<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Constrain, mate or flush? How to choose? in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/constrain-mate-or-flush-how-to-choose/m-p/12396049#M16338</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;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?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;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&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 23 Nov 2023 09:33:52 GMT</pubDate>
    <dc:creator>Hubert_Los</dc:creator>
    <dc:date>2023-11-23T09:33:52Z</dc:date>
    <item>
      <title>Constrain, mate or flush? How to choose?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/constrain-mate-or-flush-how-to-choose/m-p/12396049#M16338</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;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?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;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&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 23 Nov 2023 09:33:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/constrain-mate-or-flush-how-to-choose/m-p/12396049#M16338</guid>
      <dc:creator>Hubert_Los</dc:creator>
      <dc:date>2023-11-23T09:33:52Z</dc:date>
    </item>
    <item>
      <title>Re: Constrain, mate or flush? How to choose?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/constrain-mate-or-flush-how-to-choose/m-p/12443205#M16339</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12591383"&gt;@Hubert_Los&lt;/a&gt;&amp;nbsp;.&amp;nbsp;You can check the direction of the plane normal if they are in the same direction to create the desired constraint.&amp;nbsp;I added the following check on line 26:&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;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
		If oAsmYZPlane.Plane.Normal.IsEqualTo(oCompYZPlane1.Plane.Normal, 0.001) Then
        	Call oADef.Constraints.AddFlushConstraint(oCompYZPlane1, oAsmYZPlane, 0)
		End If
    End If

End Sub&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Dec 2023 10:55:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/constrain-mate-or-flush-how-to-choose/m-p/12443205#M16339</guid>
      <dc:creator>Andrii_Humeniuk</dc:creator>
      <dc:date>2023-12-15T10:55:21Z</dc:date>
    </item>
  </channel>
</rss>

