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
I am trying to get the HANDLE id to display in a custom Table. using PSD and came across your post.
I think Handle is a automatic property that is redily availiable... check your automatic properties.
What Arch object are you working with?
Well its not in the General Properties. If you list it, it displays. I am using Acad Arch And MeP.