Category Archives: Property Sets

You are here: Home » Category: "Property Sets"

Mass Element Elevation in a Property Set

Posted by  | Categories: Autocad MEP, Property Sets

 

Recently a question was asked on the AutoCAD MEP forums about how to put the elevation of a Mass Element in a property set definition when neither the location or the elevation was available as an automatic property.  You can view the original post here.  Since this was very similar to a post that was covered previously on this blog it was an easy solution.  First I created a new property set definition that referenced a mass element and then added the automatic property definition OBJECTID.  Once that was complete I created a new formula definition and added the following code.  Make sure to replace the [OBJECTID] in the code below with a reference to the automatic property!

 

On Error Resume Next
DecimalPlaces = 8
Set acadApp = GetObject(,"AutoCAD.Application") 

'ACADVER values:
'MEP 2010 = "18.0s (LMS Tech)" 
'MEP 2011 = "18.1s (LMS Tech)"
'MEP 2012 = "18.2s (LMS Tech)"
'MEP 2013 = "19.0s (LMS Tech)" 
'MEP 2014 = "19.1s (LMS Tech)" 
'MEP 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)"  'MEP-2010 
		aecBaseVer = "AecX.AecBaseApplication.6.0" 

	Case "18.1s (LMS Tech)"  'MEP-2011 
		aecBaseVer = "AecX.AecBaseApplication.6.5" 

	Case "18.2s (LMS Tech)"  'MEP-2012 
		aecBaseVer = "AecX.AecBaseApplication.6.7"

	Case "19.0s (LMS Tech)"  'MEP-2013 
		aecBaseVer = "AecX.AecBaseApplication.7.0"

	Case "19.1s (LMS Tech)"  'MEP-2014 
		aecBaseVer = "AecX.AecBaseApplication.7.5"

	Case "20.0s (LMS Tech)"  'MEP-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 MassElementObject = acadApp.ActiveDocument.ObjectIDToObject([ObjectID])
	Set UtilityObject = aecBase.ActiveDocument.Utility

	' Get the Normal of the Object and break down into individual X, Y, and Z parts
	MassElementObjectNormal = UtilityObject.ConvertToVariantArray(MassElementObject.Location)
	NormalX = Round(MassElementObjectNormal(0), DecimalPlaces)
	NormalY = Round(MassElementObjectNormal(1), DecimalPlaces)
	NormalZ = Round(MassElementObjectNormal(2), DecimalPlaces)

	'Return the results
       RESULT = Cdbl(NormalZ)


End If

 

Download Sample Drawing

 

 

 

Undocumented property set definitions continued

Posted by  | Categories: Autocad MEP, Property Sets

 

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.

RESULT="NA"
On Error Resume Next
Set AcadApp = GetObject(, "AutoCAD.Application")
Set MEPObject = AcadApp.Activedocument.Objectidtoobject("[ObjectID]")
RESULT= MEPObject.location

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.

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])
	Set UtilityObject = aecBase.ActiveDocument.Utility

	' Get the Location of the SpaceObject and break down into individual X, Y, and Z parts
	SpaceObjectLocation = UtilityObject.ConvertToVariantArray(SpaceObject.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.

 

Space Object Location

Space Object Location

Undocumented Property Set Definitions

Posted by  | Categories: Autocad MEP, Property Sets

If you heavily use property sets then at one time or another you have found the need to schedule a property that is not readily available via an automatic property definition.  For example when creating a pipe system you can assign it a system family (commonly known as group) that will allow different systems of the same family to interconnect.  Systems that are not of the same group will not interconnect.  This could be a handy property to schedule but how do you do it?  System group is not an automatic property of MEP objects.

First start the style manager and then open up the property set that you wish to add the system family definition to.  The first thing that needs to be done is to add the automatic property definition ObjectID to the property set.  This is needed to access information about the object.  Then just add the following code to a formula based property definition:

RESULT="NA"
On Error Resume Next
Set AcadApp = GetObject(, "AutoCAD.Application")
Set MEPObject = AcadApp.Activedocument.Objectidtoobject("[ObjectID]")
RESULT= MEPObject.SystemFamily
 

Make sure to input [ObjectID] by clicking on the definition in the Insert Property Definition section in the lower left portion of the dialog window.  Hit Ok and make sure to make your new property definition viewable so you can see it on the property palette’s extended tab.

System Family Formula Editor

System Family Formula Based Property Definition