Author Topic: How to adapt a lisp code to autocad mep?  (Read 1568 times)

0 Members and 1 Guest are viewing this topic.

jtm2020hyo

  • Newt
  • Posts: 198
How to adapt a lisp code to autocad mep?
« on: November 01, 2021, 12:18:54 AM »
here the code:

Code: [Select]
(defun C:test ()
  (setq ss (ssget))
  (setq i 0)
  (repeat (sslength ss)
    (progn
      (objdata2propset (ssname ss i))
      (setq i (1+ i))
    ) ;_ end of progn
  ) ;_ end of repeat
  (princ)
) ;_ end of defun

(defun objdata2propset (ent)
  (setq tblname (car (ade_odgettables ent)))
  (setq str (ade_odgetfield ent (car (ade_odgettables ent)) "FULLNAME" 0))
  (setq vlaObj (vlax-ename->vla-object ent)
acadObj (vlax-get-acad-object)
schedApp (vla-getInterfaceObject
  acadObj
  "AecX.AecScheduleApplication.7.9"
) ;_ end of vla-getInterfaceObject
propSets (vlax-invoke-method schedApp 'PropertySets vlaObj)
psdName "Road Name"
propSet (vlax-invoke-method propSets 'Item psdName)
properties (vlax-get-property propSet 'Properties)
propNameValList (reverse
  (vlax-for prop properties
    (if (= (vlax-get-property prop 'Name) "Road_Name")
      (vlax-put-property prop 'Value (vlax-make-variant Str))
    ) ;_ end of if
  ) ;_ end of vlax-for
) ;_ end of reverse
  ) ;_ end of setq
) ;_ end of defun


;|«Visual LISP© Format Options»
(200 2 40 2 T "end of " 100 20 0 0 0 T T nil T)
;*** DO NOT add text below the comment! ***|;

could help me to edit this code to be used in AutoCAD MEP?

Rod

  • Newt
  • Posts: 185
Re: How to adapt a lisp code to autocad mep?
« Reply #1 on: November 01, 2021, 12:58:53 AM »
Hi jtm2020hyo,

What are you trying to do? Push values into property set data through lisp?

Cheers, Rod.

For anyone else following my code was originally posted here
http://www.theswamp.org/index.php?topic=54460.msg589886#msg589886
"All models are wrong, some models are useful" - George Box

baitang36

  • Bull Frog
  • Posts: 213
Re: How to adapt a lisp code to autocad mep?
« Reply #2 on: November 01, 2021, 03:55:51 AM »
what is autocad mep?

jtm2020hyo

  • Newt
  • Posts: 198
Re: How to adapt a lisp code to autocad mep?
« Reply #3 on: November 01, 2021, 10:36:12 AM »
Hi jtm2020hyo,

What are you trying to do? Push values into property set data through lisp?

Cheers, Rod.

For anyone else following my code was originally posted here
http://www.theswamp.org/index.php?topic=54460.msg589886#msg589886

thanks for reply, until if found your code works for CIVIL3D, but drop "ade_odgettables " error for AutoCAD Architecture and AutoCAD MEP

I wish study the code and adapt it to use to insert Block AttDef Values fields to Property Set Definitions.


Rod

  • Newt
  • Posts: 185
Re: How to adapt a lisp code to autocad mep?
« Reply #4 on: November 01, 2021, 06:28:57 PM »
You can use a property set formula to refer to a block attribute. I have an example somewhere I can look for, or you can post your block if you are happy to.

If you still need to set the property set values through lisp you will need the AecScheduleApplication COM object installed. It was not installed as part of AutoCAD Civil it might be installed as part of MEP. You can just search for it in the registry to check.

To install it I just installed AutoCAD architecture (from my testing even the demo will work after the demo has expired).

I don't have much time to help at the moment, will do if I can.

Cheers, Rod,
"All models are wrong, some models are useful" - George Box

BIGAL

  • Swamp Rat
  • Posts: 1417
  • 40 + years of using Autocad
Re: How to adapt a lisp code to autocad mep?
« Reply #5 on: November 01, 2021, 09:11:32 PM »
As Rod has said they dont supply the dll that makes life easier. I am sure I found something about make "property" trying to find.

So to clarify you have a block and want to set a Property not a OD to a object.

Note if you have AecScheduleApplication.dll you need to do "About" and check on product number as it changes with each version eg 7.9 is what Rod has.

I think it was convert property data to a block atts the opposite.

Did you google ?

« Last Edit: November 01, 2021, 09:15:33 PM by BIGAL »
A man who never made a mistake never made anything

jtm2020hyo

  • Newt
  • Posts: 198
Re: How to adapt a lisp code to autocad mep?
« Reply #6 on: November 16, 2021, 09:13:55 PM »
I did not found AecScheduleApplication.dll in AutoCAD MEP

I googled but I did not found anything.

EDIT1: I found "AecX.AecXScheduleRes.8.4" but I still have the "no function definition: ADE_ODGETTABLES", the good part is that the lisp finally run.
« Last Edit: November 17, 2021, 06:21:10 AM by jtm2020hyo »

jtm2020hyo

  • Newt
  • Posts: 198
Re: How to adapt a lisp code to autocad mep?
« Reply #7 on: November 17, 2021, 06:06:19 AM »
Hi jtm2020hyo,

What are you trying to do? Push values into property set data through lisp?

I wish to create an anchorage between ACAD objects (no AMEP or ACA) using Fields in Property Set Data.

something like this:

in the file



here we have 3 objects







I wish link Attribute Fields since 2 Blocks Objects to last Block's Property Set Data, (in the attached sample I used Lines, but recently I found that is possible use Fields to link AMEP objects) something like this:



related:

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/anchor-properties-set-data-to-properties-of-others-objects/m-p/10681167#M421792

PD: attached file