<?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 Re: Create origin flush constraints in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-origin-flush-constraints/m-p/12207877#M19625</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13518190"&gt;@Andrii_Humeniuk&lt;/a&gt;&amp;nbsp;- Perfect! Thank you!&lt;/P&gt;</description>
    <pubDate>Wed, 30 Aug 2023 20:01:31 GMT</pubDate>
    <dc:creator>MikeOG</dc:creator>
    <dc:date>2023-08-30T20:01:31Z</dc:date>
    <item>
      <title>Create origin flush constraints</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-origin-flush-constraints/m-p/12205166#M19617</link>
      <description>&lt;P&gt;Hi, can someone please help me with some ilogic. I want a rule that that will create origin flush constraint for any / all parts that I run it on at assembly level. It must have an option to turn Ground at origin on or off in the code. There is a toolbar for this under the productivity tab (Assemble Ribbon), but I would like to map it to a rule / keyboard shortcut.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MikeOG_0-1693338495521.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1259651i09AA92F87B1B168E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MikeOG_0-1693338495521.png" alt="MikeOG_0-1693338495521.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found some code that does only the grounded bit, still need it to "Create origin flush constraints".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Sub&lt;/SPAN&gt; &lt;SPAN&gt;Main&lt;/SPAN&gt;
    &lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oDoc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;AssemblyDocument&lt;/SPAN&gt;
    &lt;SPAN&gt;oDoc&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;ActiveDocument&lt;/SPAN&gt;

    &lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oOcc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;ComponentOccurrence&lt;/SPAN&gt;
    &lt;SPAN&gt;oOcc&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;CommandManager&lt;/SPAN&gt;.&lt;SPAN&gt;Pick&lt;/SPAN&gt;(&lt;SPAN&gt;kAssemblyOccurrenceFilter&lt;/SPAN&gt;, &lt;SPAN&gt;"SelectPart"&lt;/SPAN&gt;)
	
	&lt;SPAN&gt;oOcc&lt;/SPAN&gt;.&lt;SPAN&gt;Grounded&lt;/SPAN&gt; = &lt;SPAN&gt;False&lt;/SPAN&gt;
	&lt;SPAN&gt;For&lt;/SPAN&gt; &lt;SPAN&gt;Each&lt;/SPAN&gt; &lt;SPAN&gt;oConstraint&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;AssemblyConstraint&lt;/SPAN&gt; &lt;SPAN&gt;In&lt;/SPAN&gt; &lt;SPAN&gt;oOcc&lt;/SPAN&gt;.&lt;SPAN&gt;Constraints&lt;/SPAN&gt;
		&lt;SPAN&gt;oConstraint&lt;/SPAN&gt;.&lt;SPAN&gt;Delete&lt;/SPAN&gt;
	&lt;SPAN&gt;Next&lt;/SPAN&gt;
	&lt;SPAN&gt;oOcc&lt;/SPAN&gt;.&lt;SPAN&gt;Transformation&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;TransientGeometry&lt;/SPAN&gt;.&lt;SPAN&gt;CreateMatrix&lt;/SPAN&gt;
	&lt;SPAN&gt;oOcc&lt;/SPAN&gt;.&lt;SPAN&gt;Grounded&lt;/SPAN&gt; = &lt;SPAN&gt;True&lt;/SPAN&gt;
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2023 19:51:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/create-origin-flush-constraints/m-p/12205166#M19617</guid>
      <dc:creator>MikeOG</dc:creator>
      <dc:date>2023-08-29T19:51:50Z</dc:date>
    </item>
    <item>
      <title>Re: Create origin flush constraints</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-origin-flush-constraints/m-p/12205202#M19618</link>
      <description>&lt;P&gt;I did constraint to 3 planes, in VB.NET addin:&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;    Public Sub Button1_Execute()
      Dim oDoc As Document
      Dim oSelectSet As SelectSet
      Dim AssmYZPlane As WorkPlane
      Dim AssmXZPlane As WorkPlane
      Dim AssmXYPlane As WorkPlane
      'Dim CompYZPlane As WorkPlane
      'Dim CompXZPlane As WorkPlane
      'Dim CompXYPlane As WorkPlane
      Dim ProxyYZPlane As WorkPlaneProxy
      Dim ProxyXZPlane As WorkPlaneProxy
      Dim ProxyXYPlane As WorkPlaneProxy
      Dim oFlush As FlushConstraint
      Dim oComponent As ComponentOccurrence
      Dim oAsmCompDef As AssemblyComponentDefinition
      Dim oTxnMgr As TransactionManager
      Dim oTxn As Transaction

      Try
        oDoc = AddinGlobal.IVApp.ActiveDocument
        If oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
          oSelectSet = AddinGlobal.IVApp.ActiveDocument.SelectSet
          If oSelectSet.Count &amp;gt; 0 Then
            oAsmCompDef = AddinGlobal.IVApp.ActiveDocument.ComponentDefinition
            AssmYZPlane = oDoc.ComponentDefinition.WorkPlanes.Item("YZ Plane")
            AssmXZPlane = oDoc.ComponentDefinition.WorkPlanes.Item("XZ Plane")
            AssmXYPlane = oDoc.ComponentDefinition.WorkPlanes.Item("XY Plane")

            oTxnMgr = AddinGlobal.IVApp.TransactionManager
            oTxn = oTxnMgr.StartTransaction(oDoc, "Mate to Origin")

            For Each oComponent In oSelectSet
              '      Set CompYZPlane = oComponent.Definition.WorkPlanes.Item("YZ Plane")
              Call oComponent.CreateGeometryProxy(oComponent.Definition.WorkPlanes.Item("YZ Plane"), ProxyYZPlane)

              '      Set CompXZPlane = oComponent.Definition.WorkPlanes.Item("XZ Plane")
              Call oComponent.CreateGeometryProxy(oComponent.Definition.WorkPlanes.Item("XZ Plane"), ProxyXZPlane)

              '      Set CompXYPlane = oComponent.Definition.WorkPlanes.Item("XY Plane")
              Call oComponent.CreateGeometryProxy(oComponent.Definition.WorkPlanes.Item("XY Plane"), ProxyXYPlane)

              oFlush = oAsmCompDef.Constraints.AddFlushConstraint(ProxyYZPlane, AssmYZPlane, 0)
              oFlush = oAsmCompDef.Constraints.AddFlushConstraint(ProxyXZPlane, AssmXZPlane, 0)
              oFlush = oAsmCompDef.Constraints.AddFlushConstraint(ProxyXYPlane, AssmXYPlane, 0)
            Next
            oTxn.End()
          Else
            MsgBox("Select parts to mate.")
          End If
        End If


      Catch ex As Exception
        Windows.Forms.MessageBox.Show(ex.ToString())
      End Try
    End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Should be able to get "Center Point" from WorkPoints:&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-155178B3-E035-411C-BEB9-E0FA9D1D4462" target="_blank"&gt;https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-155178B3-E035-411C-BEB9-E0FA9D1D4462&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2023 20:09:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/create-origin-flush-constraints/m-p/12205202#M19618</guid>
      <dc:creator>Frederick_Law</dc:creator>
      <dc:date>2023-08-29T20:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: Create origin flush constraints</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-origin-flush-constraints/m-p/12205217#M19619</link>
      <description>&lt;P&gt;If possible, can someone write an ilogic code for this please?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2023 20:17:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/create-origin-flush-constraints/m-p/12205217#M19619</guid>
      <dc:creator>MikeOG</dc:creator>
      <dc:date>2023-08-29T20:17:03Z</dc:date>
    </item>
    <item>
      <title>Re: Create origin flush constraints</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-origin-flush-constraints/m-p/12205225#M19620</link>
      <description>&lt;P&gt;iLogic is based on VB.&lt;/P&gt;&lt;P&gt;You'll need to fix 20%.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2023 20:20:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/create-origin-flush-constraints/m-p/12205225#M19620</guid>
      <dc:creator>Frederick_Law</dc:creator>
      <dc:date>2023-08-29T20:20:27Z</dc:date>
    </item>
    <item>
      <title>Re: Create origin flush constraints</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-origin-flush-constraints/m-p/12205245#M19621</link>
      <description>&lt;P&gt;My coding skills are unfortunately very limited hence me asking for someone to write an ilogic rule that I can just plug straight in.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2023 20:30:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/create-origin-flush-constraints/m-p/12205245#M19621</guid>
      <dc:creator>MikeOG</dc:creator>
      <dc:date>2023-08-29T20:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: Create origin flush constraints</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-origin-flush-constraints/m-p/12205302#M19622</link>
      <description>&lt;P&gt;While you're waiting for someone to do it for you, you could try and see how far you can get and learn something.&lt;/P&gt;&lt;P&gt;Unless you're too busy for that too&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2023 21:01:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/create-origin-flush-constraints/m-p/12205302#M19622</guid>
      <dc:creator>Frederick_Law</dc:creator>
      <dc:date>2023-08-29T21:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: Create origin flush constraints</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-origin-flush-constraints/m-p/12205313#M19623</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5289378"&gt;@Frederick_Law&lt;/a&gt;&amp;nbsp;I usually give it a go first, try and piece some snippets together and trial and error till I get it to work, just too busy atm, and if someone has already written something that could work it would save me some time.. Thank you for the VB code though, I do appreciate it. &lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2023 21:06:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/create-origin-flush-constraints/m-p/12205313#M19623</guid>
      <dc:creator>MikeOG</dc:creator>
      <dc:date>2023-08-29T21:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: Create origin flush constraints</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-origin-flush-constraints/m-p/12205866#M19624</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12626711"&gt;@MikeOG&lt;/a&gt;&amp;nbsp;.&amp;nbsp;This is the macro I use in my work. Before running the macro, you need to select the components on which you want to set Flush constraints.&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Private Sub Main()
	Dim oInvApp As Inventor.Application = ThisApplication
	Dim oDoc As Document = oInvApp.ActiveDocument
	Dim oTM As TransactionManager = oInvApp.TransactionManager
	If TypeOf oDoc Is AssemblyDocument Then
		Dim oAssDoc As AssemblyDocument = oDoc
		Dim oSelSet As SelectSet = oAssDoc.SelectSet
		If oSelSet.Count &amp;lt; 1 Then
			MessageBox.Show("It is necessary to select at least one component!", "Error!", _
							MessageBoxButtons.OK, MessageBoxIcon.Error)
			Exit Sub
		End If
		Dim sListOccs As New List(Of ComponentOccurrence)
		For i As Integer = 1 To oSelSet.Count
			If TypeOf oSelSet.Item(i) Is ComponentOccurrence Then
				sListOccs.Add(oSelSet.Item(i))
			End If
		Next i
		Dim newTM As Transaction = oTM.StartTransaction(oAssDoc, "Constraints_XYZ")
		For iOcc As Integer = 0 To sListOccs.Count - 1
			Call CreatFlushConstraints(oAssDoc.ComponentDefinition, sListOccs(iOcc))
		Next
		newTM.End
	Else
		MessageBox.Show("This rule is intended for work with assemblies!", "Error!", _
						MessageBoxButtons.OK, MessageBoxIcon.Error)
	End If 
End Sub

Private Function CreatFlushConstraints(ByVal oAssDef As AssemblyComponentDefinition,
										ByVal oOcc As ComponentOccurrence)
	Dim oAsmPlane As WorkPlane
	Dim oPartPlane As WorkPlane
	Dim oPartPlaneProxy As WorkPlaneProxy
	For i As Integer = 1 To 3
		oAsmPlane = oAssDef.WorkPlanes(i)
		oPartPlane = oOcc.Definition.WorkPlanes(i)
		Call oOcc.CreateGeometryProxy(oPartPlane, oPartPlaneProxy)
		Call oAssDef.Constraints.AddFlushConstraint(oPartPlaneProxy, oAsmPlane, 0)
	Next i
End Function&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2023 05:10:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/create-origin-flush-constraints/m-p/12205866#M19624</guid>
      <dc:creator>Andrii_Humeniuk</dc:creator>
      <dc:date>2023-08-30T05:10:01Z</dc:date>
    </item>
    <item>
      <title>Re: Create origin flush constraints</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-origin-flush-constraints/m-p/12207877#M19625</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13518190"&gt;@Andrii_Humeniuk&lt;/a&gt;&amp;nbsp;- Perfect! Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2023 20:01:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/create-origin-flush-constraints/m-p/12207877#M19625</guid>
      <dc:creator>MikeOG</dc:creator>
      <dc:date>2023-08-30T20:01:31Z</dc:date>
    </item>
  </channel>
</rss>

