Ejemplo n.º 1
0
 private static void AddAttributeSets(Inventor.ComponentOccurrence componentOccurrence, String AttriSetsName, String AttriName, String AttriValue)
 {
     Inventor.AttributeSets m_AttributeSets = componentOccurrence.AttributeSets;
     if (!m_AttributeSets.NameIsUsed[AttriSetsName])
     {
         Inventor.AttributeSet m_AttributeSet = m_AttributeSets.Add(AttriSetsName);
         Inventor.Attribute    m_Attribute    = m_AttributeSet.Add(AttriName, Inventor.ValueTypeEnum.kStringType, AttriValue);
     }
 }
Ejemplo n.º 2
0
        //switch (GetInventorObjType(JustSelected[i]))
        //{
        //    case Inventor.ObjectTypeEnum.kComponentOccurrenceObject:

        //        //Inventor.ComponentOccurrence ComponentOccurrence = (Inventor.ComponentOccurrence)objUnKnown;
        //        //ColourIt(AssemblyDocument, ComponentOccurrence);
        //        //System.Diagnostics.Debug.WriteLine(ComponentOccurrence.Name);
        //        return objTypeEum;
        //        break;
        //    case Inventor.ObjectTypeEnum.kRectangularOccurrencePatternObject:

        //        //Inventor.RectangularOccurrencePattern RectangularOccurrencePattern = (Inventor.RectangularOccurrencePattern)objUnKnown;

        //        //foreach (var Ritem in RectangularOccurrencePattern.OccurrencePatternElements)
        //        //{
        //        //    Inventor.OccurrencePatternElement occurrencePatternElement = (Inventor.OccurrencePatternElement)Ritem;
        //        //    foreach (var Occitem in occurrencePatternElement.Occurrences)
        //        //    {

        //        //        Inventor.ComponentOccurrence componentOccurrence = (Inventor.ComponentOccurrence)Occitem;
        //        //        ColourIt(AssemblyDocument, componentOccurrence);

        //        //    }
        //        //}
        //        break;


        //    default:
        //        break;
        //}
        //foreach (object item in JustSelectedEntities)
        //{
        //    ObjType(item);
        //    System.Diagnostics.Debug.WriteLine("Just Selected");
        //}

        //if (MoreSelectedEntities != null)
        //{
        //    foreach (object item in MoreSelectedEntities)
        //    {
        //        ObjType(item);
        //        System.Diagnostics.Debug.WriteLine("More Selected");
        //    }
        //}
        //Inventor.AssemblyDocument AssemblyDocument,
        //string Colour = "Red";
        //ColourOccurance(AssemblyDocument, componentOccurrence, Colour);
        //,Inventor.AssemblyDocument AssemblyDocument
        private static void AddAttributeSets(ref Inventor.ComponentOccurrence componentOccurrence, string AttributeSets_Name, string Attribute_Name, string Attribute_Value)
        {
            if (AttributeSets_Name != null || Attribute_Name != null)
            {
                Inventor.AttributeSets m_AttributeSets = componentOccurrence.AttributeSets;
                if (!m_AttributeSets.NameIsUsed[AttributeSets_Name])
                {
                    Inventor.AttributeSet m_AttributeSet = m_AttributeSets.Add(AttributeSets_Name);
                    Inventor.Attribute    m_Attribute    = m_AttributeSet.Add(Attribute_Name, Inventor.ValueTypeEnum.kStringType, Attribute_Value);
                }
            }
        }
Ejemplo n.º 3
0
        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");
                }
            }
        }
Ejemplo n.º 4
0
        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;
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private static void AddEachAttributes(ref Inventor.AssemblyDocument m_AssemblyDocument, bool SelectAllArrays, String GroupName, String GroupNumber)
        {
            if (m_AssemblyDocument.SelectSet.Count == 0)
            {
                MessageBox.Show("Need to select a Part or Sub Assembly");
                return;
            }
            Inventor.Assets colour = m_AssemblyDocument.Assets;

            try
            {
                foreach (var item in m_AssemblyDocument.SelectSet)
                {
                    object                  objUnKnown = item;
                    System.Type             invokeType = objUnKnown.GetType();
                    object                  tmp        = invokeType.InvokeMember("Type", BindingFlags.GetProperty, null, objUnKnown, null);
                    Inventor.ObjectTypeEnum objTypeEum = (Inventor.ObjectTypeEnum)tmp;
                    System.Diagnostics.Debug.WriteLine(objTypeEum.ToString());

                    if (objTypeEum == Inventor.ObjectTypeEnum.kComponentOccurrenceObject)
                    {
                        Inventor.ComponentOccurrence componentOccurrence = (Inventor.ComponentOccurrence)item;//(Inventor.ComponentOccurrence)objUnKnown;
                        Inventor.AttributeSets       m_AttributeSets     = componentOccurrence.AttributeSets;
                        System.Diagnostics.Debug.Print(componentOccurrence.Name);
                        // 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;
                        }
                    }
                    else if (objTypeEum == Inventor.ObjectTypeEnum.kRectangularOccurrencePatternObject && SelectAllArrays)
                    {
                        Inventor.RectangularOccurrencePattern RectangularOccurrencePattern = (Inventor.RectangularOccurrencePattern)item;

                        foreach (var Ritem in RectangularOccurrencePattern.OccurrencePatternElements)
                        {
                            Inventor.OccurrencePatternElement occurrencePatternElement = (Inventor.OccurrencePatternElement)Ritem;
                            foreach (var Occitem in occurrencePatternElement.Occurrences)
                            {
                                Inventor.ComponentOccurrence componentOccurrence = (Inventor.ComponentOccurrence)Occitem;
                                Inventor.AttributeSets       m_AttributeSets     = componentOccurrence.AttributeSets;
                                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 ex)
            {
                MessageBox.Show("Is the selected item a Component?");
                MessageBox.Show(ex.ToString());
                return;
            }
        }