Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Contributor
Gustavo_Bernardi
Posts: 20
Registered: ‎05-30-2009
Message 1 of 4 (327 Views)

set basepoint during insertion of blocks with AutoLISP

327 Views, 3 Replies
01-14-2013 08:31 AM

hello to all
would like to set a base point during insertion of one block.

When not insert by AutoLISP, just type "b" to be able to change the base point.

But when I'm using an AutoLISP that inserts a block, it does not work, it interrupts the sequence of routine.

Anyone have a tip that can help me improve routine?

 

Lisp:

 

(defun c:carrobox()
(setq #clayer (getvar "clayer")) 
(if (= unidades nil)(setq unidades "cm"))
(if(= unidades "cm")(setq scalefactor 1.0)(setq scalefactor 0.01))
(if (= numberboxcar nil)(setq numberboxcar 1))
(if (= passoboxcar nil)(setq passoboxcar 1))
(setq frase (strcat "\nBloco de box [Inserir,Numero = " (itoa numberboxcar)",Soma = +"(itoa passoboxcar)",-----, Un = " unidades "]<Inserir>"))
(initget "I N S U" 0)
(setq op (getkword  frase))
(cond
((= op "U")(if(= unidades "cm")(setq unidades "metros")(setq unidades "cm"))(C:carrobox))
((= op "N")(setq numberboxcar(getint "\nNúmero do box atual: "))(C:carrobox))
((= op "S")(setq passoboxcar(getint "\nIncremento a cada box: "))(C:carrobox))
(
(or(= op "I")(= op nil))
(inserirboxdecarro)
)
)
(setvar "clayer" #clayer)
)
(defun inserirboxdecarro()
(if (not (tblsearch "layer" "box de estacionamentos"))(command "._-layer" "m" "box de estacionamentos" "c" "13" "" ""))(progn(command "._-layer" "on" "box de estacionamentos" "thaw" "box de estacionamentos""")(setvar "clayer" "box de estacionamentos")) 
(command "._INSERT" "box de carro.dwg" "scale" scalefactor PAUSE pause numberboxcar)
(setq numberboxcar (+ numberboxcar passoboxcar))
(inserirboxdecarro)
)

 

Thanks In Advance

*Expert Elite*
pbejse
Posts: 2,500
Registered: ‎11-24-2009
Message 2 of 4 (272 Views)

Re: set basepoint during insertion of blocks with AutoLISP

01-17-2013 12:38 AM in reply to: Gustavo_Bernardi
(defun inserirboxdecarro ()
			(if	(not (tblsearch "layer" "box de estacionamentos"))
		(command
	"._-layer"
	"m"
	"box de estacionamentos"
	"c"
	"13"
	""
	""
	) ;_ end of command
		) ;_ end of if
			(progn (command
	 "._-layer"
	 "on"
	 "box de estacionamentos"
	 "thaw"
	 "box de estacionamentos"
	 ""
	 ) ;_ end of command
		 (setvar "clayer" "box de estacionamentos")
		 ) ;_ end of progn
			(command "._INSERT" "box de carro.dwg" "scale" scalefactor)
			(while (not (zerop (getvar 'cmdactive)))
		(command pause)
		) ;_ end of while
			(vla-put-textstring
		(car
	(vlax-invoke
(vlax-ename->vla-object (entlast))
'GetAttributes
) ;_ end of vlax-invoke
	) ;_ end of car
		numberboxcar
		) ;_ end of vla-put-textstring
 ;_ end of command
			(setq numberboxcar (+ numberboxcar passoboxcar))
			(inserirboxdecarro)
			)

 

HTH

 

Contributor
Gustavo_Bernardi
Posts: 20
Registered: ‎05-30-2009
Message 3 of 4 (237 Views)

Re: set basepoint during insertion of blocks with AutoLISP

01-23-2013 09:12 AM in reply to: pbejse

That helped a lot. Just wanted to know what made it work.
is it?

(while (not (zerop (getvar 'cmdactive)))
(command pause)

TKS

*Expert Elite*
pbejse
Posts: 2,500
Registered: ‎11-24-2009
Message 4 of 4 (212 Views)

Re: set basepoint during insertion of blocks with AutoLISP

01-25-2013 06:36 AM in reply to: Gustavo_Bernardi

Gustavo_Bernardi wrote:

That helped a lot. Just wanted to know what made it work.
is it?

(while (not (zerop (getvar 'cmdactive)))
(command pause)

TKS


Yes Gustavo_Bernardi, it  sets the command in "pause" mode indefinitely until user ends the "insert" command.

Then it assigns the string value  to the attribute.

 

Cheers

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.