Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

set basepoint during insertion of blocks with AutoLISP

3 REPLIES 3
Reply
Message 1 of 4
Gustavo_Bernardi
723 Views, 3 Replies

set basepoint during insertion of blocks with AutoLISP

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

3 REPLIES 3
Message 2 of 4
pbejse
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

 

Message 3 of 4
Gustavo_Bernardi
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

Message 4 of 4
pbejse
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

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost