Author Topic: Set alignment label style via lisp/etc before placing  (Read 5373 times)

0 Members and 1 Guest are viewing this topic.

entget

  • Mosquito
  • Posts: 19
Set alignment label style via lisp/etc before placing
« on: October 29, 2019, 10:56:33 PM »
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?

Thanks!

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
Re: Set alignment label style via lisp/etc before placing
« Reply #1 on: October 30, 2019, 01:30:19 PM »
Attached is a lisp function to set the style before adding the label.

entget

  • Mosquito
  • Posts: 19
Re: Set alignment label style via lisp/etc before placing
« Reply #2 on: October 30, 2019, 02:41:05 PM »
Jeff,

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
Corey