Ad

Tuesday, August 15, 2017

Property Set Formulas

Sometime in the recent past Autodesk enabled and advocated the use of Property Sets. It’s kind of sad why Autodesk did this, but that is another story about the lack of BIM in Civil 3D. I recently learned one can create formulas in the Property Sets and use VBScripts in the formulas. We can then use these scripts to extract information from objects. In this post I’m going to show how you can create a script to show a Pipe’s Material.

The first step is to type PropertySetDefine at the command line. This will bring up the Style Manager. image

Right click on the Property Set Definitions and select the New option. I’m using the default name of New Style. In the script I will want to use the ObjectID of the object. Note that this ObjectID is different than ObjectId found in .NET. To add this property click on the Applies To tab of the Property Set Definition select Pipe.

image

Then press the Add Automatic Property Definition button and select Object ID from the list.

image

We will need this property in the script. So now we can create a script. Note that if you don’t want to see the property in the Properties palette you can check the Visible check box to unchecked.

image

Now press the Add Formula Property Definition button. Then Right Click, in the Insert Property Defintions, on the ObjectID and select Insert. This will add the ObjectID to the formula box and in the Enter Sample Values list.

image

Next insert the following formula in the formula box. Remove the [ObjectID] from the previous step. Make sure each line

RESULT="—"

On Error Resume Next

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

Set oCivilApp=oApp.GetInterfaceObject("AeccXUiLand.AeccApplication.11.0")

Set obj=oCivilApp.ActiveDocument.ObjectIdToObject("[ObjectID]")

RESULT=obj.PartDataRecord.FindByContext(300).Tag

If the text ends up large press OK and then go back into the dialog box. This will reset the text height to the default size. Then go into the drawing and apply the property set by selecting a pipe and pressing the Add Property Set button.

image

Then the Material name should show up in the box.

image

You can find the list of standard Context here: http://blog.civil3dreminders.com/2016/03/freaking-context-values.html if you want to use a different value.

Here is a video showing the steps: https://www.youtube.com/watch?v=v97WpUgk0w8

No comments:

LinkWithin

Blog Widget by LinkWithin

Ad