Undocumented property set definitions continued
In the last post we looked at how to add an undocumented property to a property set definition. This time lets try to add a formula based location property to a space object using the method from the last post.
[frame bgcolor=”#DDDDDD” version=”light”]RESULT="NA" On Error Resume Next Set AcadApp = GetObject(, "AutoCAD.Application") Set MEPObject = AcadApp.Activedocument.Objectidtoobject("[ObjectID]") RESULT= MEPObject.location[/frame]
When this property definition is created and made visible there is no information being reported. The property definition is blank. Why is this? This is because a location property is actually made up of three different values (x,y, and z) that are stored as a point object in the system. VBScript does not know how to read point objects so the point object will first need to be converted into an array before it can read. The following code gets the space location and breaks the location point up into its 3 separate values and then concatenates them together as a string so we can read them and returns the result.
[frame bgcolor=”#DDDDDD” version=”light”]On Error Resume Next DecimalPlaces = 8 Set acadApp = GetObject(,"AutoCAD.Application") 'ACADVER values: 'ACA 2010 = "18.0s (LMS Tech)" 'ACA 2011 = "18.1s (LMS Tech)" 'ACA 2012 = "18.2s (LMS Tech)" 'ACA 2013 = "19.0s (LMS Tech)" 'ACA 2014 = "19.1s (LMS Tech)" 'ACA 2015 = "20.0s (LMS Tech)" acadVerString = acadApp.ActiveDocument.GetVariable("ACADVER") 'Set ACA application string, based on version running: Select Case acadVerString Case "18.0s (LMS Tech)" 'ACA-2010 aecBaseVer = "AecX.AecBaseApplication.6.0" Case "18.1s (LMS Tech)" 'ACA-2011 aecBaseVer = "AecX.AecBaseApplication.6.5" Case "18.2s (LMS Tech)" 'ACA-2012 aecBaseVer = "AecX.AecBaseApplication.6.7" Case "19.0s (LMS Tech)" 'ACA-2013 aecBaseVer = "AecX.AecBaseApplication.7.0" Case "19.1s (LMS Tech)" 'ACA-2014 aecBaseVer = "AecX.AecBaseApplication.7.5" Case "20.0s (LMS Tech)" 'ACA-2015 aecBaseVer = "AecX.AecBaseApplication.7.7" Case Else aecBaseVer = "Unknown" End Select If aecBaseVer = "Unknown" Then RESULT = "Unknown Version" Else Set aecBase = acadApp.GetInterfaceObject(aecBaseVer) aecBase.Init acadApp Set SpaceObject = acadApp.ActiveDocument.ObjectIDToObject([ObjectID][/frame]) Set UtilityObject = aecBase.ActiveDocument.Utility ' Get the Location of the SpaceObject and break down into individual X, Y, and Z parts SpaceObjectLocation = UtilityObject.ConvertToVariantArray(SpaceObj ect.Location) LocationX = Round(SpaceObjectLocation(0), DecimalPlaces) LocationY = Round(SpaceObjectLocation(1), DecimalPlaces) LocationZ = Round(SpaceObjectLocation(2), DecimalPlaces) 'Return the results RESULT = Cstr(LocationX & ";" & LocationY & ";" & LocationZ) End If
The value of the property definition should look something like this 144.124;1200.375;0. This would place the space object 12′-0 1/8″ on the positive X axis, 100′- 0 3/8″ on the Y axis and at a zero elevation. If you would like to see more or less decimal places in the result then you can change the second line of code from DecimalPlaces = 3 to DecimalPlaces = X where X is the amount of decimal places you would like to see. And finally if you are only interested in the elevation of the space then you can modify the result of the script to instead say RESULT = LocationZ. There is no need to convert to a string in this case as a number would be more preferable as the units of the property definition could then be set to a length value and read as feet and inches.