public void AddForAttributes(Inventor.AssemblyDocument m_AssemblyDocument, Inventor.SelectSet selectSet, string GroupName, int cnt) { // int cnt = m_AssemblyDocument.SelectSet.Count; // Inventor.SelectSet selectSet = m_AssemblyDocument.SelectSet; // m_AssemblyDocument.SelectSet.GetEnumerator().Current.GetType(); for (int i = cnt; i >= 1; i--) { // object itm = selectSet[i]; try { object objUnKnown = selectSet[i]; System.Type invokeType = objUnKnown.GetType(); object tmp = invokeType.InvokeMember("Type", BindingFlags.GetProperty, null, objUnKnown, null); Inventor.ObjectTypeEnum objTypeEum = (Inventor.ObjectTypeEnum)tmp; if (objTypeEum == Inventor.ObjectTypeEnum.kComponentOccurrenceObject) { Inventor.ComponentOccurrence componentOccurrence = (Inventor.ComponentOccurrence)objUnKnown; Inventor.AttributeSets m_AttributeSets = componentOccurrence.AttributeSets; if (!(m_AttributeSets is null)) { // Add the attributes to the ComponentOccurrence Name = "GroupObject"; if (!m_AttributeSets.NameIsUsed[GroupName]) { Inventor.AttributeSet m_AttributeSet = m_AttributeSets.Add(GroupName); Inventor.Attribute m_Attribute = m_AttributeSet.Add(GroupName + "A", Inventor.ValueTypeEnum.kStringType, "G"); Inventor.Asset asset = m_AssemblyDocument.Assets["Red"]; //this to sort out componentOccurrence.Appearance = asset; } } } } catch (Exception) { MessageBox.Show("Exception"); } } }
public void AddFor(ref Inventor.AssemblyDocument m_AssemblyDocument, string GroupName, int cnt, Inventor.SelectSet selectSet) { AddForAttributes(ref m_AssemblyDocument, selectSet, GroupName, cnt); }
private static void AddForAttributes(ref Inventor.AssemblyDocument m_AssemblyDocument, Inventor.SelectSet selectSet, string GroupName, int cnt) { // int cnt = m_AssemblyDocument.SelectSet.Count; // Inventor.SelectSet selectSet = m_AssemblyDocument.SelectSet; // m_AssemblyDocument.SelectSet.GetEnumerator().Current.GetType(); for (int i = 1; i <= cnt; i++) { // object itm = selectSet[i]; object objUnKnown = selectSet[i]; System.Type invokeType = objUnKnown.GetType(); object tmp = invokeType.InvokeMember("Type", BindingFlags.GetProperty, null, objUnKnown, null); Inventor.ObjectTypeEnum objTypeEum = (Inventor.ObjectTypeEnum)tmp; if (objTypeEum == Inventor.ObjectTypeEnum.kComponentOccurrenceObject) { Inventor.ComponentOccurrence componentOccurrence = (Inventor.ComponentOccurrence)objUnKnown; Inventor.AttributeSets m_AttributeSets = componentOccurrence.AttributeSets; // System.Diagnostics.Debug.Print(componentOccurrence.Name); // System.Diagnostics.Debug.Print("Counter: " + i.ToString()); if (!(m_AttributeSets is null)) { // Add the attributes to the ComponentOccurrence Name = "GroupObject"; if (!m_AttributeSets.NameIsUsed[GroupName]) { Inventor.AttributeSet m_AttributeSet = m_AttributeSets.Add(GroupName); Inventor.Attribute m_Attribute = m_AttributeSet.Add(GroupName + "A", Inventor.ValueTypeEnum.kStringType, "G"); Inventor.Asset asset = m_AssemblyDocument.Assets["Red"]; //this to sort out componentOccurrence.Appearance = asset; } } } } }