Code Red > AutoLISP (Vanilla / Visual)

User defined properties of C3D cogo points

(1/3) > >>

CHulse:
Hi
I'm trying to extract some user defined property (UDP) values from Civil3D cogo point entities and something is baffling me.

I'm able to get the UDP values successfully using this:

--- Code - Auto/Visual Lisp: ---(vlax-invoke x 'GetUserDefinedPropertyValue "UDP_tag")
But if I try to make a separate function and pass the same variables to it, it fails for me.  I'm probably doing something stupid and I'm hoping y'all will set me straight.
This fails:

--- Code - Auto/Visual Lisp: ---(defun _GetCogoUDP (cogo UDP / )  (vlax-invoke cogo 'GetUserDefinedPropertyValue UDP))
example call:

--- Code - Auto/Visual Lisp: ---(_GetCogoUDP x "UDP_Tag")
Any help would be much appreciated.

Jeff_M:
Cary, UDPs are case-sensitive, so "UDP_tag" is not the same as "UDP_Tag"

CHulse:

--- Quote from: Jeff_M on January 27, 2023, 01:29:17 PM ---Cary, UDPs are case-sensitive, so "UDP_tag" is not the same as "UDP_Tag"

--- End quote ---

Thanks for catching that. That's just a generic example, but it made me go back to check and I did indeed have a typo. Thank you.

To take this further - can you suggest how best to trap an error like that?

Thanks!

Jeff_M:
Since there is no way with the COM API to get the UDP Classifications in the drawing without finding those assigned to point groups, this is how I'd do it:

--- Code - Auto/Visual Lisp: ---(defun _GetCogoUDP (cogo UDP / )  (if (FindUDP UDP (vlax-get cogo 'Document))    (setq return (vlax-invoke cogo 'GetUserDefinedPropertyValue UDP))    (setq return "UDP not found.")    )  return  ) (defun FindUDP (UDPName civdoc / )  (setq retval nil        way nil)  (vlax-for grp (vlax-get civdoc 'pointgroups)    (if (setq udpclass (vlax-invoke grp 'getuserdefinedpropertyclassification 'way))      (vlax-for udp (vlax-get udpclass 'userdefinedproperties)        (if (= UDPName (vlax-get udp 'name))          (setq retval udp)          )        )      )    )  retval  )

CHulse:
Thanks Jeff

Though when I implement that, it returns "UDP not found." regardless, for both valid and invalid UDP names?

Navigation

[0] Message Index

[#] Next page

Go to full version