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

0 Members and 1 Guest are viewing this topic.

Rod

  • Newt
  • Posts: 106
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
  18.  "AecX.AecScheduleApplication.7.9"
  19. ) ;_ end of vla-getInterfaceObject
  20. propSets (vlax-invoke-method schedApp 'PropertySets vlaObj)
  21. psdName "Road Name"
  22. propSet (vlax-invoke-method propSets 'Item psdName)
  23. properties (vlax-get-property propSet 'Properties)
  24. propNameValList (reverse
  25.  (vlax-for prop properties
  26.    (if (= (vlax-get-property prop 'Name) "Road_Name")
  27.      (vlax-put-property prop 'Value (vlax-make-variant Str))
  28.    ) ;_ end of if
  29.  ) ;_ end of vlax-for
  30. ) ;_ end of reverse
  31.  ) ;_ end of setq
  32. ) ;_ end of defun
Standing on the toes of giants.

Rod

  • Newt
  • Posts: 106
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.
Standing on the toes of giants.

Peter2

  • Swamp Rat
  • Posts: 527
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 2017 - 2019 German (so some technical terms will be badly retranslated to English)
Civil 3D 2018 - 2019
BricsCAD V18

MSTG007

  • Water Moccasin
  • Posts: 2329
  • 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 2018