check object type in Inventor

By Xiaodong Liang

Issue
Some properties or methods return an object. But I did not know how to check its type. e.g. I would like to determine the Proxy ObjectType returned from Constraint.EntityOne (i.e. If oConst.EntityOne = kWorkPointProxyObject

Solution

Two ways you could use. Please refer to the code below. One uses TypeOf. Another get the Object.ObjectType which is a value of the enu ObjectTypeEnumm.

Sub tesObjectTypeEnumt()
Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveDocument
Dim oAsmCompDef As AssemblyComponentDefinition
Set oAsmCompDef = oAsmDoc.ComponentDefinition
Dim oConstraints As AssemblyConstraints
Set oConstraints = oAsmCompDef.Constraints
Dim oCons As AssemblyConstraint
Set oCons = oConstraints(1)
Dim oEntityOne As Object
Set oEntityOne = oCons.EntityOne
'way1
If TypeOf oEntityOne Is EdgeProxy Then
End If
'way2
Dim objType As ObjectTypeEnum
objType = oEntityOne.Type
If objType = kEdgeProxyObject Then
End If
End Sub

Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading