Inventor General

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

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

75 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,217
Registered: ‎09-13-2011
Message 2 of 3 (68 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
Posts: 9
Registered: ‎03-28-2013
Message 3 of 3 (60 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...?

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube