CAD Forums > Vertically Challenged

Set alignment label style via lisp/etc before placing


I'm trying to place a couple custom alignment labels via lisp. The label basically labels a point with the station of two different, selected alignments  ...this is the gist of my code:
(setq alignment1 (entsel))
(setq alignment2 (entsel))
(setq pt1 (getpoint))
(command "AddAlignOffLbl" alignment1 pt1 pt1 alignment2 "")
(vlax-put-Property(vlax-ename->vla-object(entlast)) 'LabelStyle "Style1")

My deal is this - if Style1 is "current" in the add label dialog box all is good, but if any other style is "current" it only passes the first alignment to the label and the label comes up with ??? in place of the second alignment. If I select the label and go to the properties palette, the second alignment is listed as "none" or something and I can select the desired alignment from within that pull down and it populates the label and all is good.

My question then is this - can I set the default or current label style via lisp in the beginning of my code so it places correctly when ran?


Attached is a lisp function to set the style before adding the label.


I can not thank you enough! This is exactly what I needed and it worked perfectly "out of the box" the first time.
...will address error handling - so it wont puke lol

Truth be told - critical parts of the code I have to this point are probably due in part to studying other code you've posted in the past. Sincerely appreciate your contributions!

Thanks again


[0] Message Index

Go to full version