DigiPara Liftdesigner LDX API
Loading...
Searching...
No Matches
Modify Object BIM Properties

API method: ILDXObject5.ObjectBIMSettings

Treename: Shaft0.Car.BIMSettings.

 ' from Samples/Src/LDXAPIExamples/Example_LDXBIMProperties.vb

    <APIHelpAttribute(APIHelpModes.FireCalcModel Or APIHelpModes.LoadLD3File, {APIHelpModes.InputParaLDXDoc}, "Shaft0.Car.BIMSettings.", "LDXObject~ObjectBIMSettings", "Modify Object BIM Properties")>
 Public Shared Sub ObjectBIMSettings(ByRef ldxDocument As DigiPara.LDX.LDXDocument)

     ' generate and prune document BIM settings
     InitializeDocumentBIMSettings(ldxDocument)
     Dim documentBIMSettings As DigiPara.LDX.LDXDocumentBIMSettings = ldxDocument.DocumentBIMSettings
     documentBIMSettings.Prune()

     Dim ldxObject As DigiPara.LDX.LDXObject
     Dim BIMSettings As DigiPara.LDX.LDXBIMSettings
     Dim BIMPropertyStandard As DigiPara.LDX.LDXBIMPropertyStandard
     Dim BIMProperty As DigiPara.LDX.LDXBIMProperty


     ' first for the document itself
     ldxObject = ldxDocument.Object

     ' TR-06129 changed the default to have LDXDocument and other classes exported by default, for the test to work, we need to override the default now.
     Dim classProperties = documentBIMSettings.ClassBIMSettingsByObject(ldxObject).IndividualBIMSettings
     classProperties.BIMExportMode = DigiPara.LDX.BIMExportModes.bemNone

     ' verify that we are allowed to add BIM properties
     System.Diagnostics.Debug.Assert((ldxObject.BIMExportMode And DigiPara.LDX.BIMExportModes.bemExportPossible) = DigiPara.LDX.BIMExportModes.bemExportPossible)

     ' not all objects allow it, but LDXDocument and all LDXComps; on ldxDocument.Shafts.Object, the following operations would fail.
     System.Diagnostics.Debug.Assert((ldxDocument.Shafts.Object.BIMExportMode And DigiPara.LDX.BIMExportModes.bemExportPossible) = DigiPara.LDX.BIMExportModes.bemNone)

     ' deactivate BIM properties (for starters)
     ldxObject.BIMExportMode = DigiPara.LDX.BIMExportModes.bemNone

     ' BIM properties are supposed to be gone (after a recalc)
     ldxDocument.CalculateModel(DigiPara.LDX.CalculateModelModes.rcmCalc)
     System.Diagnostics.Debug.Assert(IsNothing(ldxObject.ObjectBIMSettings))

     ' activate BIM properties
     ldxObject.BIMExportMode = ldxObject.BIMExportMode Or DigiPara.LDX.BIMExportModes.bemExportProperties
     System.Diagnostics.Debug.Assert(Not IsNothing(ldxObject.ObjectBIMSettings)) ' should be there immediately without recalc
     ' for ldBIM exports, the bemExportProperties also has the effect that the object will get exported into its own 3DDWG/Family,
     ' because the exported BIM properties need a place to be stored on.

     BIMSettings = ldxObject.ObjectBIMSettings.BIMSettings

     System.Diagnostics.Debug.Assert(ReferenceEquals(BIMSettings.DocumentBIMSettings, ldxDocument.DocumentBIMSettings))

     ' move on to the car
     ldxObject = ldxDocument.Shafts(0).Car.Object
     ldxObject.BIMExportMode = ldxObject.BIMExportMode Or DigiPara.LDX.BIMExportModes.bemExportProperties Or DigiPara.LDX.BIMPropertyStandardModes.bpsmExportEnabled
     BIMSettings = ldxObject.ObjectBIMSettings.BIMSettings
     System.Diagnostics.Debug.Assert(Not IsNothing(BIMSettings))

     Dim customized As Boolean = False

     ' for properties with the bpmEvaluationDisabled flag, you can customize the value 
     For Each BIMPropertyStandard In documentBIMSettings
         For Each BIMProperty In BIMPropertyStandard
             ' When operating on the BIM properties on an individual object, one should not
             ' modify the property itself. Instead, one should fetch the value of
             ' that property on the given object.
             Dim Value = BIMProperty.GetValue(ldxObject)

             ' if ldxObject is not null, Value will also always be non-null, and its BP_ID will fit the property
             ' even if ldxObject was not really equipped to hold BIM property values.
             ' BIM Property Values only exist as long as they are required; they are kept alive
             ' while we're holding a reference via COM to them or while they hold a customized value.
             System.Diagnostics.Debug.Assert(Not IsNothing(Value))
             System.Diagnostics.Debug.Assert(Value.BP_ID = BIMProperty.BP_ID)

             If BIMProperty.BP_TYPE = DigiPara.LDX.BIMPropertyType.bptText Then
                 With Value
                     If Not .EvaluationEnabled Then
                         ' Values/Properties that have evaluation disabled can be given custom values
                         .Value = ldxObject.TreeName
                     ElseIf Not customized Then
                         ' For others, evaluation can be explicitly disabled, and then you can set a value
                         customized = True
                         Dim oldValue = .Value
                         .EvaluationEnabled = False
                         .Value = "OVERRIDE" + ldxObject.TreeName

                         System.Diagnostics.Debug.Assert(.Value <> oldValue)

                         ' to reset the customized status, you need to clear two bits in the value's mode
                         .BPV_MODE = (.BPV_MODE And Not DigiPara.LDX.BIMPropertyValueModes.bpvmEvaluationMask) Or DigiPara.LDX.BIMPropertyValueModes.bpvmEvaluationFromProperty

                         ' the value will then snap back to what it was before customization
                         System.Diagnostics.Debug.Assert(.Value = oldValue)
                     End If
                 End With
             End If
         Next
     Next

     ' it is also possible to add and remove object specific standards and properties using the same methods as with DocumentBIMSettings. In almost
     ' all cases, it is probably advisable to add the properties to the document properties with the appropriate filters instead.

     ' just acvitate the export for shaft and car frame, too
     ldxObject = ldxDocument.Shafts(0).Car.CarFrame.Object
     ldxObject.BIMExportMode = ldxObject.BIMExportMode Or DigiPara.LDX.BIMExportModes.bemExportProperties
     ldxObject = ldxDocument.Shafts(0).Object
     ldxObject.BIMExportMode = ldxObject.BIMExportMode Or DigiPara.LDX.BIMExportModes.bemExportProperties

     ' if you now do a LDBIM export of the project, you will find the properties activated here in the <xtceaEaxCADInsertedFileParameter> nodes.
     ' In IFC Exports, they will appear in an IFCPROPERTYSET, typically as an IFCPROPERTYSINGLEVALUE.
 End Sub