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

5 comments:

Unknown said...

Dear Mates, is there any manual where we can go deeper in vbScript formula.
I would like to generate a formula with the start and finish region , that it's defined in a corridor with diferents assemblies.

Thank you very much!
Javier

Christopher Fugitt said...

You'll want to check out the Civil 3D Developer's Guide.
https://knowledge.autodesk.com/support/civil-3d/learn-explore/caas/CloudHelp/cloudhelp/2017/ENU/Civil3D-DevGuide/files/GUID-DA303320-B66D-4F4F-A4F4-9FBBEC0754E0-htm.html

Unknown said...

Thank you very much Christopher. The problem is that I am not able to fit this structure in a formula, because I don't know how it really works.
The following sample displays the start and end station for every baseline region in a baseline:

foreach (BaselineRegion oBaselineRegion in oBaseline.BaselineRegions)
{
ed.WriteMessage(@"Baseline region information -
Start station : {0}
End station : {1}\n",
oBaselineRegion.StartStation,
oBaselineRegion.EndStation);

}
How would be written the formula in property sets for a solid 3d extracted from a corridor??( Or otherwise, for a corridor, baseline object)
I look forward to hearing you. And it's been a pleasure to get in touch.
Best regards.
Javier.

Christopher Fugitt said...

The code you posted is .NET, you'll want to use the Legacy COM API.

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

For Each oBaseline In obj.Baselines
Debug.Print "Baseline information -"
Debug.Print "Alignment : " & oBaseline.Alignment.Name
Debug.Print "Profile : " & oBaseline.Profile.Name
Debug.Print "Start station: " & oBaseline.StartStation
Debug.Print "End station : " & oBaseline.EndStation
Debug.Print
Next

https://knowledge.autodesk.com/support/civil-3d/learn-explore/caas/CloudHelp/cloudhelp/2017/ENU/Civil3D-DevGuide/files/GUID-7FB74536-C9CE-420B-BF54-7C0D57C7838E-htm.html

Unknown said...

Dear Christopher, thank you for your response. I wrote this formula expresion referenced to my Objet ID defined in my Corridor Property Data – User Defined, that applies to Corridors, Body and Solid3d, but the result is that it didn't work:

Moreover I tried this 3 Formulas in the property set window, but they didn't work, at all:

Number 1)

RESULT="--"
On Error Resume Next
Set oApp=GetObject(, "AutoCAD.Application")
Set oCivilApp=oApp.GetInterfaceObject("AeccXUiLand.AeccApplication.12.0")
Set obj=oCivilApp.ActiveDocument.ObjectIdToObject("[Corridor Property Data – User Defined:ObjectID]")
For Each oBaseline In obj.Baselines
Debug.Print "Baseline information -"
Debug.Print "Alignment : " & oBaseline.Alignment.Name
Debug.Print "Profile : " & oBaseline.Profile.Name
Debug.Print "Start station: " & oBaseline.StartStation
Debug.Print "End station : " & oBaseline.EndStation
Debug.Print
Next

Number 2)

RESULT="--"
On Error Resume Next
Set oApp=GetObject(, "AutoCAD.Application")
Set oCivilApp=oApp.GetInterfaceObject("AeccXUiLand.AeccApplication.12.0")
Set obj=oCivilApp.ActiveDocument.ObjectIdToObject("[Corridor Property Data – User Defined:ObjectID]")
RESULT=obj.Print "Start station: " & oBaseline.StartStation

Number 3)

RESULT="--"
On Error Resume Next
Set oApp=GetObject(, "AutoCAD.Application")
Set oCivilApp=oApp.GetInterfaceObject("AeccXUiLand.AeccApplication.12.0")
Set obj=oCivilApp.ActiveDocument.ObjectIdToObject("[Corridor Property Data – User Defined:ObjectID]")
RESULT= obj.oBaseline.StartStation

I don't Know if it's imposible to extract this parameter from a SOLID 3D, but it's weird, because it should be a must to add and link information in your BIM model.
Maybe is a language error or a conceptual error. ( And the most probably is taht i have poor experience programming , and just started my adventure)

I'm sincerely very grateful for your help.
Javier


LinkWithin

Blog Widget by LinkWithin

Ad