Author Topic: User defined properties of C3D cogo points  (Read 1639 times)

0 Members and 1 Guest are viewing this topic.

CHulse

  • Swamp Rat
  • Posts: 504
User defined properties of C3D cogo points
« on: January 27, 2023, 12:28:01 PM »
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: [Select]
  1. (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: [Select]
  1. (defun _GetCogoUDP (cogo UDP / )
  2.   (vlax-invoke cogo 'GetUserDefinedPropertyValue UDP))

example call:
Code - Auto/Visual Lisp: [Select]
  1. (_GetCogoUDP x "UDP_Tag")

Any help would be much appreciated.
Cary Hulse
Urban Forestry Manager
Wetland Studies and Solutions

Civil 3D 2020 & 2023

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: User defined properties of C3D cogo points
« Reply #1 on: January 27, 2023, 01:29:17 PM »
Cary, UDPs are case-sensitive, so "UDP_tag" is not the same as "UDP_Tag"

CHulse

  • Swamp Rat
  • Posts: 504
Re: User defined properties of C3D cogo points
« Reply #2 on: January 27, 2023, 02:09:09 PM »
Cary, UDPs are case-sensitive, so "UDP_tag" is not the same as "UDP_Tag"

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!
Cary Hulse
Urban Forestry Manager
Wetland Studies and Solutions

Civil 3D 2020 & 2023

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: User defined properties of C3D cogo points
« Reply #3 on: January 27, 2023, 03:25:14 PM »
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: [Select]
  1. (defun _GetCogoUDP (cogo UDP / )
  2.   (if (FindUDP UDP (vlax-get cogo 'Document))
  3.     (setq return (vlax-invoke cogo 'GetUserDefinedPropertyValue UDP))
  4.     (setq return "UDP not found.")
  5.     )
  6.   return
  7.   )
  8.  
  9. (defun FindUDP (UDPName civdoc / )
  10.   (setq retval nil
  11.         way nil)
  12.   (vlax-for grp (vlax-get civdoc 'pointgroups)
  13.     (if (setq udpclass (vlax-invoke grp 'getuserdefinedpropertyclassification 'way))
  14.       (vlax-for udp (vlax-get udpclass 'userdefinedproperties)
  15.         (if (= UDPName (vlax-get udp 'name))
  16.           (setq retval udp)
  17.           )
  18.         )
  19.       )
  20.     )
  21.   retval
  22.   )

CHulse

  • Swamp Rat
  • Posts: 504
Re: User defined properties of C3D cogo points
« Reply #4 on: January 27, 2023, 03:55:29 PM »
Thanks Jeff

Though when I implement that, it returns "UDP not found." regardless, for both valid and invalid UDP names?
Cary Hulse
Urban Forestry Manager
Wetland Studies and Solutions

Civil 3D 2020 & 2023

CHulse

  • Swamp Rat
  • Posts: 504
Re: User defined properties of C3D cogo points
« Reply #5 on: January 27, 2023, 04:10:26 PM »
So this is what I came up with to avoid the error. Seems to work.

Code - Auto/Visual Lisp: [Select]
  1. (defun _GetCogoUDP (cogo UDP / u ret)
  2. (setq u (vl-catch-all-apply 'vlax-invoke (list cogo 'GetUserDefinedPropertyValue UDP)))
  3.         (setq ret "UPD Not Found")
  4.         (setq ret u)
  5.   )
  6. ret
  7. );_end defun
Cary Hulse
Urban Forestry Manager
Wetland Studies and Solutions

Civil 3D 2020 & 2023

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: User defined properties of C3D cogo points
« Reply #6 on: January 27, 2023, 04:30:37 PM »
The FindUDP worked for me. It will fail if no point groups have the Classification assigned, or if it is assigned with multiple classifications.

After I posted that I thought about trying the vl-catch-all-apply approach. Glad it worked for you.

CHulse

  • Swamp Rat
  • Posts: 504
Re: User defined properties of C3D cogo points
« Reply #7 on: January 27, 2023, 04:32:47 PM »
Ah. I think all my point groups are set to "ALL" for the classification.
So that I think explains it?
Cary Hulse
Urban Forestry Manager
Wetland Studies and Solutions

Civil 3D 2020 & 2023

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: User defined properties of C3D cogo points
« Reply #8 on: January 27, 2023, 05:08:31 PM »
Yes, the All would cause no UDPs to be found with the method I posted. The COM API really sucks for working with UDPs and UDP Classifications. It is good at some things, but is really limited.

CHulse

  • Swamp Rat
  • Posts: 504
Re: User defined properties of C3D cogo points
« Reply #9 on: January 28, 2023, 08:10:57 AM »
Yes, the All would cause no UDPs to be found with the method I posted. The COM API really sucks for working with UDPs and UDP Classifications. It is good at some things, but is really limited.

Thanks again Jeff. Very helpful.
Cary Hulse
Urban Forestry Manager
Wetland Studies and Solutions

Civil 3D 2020 & 2023

CHulse

  • Swamp Rat
  • Posts: 504
Re: User defined properties of C3D cogo points
« Reply #10 on: July 28, 2023, 09:23:25 AM »
Circling back to this - is there any way to assign a UDP Classification to a point group via lisp?
Cary Hulse
Urban Forestry Manager
Wetland Studies and Solutions

Civil 3D 2020 & 2023

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: User defined properties of C3D cogo points
« Reply #11 on: July 28, 2023, 11:26:26 AM »
Circling back to this - is there any way to assign a UDP Classification to a point group via lisp?
Yes. http://docs.autodesk.com/CIV3D/2012/ENU/API_Reference_Guide/com/AeccXLandLib__IAeccPointGroup__SetUserDefinedPropertyClassification@[in]_AeccUDPClassificationApplyWay@[in]_VARIANT.htm

(vlax-invoke ptgroup 'setuserdefinedpropertyclassification 2 "StationOffset");;2=custom classification, 0=None, 1=All
« Last Edit: July 28, 2023, 11:38:39 AM by Jeff_M »

CHulse

  • Swamp Rat
  • Posts: 504
Re: User defined properties of C3D cogo points
« Reply #12 on: July 28, 2023, 12:47:29 PM »
Thanks Jeff
Cary Hulse
Urban Forestry Manager
Wetland Studies and Solutions

Civil 3D 2020 & 2023