AutoCAD Architecture Customization
Welcome to Autodesk’s AutoCAD Architecture Customization Forums. Share your knowledge, ask questions, and explore popular AutoCAD Architecture Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

VBA Based Formula Property in PSD (a Hanger solution example).

7 REPLIES 7
Reply
Message 1 of 8
mdhutchinson
1139 Views, 7 Replies

VBA Based Formula Property in PSD (a Hanger solution example).

VBA is no longer available except as a separate download... some have said that VBA in 2013 will not be supported at all - separate download or not.

It is my understanding however, that VBA based code will still work in VBScript even though the separate download VBA is not in place.... I've proven this with the below code that works.

 

I have found acadauto.chm (Acad ActiveX VBA Reference) for core AutoCAD VBA. 

The question: Where can I find the newest help file for AutoCAD MEP Active X VBA???

 

I painstackingly got the below code to work.

Essentially, I have a lisp app that inserts an AutoCAD Block at the top of user selected MEP Pipe objects (a pipe style created for All-Thread Rod for Hangers).

The lisp app inserts the block and adds XData to the Pipe with 1005 group code (Handle)... the below code snags the XData attached to the pipe and reads the Handle. If the Handle points to an existing Block and the Block insertion point exists within a fuzz factor from the top of the pipe (All-Thread rod)... then the value of the formula is the name of the AutoCAD Block. This will then be included in the MEP Schedule.

 

Side interest... any thoughts for improvment, or perthaps on the reliability of the below code would be appreciated. Note: The [Handle] field below is an automatic property taken from the pipe (All-Thread Rod).

 

 

'== Converts XData Handle (Block) on All-Thread Rod to an Obj. Tests location, if not there returns to empty String

On Error Resume Next

Set AcadApp = GetObject(,"AutoCAD.Application")

AcadVerString = AcadApp.ActiveDocument.GetVariable("ACADVER")

Select Case AcadVerString

   Case "18.1s (LMS Tech)"

      aecBaseVer = "AecX.AecBaseApplication.6.5"

   Case "18.2s (LMS Tech)"

      aecBaseVer = "AecX.AecBaseApplication.6.7"

   Case Else

      aecBaseVer = "Unknown"

End Select

If aecBaseVer = "Unknown" Then

      RESULT = "Unknown Version"

   Else

' >>>> Setup to work with the coordinates

      Set aecBase = AcadApp.GetinterfaceObject(aecBaseVer)

      aecBase.Init AcadApp

      Set Util = aecBase.ActiveDocument.Utility

' >>>> Get the Rod and the XData if there is any.

      Set RodObj = Nothing

      Set RodObj = AcadApp.ActiveDocument.HandleToObject("[Handle]")

      RodObj.GetXData "TWC-Hangers", xdataType, xdataValue

      BlockHandle = xdataValue (2)

      Set BlockObj = Nothing

'>>>> Convert the Handle to an object.

      Set BlockObj = AcadApp.ActiveDocument.HandleToObject(BlockHandle)

      If Not BlockObj Is Nothing Then ' check insertion point first - then use block name if okay.

            Fuz = 0.02

            ZFuz = 8.3125

            RLoc = Util.ConverttoVariantArray(RodObj.EndPoint)

            BLoc = Util.ConverttoVariantArray(BlockObj.InsertionPoint)

            XCom = ((Abs (RLoc(0) - BLoc(0))) <= Fuz)

            YCom = ((Abs (RLoc(1) - BLoc(1))) <= Fuz)

            ZCom = ((Abs (RLoc(2) - BLoc(2))) <= ZFuz)

            If (XCom and YCom and ZCom) Then

                        BlockName = BlockObj.EffectiveName

                        RESULT = BlockName

                  Else

                        RESULT = ""

            End If

      Else

            RESULT = ""

      End If

End If

7 REPLIES 7
Message 2 of 8
Anonymous
in reply to: mdhutchinson

Is this for AutoCad Architecture 2014?

 

Message 3 of 8
mdhutchinson
in reply to: Anonymous

Close... it is for AutoCAD MEP 2014.

 

why?

Message 4 of 8
Anonymous
in reply to: mdhutchinson

I am trying to get the HANDLE id to display in a custom Table. using PSD and came across your post.

Message 5 of 8
mdhutchinson
in reply to: Anonymous

I think Handle is a automatic property that is redily availiable... check your automatic properties.

What Arch object are you working with?

Message 6 of 8
Anonymous
in reply to: mdhutchinson

Well its not in the General Properties. If you  list it, it displays. I am using Acad Arch And MeP.

Message 7 of 8
Anonymous
in reply to: Anonymous

i wanted for all objects, Lines, plines, arcs, walls, space, MEP, doors etc.

Message 8 of 8
David_W_Koch
in reply to: Anonymous

Handle is an automatic property for all graphic objects, AEC and AutoCAD.


David Koch
AutoCAD Architecture and Revit User
Blog | LinkedIn
EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost