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

14 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


Anonymous said...

Hi, do you know how to get the Area from a closed Feature Line into the Formula Property? I works for Length2D and Length3D but not for Area!?
Thanks!
/Thomas

Christopher Fugitt said...

I don't think you can use .NET in VBScript, so you are left with COM only. So you'd be stuck iterating the vertices to get the area. There are formulas out there, for instance this one:
https://web.archive.org/web/20120410040052/http://blog.csharphelper.com/2010/01/04/calculate-a-polygons-area-in-c.aspx

Anonymous said...

Hi Chris, is it possible to apply this to 3D Solids, I am trying to attach extended data via a property set style to 3D Solids.

Namely show the length, width, depth etc. You can show the volume through an automatic property set but not all attributes are included in the automatic property definitions.

Im guessing it has something to do with what the Civil3D API has available, I'm a novice at best with this API stuff. Is there a way to check what elements could be assigned different attributes

Anonymous said...

Hi Chris, is it possible to apply this to 3D Solids, I am trying to attach extended data via a property set style to 3D Solids.

Namely show the length, width, depth etc. You can show the volume through an automatic property set but not all attributes are included in the automatic property definitions.

Im guessing it has something to do with what the Civil3D API has available, I'm a novice at best with this API stuff. Is there a way to check what elements could be assigned different attributes

Unknown said...

Hi Chris, is it possible to apply this to 3D Solids, I am trying to attach extended data via a property set style to 3D Solids.

Namely show the length, width, depth etc. You can show the volume through an automatic property set but not all attributes are included in the automatic property definitions.

Im guessing it has something to do with what the Civil3D API has available, I'm a novice at best with this API stuff. Is there a way to check what elements could be assigned different attributes

Unknown said...

Hi Chris

I'm looking for either a full list of context values, is there anywhere to go to find these values.

Or would you know what the context values are for analysing volume surfaces?

Christopher Fugitt said...

The pipe context values may be found here: http://help.autodesk.com/view/CIV3D/2021/ENU/?guid=96ac3273-fbeb-5752-d806-1e92a7e9d76a

Other properties/methods can be found in the COM API Reference Guide:
http://docs.autodesk.com/CIV3D/2012/ENU/API_Reference_Guide/com/AeccXPipeLib__IAeccPipe.htm

Marketing Design said...

Sadly this doesn't work for Civil 3D 2020.

https://knowledge.autodesk.com/support/civil-3d/learn-explore/caas/sfdcarticles/sfdcarticles/How-to-use-property-sets-to-populate-a-pipe-with-its-upstream-and-downstream-structures-in-Civil-3D.html

or

https://knowledge.autodesk.com/support/civil-3d/troubleshooting/caas/sfdcarticles/sfdcarticles/How-to-define-property-sets-to-include-pipe-length-in-Civil-3D.html

Doesn't work aswell, if you use DUMP.lsp to pull out the Variables from the Pipe, you won't get Length3D or 2D.

Anonymous said...

Good morning everyone, I am working on the properties of corridors and surfaces, I would like to know what other properties I can work automatically (seasons, volume, characteristics) and where I can find the way to write a script to request said information. Thank you very much

LinkWithin

Blog Widget by LinkWithin

Ad