Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I would like to constrain the part to the origin plane at this actual position. I check the angle between the planes and if it is 0, I create a constraint. And at this point I have a problem, because I don't know what type of constraint I should choose. Sometimes the part rotates 180 degrees. Do you know how I can choose the constraints correctly?
Sub Constrain()
Dim oADoc As AssemblyDocument
Set oADoc = ThisApplication.ActiveDocument
Dim oADef As AssemblyComponentDefinition
Set oADef = oADoc.ComponentDefinition
Dim oAsmYZPlane As WorkPlane
Set oAsmYZPlane = oADef.WorkPlanes.Item(1)
Dim oCompYZPlane1 As Object
Dim oCompYZPlane2 As Object
If oADoc.SelectSet.Count = 1 Then
Set oOcc1 = ThisApplication.ActiveDocument.SelectSet.Item(1)
Else
Set oOcc1 = ThisApplication.CommandManager.Pick(kAssemblyLeafOccurrenceFilter, "1")
End If
Dim oCompPtDef1 As PartComponentDefinition
Set oCompPtDef1 = oOcc1.Definition
Call oOcc1.CreateGeometryProxy(oCompPtDef1.WorkPlanes.Item(1), oCompYZPlane1)
Angle = ThisApplication.MeasureTools.GetAngle(oCompYZPlane1, oAsmYZPlane)
If Angle = 0 Then
Call oADef.Constraints.AddFlushConstraint(oCompYZPlane1, oAsmYZPlane, 0)
End If
End Sub
Solved! Go to Solution.