• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Visual LISP, AutoLISP and General Customization

    Reply
    Contributor
    Posts: 16
    Registered: ‎05-30-2009

    set basepoint during insertion of blocks with AutoLISP

    174 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

    Please use plain text.
    *Expert Elite*
    Posts: 2,057
    Registered: ‎11-24-2009

    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

     

    Please use plain text.
    Contributor
    Posts: 16
    Registered: ‎05-30-2009

    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

    Please use plain text.
    *Expert Elite*
    Posts: 2,057
    Registered: ‎11-24-2009

    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

     

    Please use plain text.