Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

multiple members of iAssembly and Ipart into main Assembly

terzicZG6MS
Explorer

multiple members of iAssembly and Ipart into main Assembly

terzicZG6MS
Explorer
Explorer

Hello!

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.

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.

Inside iAssembly I made three assembly param (Lenght, Height,Depth) and i used iLogic to change length of profile regarding current iAssemblly row:

Parameter("Profile_length:1", "Length") = Length - (75.7 * 2)
Parameter("Profile_height:1", "Length") = Height -(75.7 *2)
Parameter("Profile_depth:1", "Length") = Depth - (75.7 * 2)

terzicZG6MS_0-1663946118521.png

This is how it should look like.

 

This is the code in C#:

//This Methode assemble main AHU Assembly. It add and position Boxes.

//Inventor Objects
AssemblyDocument oAssyDoc;
AssemblyComponentDefinition oACD;
ComponentOccurrences oCOs;
ComponentOccurrence oCO;

TransientGeometry oTG = m_inventorApplication.TransientGeometry;
Matrix oMatrix = oTG.CreateMatrix();

ASSY_Methodes oASSYAPI = new ASSY_Methodes(m_inventorApplication);
PART_Methodes oPartAPI = new PART_Methodes(m_inventorApplication);

 

//1. Make AHU Assembly
oAHU.FileName = oAHU.Paths.ProjectFolder + "AHU_" + oAHU.AhuID + ".iam";
oASSYAPI.Save_As_Copy(oAHU.Paths.Assembly_Template, oAHU.FileName);

 

//2. Open AHU Assembly and insert Boxes and position Boxes
oAssyDoc = (AssemblyDocument)m_inventorApplication.Documents.Open(oAHU.FileName);
oACD = oAssyDoc.ComponentDefinition;
oCOs = oACD.Occurrences;

//Make and insert Adapter Part
string strFileName = oAHU.Paths.ProjectFolder + "Adapter.ipt";
oPartAPI.Save_As_Copy(oAHU.Paths.Part_Template, strFileName);
oCO = oCOs.Add(strFileName, oMatrix);

AhuBox oBox = null;

for (int i = 0; i < oAHU.Boxes.Count; i++)
{
oBox = oAHU.Boxes[i];

if (oBox.Length > 1)
{
// Open the factory document invisible.
AssemblyDocument oFactoryDoc = (AssemblyDocument)m_inventorApplication.Documents.Open("C:\\Users\\darmin2\\Desktop\\iAsembly\\iAssembly_Box.iam", false);

// Set a reference to the component definition.
AssemblyComponentDefinition oCompDef = oFactoryDoc.ComponentDefinition;

// Make sure we have an iAssy factory.
if (!oCompDef.IsiAssemblyFactory)
{
System.Windows.Forms.MessageBox.Show("Chosen document is not a factory.", "Invalid document");
return;
}

// Set a reference to the factory.
iAssemblyFactory oiAssyFactory = oCompDef.iAssemblyFactory;
iAssemblyTableRows oRows = oiAssyFactory.TableRows;
iAssemblyTableRow oRow;
iAssemblyMember oMember;
oRow = oRows[i];

oRow[3].Value = Convert.ToString(oBox.Length);
oRow[4].Value = Convert.ToString(oBox.Depth);
oRow[5].Value = Convert.ToString(oBox.Height);
oiAssyFactory.CreateMember(oRow);
oCO = oCOs.AddiAssemblyMember("C:\\Users\\darmin2\\Desktop\\iAsembly\\iAssembly_Box.iam", oMatrix, oRow.Index);

 

terzicZG6MS_1-1663946774378.png

This is what I get.

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.

Thanks!

0 Likes
Reply
140 Views
0 Replies
Replies (0)