Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

2 REPLIES 2
Reply
Message 1 of 3
jacofiero
288 Views, 2 Replies

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

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?

Tags (2)
2 REPLIES 2
Message 2 of 3
mrattray
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

Message 3 of 3
jacofiero
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...?

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

Post to forums  

Autodesk Design & Make Report