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

Move a named block left 5 inches.

25 REPLIES 25
Reply
Message 1 of 26
Anonymous
840 Views, 25 Replies

Move a named block left 5 inches.

Hello Guys,

 

I'm dabbling in lisp to reduce some drafting time. I'm looking for a way to move a named block left 5 inches. The names block in this instance is "Bricks". What would be the easiest way of writing this in lisp form? I searched through the forums and I couldn't find what I was looking for. This is not after an insert command. This is a block that currently exists in the drawing template.

 

I appreciate any help to get me started.

 

Thanks,

 

Xi

 

 

25 REPLIES 25
Message 21 of 26
Anonymous
in reply to: Anonymous

...I am still asking to myself why the expression below:

(command "_.-INSERT" blocco coord)

implies the need for handly define Scal X,Y,Z and rotation when lisp is running....
Message 22 of 26
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:

two ways of aking...

...

(command "_.-INSERT" blocco coord)

 

in this way I have a problem...when I insert the block the window used for attributes open blocking the lisp routine...and forcing my manual input that Iwould like to avoid..

 

The other way is the copy with multiple option...

 

considering thre different points for the positioning of the copy...coord1, coord2, coord3 is it corret the following :

 

(command "_.copy" (ssname (ssget "_X" (list (cons 2 VAL1))) 0) "" "_Multiple" coord1 coord2 coord3 "")

 

 


On the Attributes, you could ask for the values ahead of time and save them into variables, or if you know what they should be, save them into variables without asking the User, and then feed them in at the end of the (command) function that Inserts the Block.  Or you could change the definition of the Block to make them preset values if appropriate.  Look into the ATTREQ System Variable, which may also give you some options.

 

If I understand correctly, I think you need to do the multiple copies this way:

 

(command "_.copy" (ssname (ssget "_X" (list (cons 2 VAL1))) 0) "" "_Multiple" coord coord1 coord2 coord3 "")

 

because the first point given after the Multiple option is the base point, and the rest of the points are copy-to locationa.  That assumes that 'coord' is the insertion base point of the Block, following from your insertion code.

Kent Cooper, AIA
Message 23 of 26
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:
...I am still asking to myself why the expression below:

(command "_.-INSERT" blocco coord)

implies the need for handly define Scal X,Y,Z and rotation when lisp is running....

You can specify particular values for the scales without manual input during Insertion, including "" [Enter] to accept the default values.  If you always want them at scale factors of 1 and rotation of zero:

 

(command "_.-INSERT" blocco coord "" "" "" Attributevalue1 Attributevalue2); Attribute values as needed, if needed

 

But that will be affected by whether the Block is defined to allow non-uniform scaling.  Insert one manually, see how many answers to prompts are needed, and provide those.

 

[By the way, the hyphen is not needed before the command name to avoid the dialog box when inside a (command) function.]

Kent Cooper, AIA
Message 24 of 26
stevor
in reply to: Anonymous

When BLOCKs are Inserted frequently,

as often done, routines are formed to

account for all the arguments,

either as preset defualt values,

or inputs at the time of the insert.

The routine checks the BLOCK definition,

and provides the argument responses,

about as K Cooper suggested.

S
Message 25 of 26
Anonymous
in reply to: stevor

(defun open ()
  (startapp "C:\\Program Files\\Microsoft Office 15\\root\\office15\\excel.exe" "C:\\Users\\lorenzo\\Desktop\\Lisp\\BOM.xls")
)


(defun getexcel ()
 (vl-load-com)
 (setq obXLS (vlax-get-or-create-object "Excel.Application"))
 (vla-put-visible obXLS T)
 (setq pos "A2")
        (setq corx "P2")
        (setq cory "Q2")
        (setq corz "R2")
 (setq obSheet (vlax-get-property obXLS "Cells"))
        (setq RNG1 (vlax-get-property obSheet 'Range pos))
        (setq VAL1 (vlax-get RNG1 'value))
        (princ VAL1)
 (setq obSheet (vlax-get-property obXLS "Cells"))
        (setq RNG2 (vlax-get-property obSheet 'Range corx))
        (setq VAL2 (vlax-get RNG2 'value))
        (princ VAL2)
 (setq obSheet (vlax-get-property obXLS "Cells"))
        (setq RNG3 (vlax-get-property obSheet 'Range cory))
        (setq VAL3 (vlax-get RNG3 'value))
        (princ VAL3)
 (setq obSheet (vlax-get-property obXLS "Cells"))
        (setq RNG4 (vlax-get-property obSheet 'Range corz))
        (setq VAL4 (vlax-get RNG4 'value))
        (princ VAL4)
        (setq coord (strcat VAL2 "," VAL3 "," VAL4))
        (setq blocco (strcat "D:\\CANTIERE_LORE\\08-Isometrici&Formati_STD\\ISO AUTOMATICO - TUBAZIONI\\Ricerca&Sviluppo\\Database-NP\\Posizioni\\" VAL1 ".dwg")
        (command "_INSERT" blocco coord "" "" "")
)

 

so...i don't know why...yesterday it was working...today...I see the error display (getexcel no function definition)

How is it possible?

 

The routine works untill coord definition, but if i introduce the last two instruction Lisp becomes crazy and nothing act...

Message 26 of 26
Anonymous
in reply to: Anonymous

...I have seen that I forgot the ) at the end of blocco's definition...now it works....and I will try to use it into a for cicle. 😉
Thank you for your support I will let you know

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

Post to forums  

Autodesk Design & Make Report

”Boost