TheSwamp

CAD Forums => Vertically Challenged => Land Lubber / Geographically Positioned => Topic started by: Rod on August 30, 2018, 09:01:25 PM

Title: Change "Property Set" data using Lisp
Post by: Rod on August 30, 2018, 09:01:25 PM
As a follow on from this thread http://www.theswamp.org/index.php?topic=54433.0 (http://www.theswamp.org/index.php?topic=54433.0)

My tests changing property set data in Autcoad Civil using lisp have been successful.

I am using the AecScheduleApplication COM object which is installed with Autocad architecture (and possibly installed with MEP).
Autocad architecture 2017 is installed on my machine as a trial (the trial has expired but this still works)

My test program read object data and placed it into the property set (which had already been defined and added to the objects but was empty)

I am yet to clean up the code, put in error checking and AEC version checking but here it is if anyone is interested.

Cheers, Rod.

Code - Auto/Visual Lisp: [Select]
  1. defun C:test ()
  2.   (setq ss (ssget))
  3.   (setq i 0)
  4.   (repeat (sslength ss)
  5.     (progn
  6.       (objdata2propset (ssname ss i))
  7.       (setq i (1+ i))
  8.     ) ;_ end of progn
  9.   ) ;_ end of repeat
  10.   (princ)
  11. ) ;_ end of defun
  12.  
  13. (defun objdata2propset (ent)
  14.   (setq tblname (car (ade_odgettables ent)))
  15.   (setq str (ade_odgetfield ent (car (ade_odgettables ent)) "FULLNAME" 0))
  16.   (setq vlaObj          (vlax-ename->vla-object ent)
  17.         acadObj         (vlax-get-acad-object)
  18.         schedApp        (vla-getInterfaceObject
  19.                           acadObj
  20.                           "AecX.AecScheduleApplication.7.9"
  21.                         ) ;_ end of vla-getInterfaceObject
  22.         propSets        (vlax-invoke-method schedApp 'PropertySets vlaObj)
  23.         psdName         "Road Name"
  24.         propSet         (vlax-invoke-method propSets 'Item psdName)
  25.         properties      (vlax-get-property propSet 'Properties)
  26.         propNameValList (reverse
  27.                           (vlax-for prop properties
  28.                             (if (= (vlax-get-property prop 'Name) "Road_Name")
  29.                               (vlax-put-property prop 'Value (vlax-make-variant Str))
  30.                             ) ;_ end of if
  31.                           ) ;_ end of vlax-for
  32.                         ) ;_ end of reverse
  33.   ) ;_ end of setq
  34. ) ;_ end of defun
Title: Re: Change "Property Set" data using Lisp
Post by: Rod on August 30, 2018, 09:17:41 PM
Here is a video of it at work and a DWG and lisp that allows multiple selection.
Title: Re: Change "Property Set" data using Lisp
Post by: Peter2 on September 21, 2018, 11:19:31 AM
Thanks Rod,
looks interesting. I hope that I can test it in the next time.
Title: Re: Change "Property Set" data using Lisp
Post by: MSTG007 on September 21, 2018, 01:53:13 PM
Just wanted to share. It worked great! Even with 2018. Thank you again Rod!!!
Title: Re: Change "Property Set" data using Lisp
Post by: MSTG007 on February 05, 2020, 09:23:38 AM
I know this is an old topic. But I was wondering if it was possible to make a popup box (selection dialog box) that lists the Object data fields instead of hard coding the field? The reason its hard to keep it hardcoded is because a lot of object data has different field names.
Title: Re: Change "Property Set" data using Lisp
Post by: hobleglobsquishyworms on February 11, 2020, 09:21:02 PM
Out of curiosity can I ask why you're doing this?  An agency requiring it?
Title: Re: Change "Property Set" data using Lisp
Post by: Rod on February 11, 2020, 10:06:47 PM
If you mean using property set data, it can be useful in creating schedule tables and labels.
Title: Re: Change "Property Set" data using Lisp
Post by: hobleglobsquishyworms on February 12, 2020, 02:50:19 AM
If you mean using property set data, it can be useful in creating schedule tables and labels.

Still trying to find a use for them myself. We have an agency here requiring a lot of data that it would help with, but a lot of that data still has to be manual entry / input, so we don't really get any efficiency out of it.
Title: Re: Change "Property Set" data using Lisp
Post by: MSTG007 on February 12, 2020, 06:25:27 AM
For us, we like to "tag" lines with Civil3D Labels. Right now, Civil3D does not read the Object Data fields, so we have to copy that data over into a property set. With another note, I did hear that with the next release with Civil3D and the Arc Connector. It will be able to bring the object data as a property set but I think this is still in beta.