Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

IV 2012 API (VBA) - Assembly Constraint Entity Type IDispatch

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Dickerson2012
1037 Views, 2 Replies

IV 2012 API (VBA) - Assembly Constraint Entity Type IDispatch

I would like to determine the Proxy ObjectType returned from Constraint.EntityOne (i.e. If oConst.EntityOne = kWorkPointProxyObject Then ....)

 

Property EntityOne() As IDispatch**

 

Can someone provide direction or sample on how IDispatch works.

 

Dim oAsmDef As AssemblyComponentDefinition
Set oAsmDef = oAsmDoc.ComponentDefinition

Dim oConst As AssemblyConstraint
For Each oConst In oAsmDef.Constraints 'Below will print the Enum 67120288 (kEdgeProxyObject) or 67119520 (kFaceProxyObject) if
'it is constrained. It will Err if a Work or Sketch Proxy Object is Constrained Debug.Print oConst.EntityOne Debug.Print oConst.EntityTwo Next

 

2 REPLIES 2
Message 2 of 3

Hi,

 

Two ways you could use. Please refer to the code below:

 

 

Sub test()

   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

 

Message 3 of 3

Thank you! This helps greatly. Is one better than or allow more or less option than the other.

 

Best Regards,

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report