AutoLISP adding multiple atts to a block, but they're all coming in at 0

AutoLISP adding multiple atts to a block, but they're all coming in at 0

acadadmin3KNUF
Advocate Advocate
317 Views
2 Replies
Message 1 of 3

AutoLISP adding multiple atts to a block, but they're all coming in at 0

acadadmin3KNUF
Advocate
Advocate

Hello to all:

 

I have a lot of blocks that I have to add the same attributes to.  I have code that is successfully adding all the atts I need...but they are ALL coming in at 0,0 in the block editor even though I tried to add code for specific insertion points.  Here is a snippet from the full code for one attribute:

 

 

 

(foreach blk blks
         (setq def (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) blk))
         (setq AttObj1
            (vla-addattribute def
              8
              acattributemodelockposition
              "ONE OR BOTH SIDES?"
              (vlax-3D-point 200 72)
              "SYS_DCV_SIDE"
              "default"
            )
         )

 

 

I've attached the LISP file and a very simple block that I've been using for testing.  Where's my error?  Thanks in advance for any help!

0 Likes
318 Views
2 Replies
Replies (2)
Message 2 of 3

-didier-
Advisor
Advisor

Bonjour @acadadmin3KNUF 

 

This is not really a solution, but the beginning of a solution :

If you use "acAlignmentLeft" instead of "acAlignmentmiddle"

The values of insertion points are correct.

 

You have to work with the options of alignment…
Sorry for my poor English.

 

Amicalement

Éternel débutant.. my site for learning : Programmer dans AutoCAD

DA

EESignature

0 Likes
Message 3 of 3

paullimapa
Mentor
Mentor

I think the problem has to do with the parts of the code where you use the vlax-3D-point function.

Per on-line help the function needs to be supplied with an x coordinate followed by a y coordinate.

If you want the y coordinate to change which means it won't overlap on the same line then you need to be changing the 2nd number and not the first.

Take a look at how the vla-addattribute is implemented on this post:

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-select-blocks-and-add-attrib...

 

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes