Author Topic: Change "Property Set" data using Lisp  (Read 1431 times)

0 Members and 1 Guest are viewing this topic.

Rod

  • Newt
  • Posts: 119
Change "Property Set" data using Lisp
« on: August 30, 2018, 09:01:25 PM »
As a follow on from this thread 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
"All models are wrong, some models are useful" - George Box

Rod

  • Newt
  • Posts: 119
Re: Change "Property Set" data using Lisp
« Reply #1 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.
"All models are wrong, some models are useful" - George Box

Peter2

  • Swamp Rat
  • Posts: 584
Re: Change "Property Set" data using Lisp
« Reply #2 on: September 21, 2018, 11:19:31 AM »
Thanks Rod,
looks interesting. I hope that I can test it in the next time.
Peter

AutoCAD Map 3D 2018 German (so some technical terms will be badly retranslated to English)
BricsCAD V19

MSTG007

  • Water Moccasin
  • Posts: 2410
  • I can't remeber what I already asked! I need help!
Re: Change "Property Set" data using Lisp
« Reply #3 on: September 21, 2018, 01:53:13 PM »
Just wanted to share. It worked great! Even with 2018. Thank you again Rod!!!
Autodesk Infrastructure Design Suite 2019

MSTG007

  • Water Moccasin
  • Posts: 2410
  • I can't remeber what I already asked! I need help!
Re: Change "Property Set" data using Lisp
« Reply #4 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.
Autodesk Infrastructure Design Suite 2019

hobleglobsquishyworms

  • Swamp Rat
  • Posts: 802
  • .net stuff
Re: Change "Property Set" data using Lisp
« Reply #5 on: February 11, 2020, 09:21:02 PM »
Out of curiosity can I ask why you're doing this?  An agency requiring it?

Rod

  • Newt
  • Posts: 119
Re: Change "Property Set" data using Lisp
« Reply #6 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.
"All models are wrong, some models are useful" - George Box

hobleglobsquishyworms

  • Swamp Rat
  • Posts: 802
  • .net stuff
Re: Change "Property Set" data using Lisp
« Reply #7 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.

MSTG007

  • Water Moccasin
  • Posts: 2410
  • I can't remeber what I already asked! I need help!
Re: Change "Property Set" data using Lisp
« Reply #8 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.
Autodesk Infrastructure Design Suite 2019