How do you convert a constraint from mate to flush with ilogic

How do you convert a constraint from mate to flush with ilogic

Curtis_Waguespack
Consultant Consultant
1,852 Views
2 Replies
Message 1 of 3

How do you convert a constraint from mate to flush with ilogic

Curtis_Waguespack
Consultant
Consultant

 

 I had trouble finding an example, so I thought I'd post one here for future reference:

 

' a reference to the assembly component definintion.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

sName = "Constraint1" 

Dim oConstraint As AssemblyConstraint
oConstraint = oAsmCompDef.Constraints.Item(sName)

oInput = InputRadioBox("Select one", "Mate", "Flush", True, "ilogic")

If oInput = False
'convert to Flush
oConstraint = oConstraint.ConvertToFlushConstraint( oConstraint.EntityOne, oConstraint.EntityTwo, 0)
Else
'Convert to Mate
oConstraint = oConstraint.ConvertToMateConstraint( oConstraint.EntityOne, oConstraint.EntityTwo, 0)
End If

oConstraint.Name = sName

 

Accepted solutions (1)
1,853 Views
2 Replies
Replies (2)
Message 2 of 3

Curtis_Waguespack
Consultant
Consultant
Accepted solution
Message 3 of 3

Koekepeerke
Advocate
Advocate

Hey @Curtis_Waguespack,

 

First of all thanks for your code i was looking vor a way to switch between flush and mate without supressing multiple constraints. I have one problem though i can't seem to put a string in the contraints.item property also the collection contraints doesnt contain a itembyname property. i have seen this before with the workplanes collection for example but there i am able to just insert a string in the item property. Do you maybe have any idea how to fix this?

I'm using inventor 2023.

Dim oDoc As AssemblyDocument = ThisDoc.Document
Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
Dim constraintName As String = "flushmate"
Dim oContraint As AssemblyConstraint = oDef.Constraints.Item(constraintName)

JeKl_0-1675162697461.png

 

Thanks in advance for your response!

0 Likes