<?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 multiple members of iAssembly and Ipart into main Assembly in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/multiple-members-of-iassembly-and-ipart-into-main-assembly/m-p/11441579#M143062</link>
    <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I need to insert n boxes (actually frame of boxes with 12 profiles and 8 corners) with different dimensions into main assembly. I created one box as iAssembly with couple of members. IAssembly of box is made by iParts of profiles and corners.&lt;/P&gt;&lt;P&gt;The problem is when I insert for example 3 boxes, I change the value of row member for iAssembly, but every box member inserted in main assembly containe SAME iParts (from last row). IParts should also change their dimensions.&lt;/P&gt;&lt;P&gt;Inside iAssembly I made three assembly param (Lenght, Height,Depth) and i used iLogic to change length of profile regarding current iAssemblly row:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Parameter&lt;/SPAN&gt;("&lt;SPAN&gt;Profile_length:1"&lt;/SPAN&gt;, &lt;SPAN&gt;"Length"&lt;/SPAN&gt;) = &lt;SPAN&gt;Length&lt;/SPAN&gt; - (75.7 * 2)
&lt;SPAN&gt;Parameter&lt;/SPAN&gt;(&lt;SPAN&gt;"Profile_height:1"&lt;/SPAN&gt;, &lt;SPAN&gt;"Length"&lt;/SPAN&gt;) = &lt;SPAN&gt;Height&lt;/SPAN&gt; -(75.7 *2)
&lt;SPAN&gt;Parameter&lt;/SPAN&gt;(&lt;SPAN&gt;"Profile_depth:1"&lt;/SPAN&gt;, &lt;SPAN&gt;"Length"&lt;/SPAN&gt;) = &lt;SPAN&gt;Depth&lt;/SPAN&gt; - (75.7 * 2)&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="terzicZG6MS_0-1663946118521.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1119859i229EA698428221CD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="terzicZG6MS_0-1663946118521.png" alt="terzicZG6MS_0-1663946118521.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This is how it should look like.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code in C#:&lt;/P&gt;&lt;P&gt;//This Methode assemble main AHU Assembly. It add and position Boxes.&lt;/P&gt;&lt;P&gt;//Inventor Objects&lt;BR /&gt;AssemblyDocument oAssyDoc;&lt;BR /&gt;AssemblyComponentDefinition oACD;&lt;BR /&gt;ComponentOccurrences oCOs;&lt;BR /&gt;ComponentOccurrence oCO;&lt;/P&gt;&lt;P&gt;TransientGeometry oTG = m_inventorApplication.TransientGeometry;&lt;BR /&gt;Matrix oMatrix = oTG.CreateMatrix();&lt;/P&gt;&lt;P&gt;ASSY_Methodes oASSYAPI = new ASSY_Methodes(m_inventorApplication);&lt;BR /&gt;PART_Methodes oPartAPI = new PART_Methodes(m_inventorApplication);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//1. Make AHU Assembly&lt;BR /&gt;oAHU.FileName = oAHU.Paths.ProjectFolder + "AHU_" + oAHU.AhuID + ".iam";&lt;BR /&gt;oASSYAPI.Save_As_Copy(oAHU.Paths.Assembly_Template, oAHU.FileName);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//2. Open AHU Assembly and insert Boxes and position Boxes&lt;BR /&gt;oAssyDoc = (AssemblyDocument)m_inventorApplication.Documents.Open(oAHU.FileName);&lt;BR /&gt;oACD = oAssyDoc.ComponentDefinition;&lt;BR /&gt;oCOs = oACD.Occurrences;&lt;/P&gt;&lt;P&gt;//Make and insert Adapter Part&lt;BR /&gt;string strFileName = oAHU.Paths.ProjectFolder + "Adapter.ipt";&lt;BR /&gt;oPartAPI.Save_As_Copy(oAHU.Paths.Part_Template, strFileName);&lt;BR /&gt;oCO = oCOs.Add(strFileName, oMatrix);&lt;/P&gt;&lt;P&gt;AhuBox oBox = null;&lt;/P&gt;&lt;P&gt;for (int i = 0; i &amp;lt; oAHU.Boxes.Count; i++)&lt;BR /&gt;{&lt;BR /&gt;oBox = oAHU.Boxes[i];&lt;/P&gt;&lt;P&gt;if (oBox.Length &amp;gt; 1)&lt;BR /&gt;{&lt;BR /&gt;// Open the factory document invisible.&lt;BR /&gt;AssemblyDocument oFactoryDoc = (AssemblyDocument)m_inventorApplication.Documents.Open("C:\\Users\\darmin2\\Desktop\\iAsembly\\iAssembly_Box.iam", false);&lt;/P&gt;&lt;P&gt;// Set a reference to the component definition.&lt;BR /&gt;AssemblyComponentDefinition oCompDef = oFactoryDoc.ComponentDefinition;&lt;/P&gt;&lt;P&gt;// Make sure we have an iAssy factory.&lt;BR /&gt;if (!oCompDef.IsiAssemblyFactory)&lt;BR /&gt;{&lt;BR /&gt;System.Windows.Forms.MessageBox.Show("Chosen document is not a factory.", "Invalid document");&lt;BR /&gt;return;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Set a reference to the factory.&lt;BR /&gt;iAssemblyFactory oiAssyFactory = oCompDef.iAssemblyFactory;&lt;BR /&gt;iAssemblyTableRows oRows = oiAssyFactory.TableRows;&lt;BR /&gt;iAssemblyTableRow oRow;&lt;BR /&gt;iAssemblyMember oMember;&lt;BR /&gt;oRow = oRows[i];&lt;BR /&gt;&lt;BR /&gt;oRow[3].Value = Convert.ToString(oBox.Length);&lt;BR /&gt;oRow[4].Value = Convert.ToString(oBox.Depth);&lt;BR /&gt;oRow[5].Value = Convert.ToString(oBox.Height);&lt;BR /&gt;oiAssyFactory.CreateMember(oRow);&lt;BR /&gt;oCO = oCOs.AddiAssemblyMember("C:\\Users\\darmin2\\Desktop\\iAsembly\\iAssembly_Box.iam", oMatrix, oRow.Index);&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="terzicZG6MS_1-1663946774378.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1119866i6E420A212AC3C871/image-size/medium?v=v2&amp;amp;px=400" role="button" title="terzicZG6MS_1-1663946774378.png" alt="terzicZG6MS_1-1663946774378.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This is what I get.&lt;/P&gt;&lt;P&gt;Probably it is because of link between the part names inside different boxes. I have profile_length, profile_depth and profile_height in each boxes and it should probably be related to boxes member name and different in each iAssembly.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Fri, 23 Sep 2022 15:29:20 GMT</pubDate>
    <dc:creator>terzicZG6MS</dc:creator>
    <dc:date>2022-09-23T15:29:20Z</dc:date>
    <item>
      <title>multiple members of iAssembly and Ipart into main Assembly</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/multiple-members-of-iassembly-and-ipart-into-main-assembly/m-p/11441579#M143062</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I need to insert n boxes (actually frame of boxes with 12 profiles and 8 corners) with different dimensions into main assembly. I created one box as iAssembly with couple of members. IAssembly of box is made by iParts of profiles and corners.&lt;/P&gt;&lt;P&gt;The problem is when I insert for example 3 boxes, I change the value of row member for iAssembly, but every box member inserted in main assembly containe SAME iParts (from last row). IParts should also change their dimensions.&lt;/P&gt;&lt;P&gt;Inside iAssembly I made three assembly param (Lenght, Height,Depth) and i used iLogic to change length of profile regarding current iAssemblly row:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Parameter&lt;/SPAN&gt;("&lt;SPAN&gt;Profile_length:1"&lt;/SPAN&gt;, &lt;SPAN&gt;"Length"&lt;/SPAN&gt;) = &lt;SPAN&gt;Length&lt;/SPAN&gt; - (75.7 * 2)
&lt;SPAN&gt;Parameter&lt;/SPAN&gt;(&lt;SPAN&gt;"Profile_height:1"&lt;/SPAN&gt;, &lt;SPAN&gt;"Length"&lt;/SPAN&gt;) = &lt;SPAN&gt;Height&lt;/SPAN&gt; -(75.7 *2)
&lt;SPAN&gt;Parameter&lt;/SPAN&gt;(&lt;SPAN&gt;"Profile_depth:1"&lt;/SPAN&gt;, &lt;SPAN&gt;"Length"&lt;/SPAN&gt;) = &lt;SPAN&gt;Depth&lt;/SPAN&gt; - (75.7 * 2)&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="terzicZG6MS_0-1663946118521.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1119859i229EA698428221CD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="terzicZG6MS_0-1663946118521.png" alt="terzicZG6MS_0-1663946118521.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This is how it should look like.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code in C#:&lt;/P&gt;&lt;P&gt;//This Methode assemble main AHU Assembly. It add and position Boxes.&lt;/P&gt;&lt;P&gt;//Inventor Objects&lt;BR /&gt;AssemblyDocument oAssyDoc;&lt;BR /&gt;AssemblyComponentDefinition oACD;&lt;BR /&gt;ComponentOccurrences oCOs;&lt;BR /&gt;ComponentOccurrence oCO;&lt;/P&gt;&lt;P&gt;TransientGeometry oTG = m_inventorApplication.TransientGeometry;&lt;BR /&gt;Matrix oMatrix = oTG.CreateMatrix();&lt;/P&gt;&lt;P&gt;ASSY_Methodes oASSYAPI = new ASSY_Methodes(m_inventorApplication);&lt;BR /&gt;PART_Methodes oPartAPI = new PART_Methodes(m_inventorApplication);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//1. Make AHU Assembly&lt;BR /&gt;oAHU.FileName = oAHU.Paths.ProjectFolder + "AHU_" + oAHU.AhuID + ".iam";&lt;BR /&gt;oASSYAPI.Save_As_Copy(oAHU.Paths.Assembly_Template, oAHU.FileName);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//2. Open AHU Assembly and insert Boxes and position Boxes&lt;BR /&gt;oAssyDoc = (AssemblyDocument)m_inventorApplication.Documents.Open(oAHU.FileName);&lt;BR /&gt;oACD = oAssyDoc.ComponentDefinition;&lt;BR /&gt;oCOs = oACD.Occurrences;&lt;/P&gt;&lt;P&gt;//Make and insert Adapter Part&lt;BR /&gt;string strFileName = oAHU.Paths.ProjectFolder + "Adapter.ipt";&lt;BR /&gt;oPartAPI.Save_As_Copy(oAHU.Paths.Part_Template, strFileName);&lt;BR /&gt;oCO = oCOs.Add(strFileName, oMatrix);&lt;/P&gt;&lt;P&gt;AhuBox oBox = null;&lt;/P&gt;&lt;P&gt;for (int i = 0; i &amp;lt; oAHU.Boxes.Count; i++)&lt;BR /&gt;{&lt;BR /&gt;oBox = oAHU.Boxes[i];&lt;/P&gt;&lt;P&gt;if (oBox.Length &amp;gt; 1)&lt;BR /&gt;{&lt;BR /&gt;// Open the factory document invisible.&lt;BR /&gt;AssemblyDocument oFactoryDoc = (AssemblyDocument)m_inventorApplication.Documents.Open("C:\\Users\\darmin2\\Desktop\\iAsembly\\iAssembly_Box.iam", false);&lt;/P&gt;&lt;P&gt;// Set a reference to the component definition.&lt;BR /&gt;AssemblyComponentDefinition oCompDef = oFactoryDoc.ComponentDefinition;&lt;/P&gt;&lt;P&gt;// Make sure we have an iAssy factory.&lt;BR /&gt;if (!oCompDef.IsiAssemblyFactory)&lt;BR /&gt;{&lt;BR /&gt;System.Windows.Forms.MessageBox.Show("Chosen document is not a factory.", "Invalid document");&lt;BR /&gt;return;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Set a reference to the factory.&lt;BR /&gt;iAssemblyFactory oiAssyFactory = oCompDef.iAssemblyFactory;&lt;BR /&gt;iAssemblyTableRows oRows = oiAssyFactory.TableRows;&lt;BR /&gt;iAssemblyTableRow oRow;&lt;BR /&gt;iAssemblyMember oMember;&lt;BR /&gt;oRow = oRows[i];&lt;BR /&gt;&lt;BR /&gt;oRow[3].Value = Convert.ToString(oBox.Length);&lt;BR /&gt;oRow[4].Value = Convert.ToString(oBox.Depth);&lt;BR /&gt;oRow[5].Value = Convert.ToString(oBox.Height);&lt;BR /&gt;oiAssyFactory.CreateMember(oRow);&lt;BR /&gt;oCO = oCOs.AddiAssemblyMember("C:\\Users\\darmin2\\Desktop\\iAsembly\\iAssembly_Box.iam", oMatrix, oRow.Index);&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="terzicZG6MS_1-1663946774378.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1119866i6E420A212AC3C871/image-size/medium?v=v2&amp;amp;px=400" role="button" title="terzicZG6MS_1-1663946774378.png" alt="terzicZG6MS_1-1663946774378.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This is what I get.&lt;/P&gt;&lt;P&gt;Probably it is because of link between the part names inside different boxes. I have profile_length, profile_depth and profile_height in each boxes and it should probably be related to boxes member name and different in each iAssembly.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2022 15:29:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/multiple-members-of-iassembly-and-ipart-into-main-assembly/m-p/11441579#M143062</guid>
      <dc:creator>terzicZG6MS</dc:creator>
      <dc:date>2022-09-23T15:29:20Z</dc:date>
    </item>
  </channel>
</rss>

