|
DigiPara Liftdesigner LDX API
|
API method: ILDXObject5.GetChildren
' from Samples/Src/LDXAPIExamples/Example_LDXDocument.vb
<APIHelpAttribute(APIHelpModes.FireCalcModel Or APIHelpModes.LoadLD3File, {APIHelpModes.InputParaLDXApp}, "", "LDXObject~GetChildren", "Get child LDX objects (fastest)")>
Public Shared Sub GetChildLDXObjectsFast(ByRef ldxApplication As DigiPara.LDX.LDXApplication)
If ldxApplication.ActiveDocument Is Nothing Then
MsgBox("Active document not found!")
Exit Sub
End If
Dim objects As String = ""
Dim ldxDocumentObject As DigiPara.LDX.LDXObject = ldxApplication.ActiveDocument.Object
' the absolutely fastest way to iterate over subobjects is this function, with the ogcmNullForEmpty parameter.
' it will not do any allocation in case the object has no children (that is a big win if you do a recursive iteration;
' most objects in the tree are leaf objects just holding a string or number), the price is an additional null check
' on your end you have to do.
' check the documentation for ObjectGetChildrenModes for other options.
Dim children = ldxDocumentObject.GetChildren(DigiPara.LDX.ObjectGetChildrenModes.ogcmNullForEmpty)
If children IsNot Nothing Then
For Each ldxObject In ldxDocumentObject.GetChildren()
If ldxObject.ObjectName.Substring(0, 3).ToUpper = "LDX" Then
objects += Environment.NewLine + String.Format("{0} ({1} - {2})", ldxObject.ObjectName, ldxObject.ObjectId, ldxObject.ObjectId.GetHashCode)
End If
Next
End If
MsgBox("Frist level child LDX objects of the active document are: Name (Id name - Id value)" + objects)
End Sub