i want to create mate for 3 face of part in assembly to quickly do my work
i have below code but it is not working
Dim asmDoc As AssemblyDocument
asmDoc = ThisApplication.ActiveDocument
Dim part1 As ComponentOccurrence
part1 = asmDoc.ComponentDefinition.Occurrences.Item(1)
Dim part2 As ComponentOccurrence
part2 = asmDoc.ComponentDefinition.Occurrences.Item(2)
Dim selectedPlane1 As WorkPlane
selectedPlane1 = ThisApplication.CommandManager.Pick(kWorkPlaneFilter, "Select the first plane")
Dim selectedPlane2 As WorkPlane
selectedPlane2 = ThisApplication.CommandManager.Pick(kWorkPlaneFilter, "Select the second plane")
Dim selectedPlane3 As WorkPlane
selectedPlane3 = ThisApplication.CommandManager.Pick(kWorkPlaneFilter, "Select the third plane")
Dim constraintGroup As GeometricConstraintGroup
constraintGroup = asmDoc.ComponentDefinition.Constraints.AddMateConstraint(part1, part2, kFlushMate, selectedPlane1, selectedPlane2, selectedPlane3)
Solved! Go to Solution.
i want to create mate for 3 face of part in assembly to quickly do my work
i have below code but it is not working
Dim asmDoc As AssemblyDocument
asmDoc = ThisApplication.ActiveDocument
Dim part1 As ComponentOccurrence
part1 = asmDoc.ComponentDefinition.Occurrences.Item(1)
Dim part2 As ComponentOccurrence
part2 = asmDoc.ComponentDefinition.Occurrences.Item(2)
Dim selectedPlane1 As WorkPlane
selectedPlane1 = ThisApplication.CommandManager.Pick(kWorkPlaneFilter, "Select the first plane")
Dim selectedPlane2 As WorkPlane
selectedPlane2 = ThisApplication.CommandManager.Pick(kWorkPlaneFilter, "Select the second plane")
Dim selectedPlane3 As WorkPlane
selectedPlane3 = ThisApplication.CommandManager.Pick(kWorkPlaneFilter, "Select the third plane")
Dim constraintGroup As GeometricConstraintGroup
constraintGroup = asmDoc.ComponentDefinition.Constraints.AddMateConstraint(part1, part2, kFlushMate, selectedPlane1, selectedPlane2, selectedPlane3)
Solved! Go to Solution.
Solved by A.Acheson. Go to Solution.
I noticed a few mistakes you have,
Here is a method that allows multiple constraints.
Dim asmDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim face1 As Face
Dim face2 As Face
Dim mate1 As MateConstraint
While True
face1 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select the first face")
' Exit loop if nothing selected
If face1 Is Nothing Then Exit While
face2 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select the second face")
' Create the insert constraint between the parts.
mate1 = asmDoc.ComponentDefinition.Constraints.AddMateConstraint(face1, face2, 0)
End While
I noticed a few mistakes you have,
Here is a method that allows multiple constraints.
Dim asmDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim face1 As Face
Dim face2 As Face
Dim mate1 As MateConstraint
While True
face1 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select the first face")
' Exit loop if nothing selected
If face1 Is Nothing Then Exit While
face2 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select the second face")
' Create the insert constraint between the parts.
mate1 = asmDoc.ComponentDefinition.Constraints.AddMateConstraint(face1, face2, 0)
End While
Hi @A.Acheson
it's almost exact. I edited the code to suit me
Dim asmDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim face1 As Face
Dim face2 As Face
Dim mate1 As MateConstraint
face1 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select the first face")
' Exit loop if nothing selected
face2 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select the second face")
' Create the insert constraint between the parts.
mate1 = asmDoc.ComponentDefinition.Constraints.AddMateConstraint(face1, face2, 0)
face3 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select the 3 face")
' Exit loop if nothing selected
face4 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select the 4 face")
' Create the insert constraint between the parts.
mate2 = asmDoc.ComponentDefinition.Constraints.AddMateConstraint(face3, face4, 0)
face5 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select the 5 face")
' Exit loop if nothing selected
face6 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select the 6 face")
' Create the insert constraint between the parts.
mate3 = asmDoc.ComponentDefinition.Constraints.AddPlushConstraint(face5, face6, 0)
I need to edit this line to look like image
Can you helpe me!!
mate3 = asmDoc.ComponentDefinition.Constraints.AddPlushConstraint(face5, face6, 0)
Hi @A.Acheson
it's almost exact. I edited the code to suit me
Dim asmDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim face1 As Face
Dim face2 As Face
Dim mate1 As MateConstraint
face1 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select the first face")
' Exit loop if nothing selected
face2 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select the second face")
' Create the insert constraint between the parts.
mate1 = asmDoc.ComponentDefinition.Constraints.AddMateConstraint(face1, face2, 0)
face3 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select the 3 face")
' Exit loop if nothing selected
face4 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select the 4 face")
' Create the insert constraint between the parts.
mate2 = asmDoc.ComponentDefinition.Constraints.AddMateConstraint(face3, face4, 0)
face5 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select the 5 face")
' Exit loop if nothing selected
face6 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select the 6 face")
' Create the insert constraint between the parts.
mate3 = asmDoc.ComponentDefinition.Constraints.AddPlushConstraint(face5, face6, 0)
I need to edit this line to look like image
Can you helpe me!!
mate3 = asmDoc.ComponentDefinition.Constraints.AddPlushConstraint(face5, face6, 0)
You have a spelling mistake here
mate3 = asmDoc.ComponentDefinition.Constraints.AddPlushConstraint(face5, face6, 0)
see API Help here
AssemblyConstraints.AddFlushConstraint( EntityOne As Object, EntityTwo As Object, Offset As Variant, [BiasPointOne] As Variant, [BiasPointTwo] As Variant ) As FlushConstrain
You have a spelling mistake here
mate3 = asmDoc.ComponentDefinition.Constraints.AddPlushConstraint(face5, face6, 0)
see API Help here
AssemblyConstraints.AddFlushConstraint( EntityOne As Object, EntityTwo As Object, Offset As Variant, [BiasPointOne] As Variant, [BiasPointTwo] As Variant ) As FlushConstrain
hi @A.Acheson
how do you fix it
mate3 = asmDoc.ComponentDefinition.Constraints.AddPlushConstraint(face5, face6, 0)
it's worst
hi @A.Acheson
how do you fix it
mate3 = asmDoc.ComponentDefinition.Constraints.AddPlushConstraint(face5, face6, 0)
it's worst
If you replace the letter "P" with "F" this should fix that method. The error message states you have the wrong method.
Fixed:
mate3 = asmDoc.ComponentDefinition.Constraints.AddFlushConstraint(face5, face6, 0)
If you replace the letter "P" with "F" this should fix that method. The error message states you have the wrong method.
Fixed:
mate3 = asmDoc.ComponentDefinition.Constraints.AddFlushConstraint(face5, face6, 0)
thank you !!!😅
Can't find what you're looking for? Ask the community or share your knowledge.