Inventor General Discussion

Inventor General Discussion

Reply
Active Member
jacofiero
Posts: 9
Registered: ‎03-28-2013
Message 1 of 3 (96 Views)

API - How do you use the ConvertTo... methods of the AssemblyConstraint Object?

96 Views, 2 Replies
06-21-2013 07:13 AM

I'm trying to flip a part by converting its constraint object type from Mate to Flush.  Seems simple enough but I can't figure out the requirements of the ConvertToMateConstraint method.  

 

Could anyone explain its use or point me towards an example?

*Expert Elite*
mrattray
Posts: 2,501
Registered: ‎09-13-2011
Message 2 of 3 (89 Views)

Re: API - How do you use the ConvertTo... methods of the AssemblyConstraint Obje

06-21-2013 07:33 AM in reply to: jacofiero
Are you familiar with the object browser? It looks like the requirements of the ConvertToFlushConstraint are thus:
ConvertToFlushConstraint(EntityOne As Object, EntityTwo As Object, Offset, [BiasPointOne], [BiasPointTwo])
It looks like you can get all the information you need from the AssemblyConstraint class,which you'll need anyways to execute ConvertToFlushConstraint against.
I hope that helps, if not can you be more specific about the problem you're having?
Mike (not Matt) Rattray

Active Member
jacofiero
Posts: 9
Registered: ‎03-28-2013
Message 3 of 3 (81 Views)

Re: API - How do you use the ConvertTo... methods of the AssemblyConstraint Obje

06-21-2013 08:25 AM in reply to: mrattray

Yes, sorry for not providing a code example to begin with.  

Here's the non-working code in VBA...

 

Public Sub FlipCon()
Dim oDoc As AssemblyDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oAsmCompDef As AssemblyComponentDefinition
Set oAsmCompDef = oDoc.ComponentDefinition
Dim oAsmCons As AssemblyConstraints
Set oAsmCons = oAsmCompDef.Constraints
Dim oCon As AssemblyConstraint
Dim oFace1 As Face
Dim oFace2 As Face

For Each oCon In oAsmCons
  Set oFace1 = oCon.EntityOne
  Set oFace2 = oCon.EntityTwo
  If oCon.Type = kMateConstraintObject Then
    oCon.ConvertToFlushConstraint(oFace1, oFace2, 0)
  ElseIf oCon.Type = kFlushConstraintObject Then
    oCon.ConvertToMateConstraint(oFace1, oFace2, 0)
  End If
Next

 

End Sub

 


I skipped the bias points as they're listed as option.  I'm assuming I'm not using the correct object type for EntityOne/EntityTwo, but if they're not the same type as was already used in the constraint then what else would they be?

 

I tried simply oCon.ConvertToMateConstraint(oCon.EntityOne, oCon.EntityTwo, 0) , but failed similarly.

 

Does Offset require a numerical Parameter object or something...?

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.