예제 #1
0
        private void Initialize()
        {
            IFeature swFeature = ((IModelDoc2)swAssembly).FirstFeature();

            while (swFeature != null)
            {
                /*Console.WriteLine("+++++ " + swFeature.Name + " - " + swFeature.GetID() + " - " + swFeature.IsSuppressed2(
                 *  (int)swInConfigurationOpts_e.swThisConfiguration, null)[0]
                 + "\n \t ++ Created: " + swFeature.DateCreated + "\n \t ++ Modified: " + swFeature.DateModified
                 + "\n \t ++ CreatedBy: " + swFeature.CreatedBy);
                 */
                if (!swFeature.IsSuppressed2((int)swInConfigurationOpts_e.swThisConfiguration, null)[0])
                {
                    var swEntity          = (IEntity)swFeature;
                    var swEntityType      = (swSelectType_e)swEntity.GetType();
                    var featureTypeName   = swFeature.GetTypeName2();
                    var featureDefinition = swFeature.GetDefinition();
                    var specificFeature   = swFeature.GetSpecificFeature2();

                    if (swSelectType_e.swSelBODYFEATURES == swEntityType)
                    {
                        bodyFeatures.Add(new BodyFeature(swFeature)); // swFeature.GetDefinition()
                                                                      // Console.WriteLine("++++ " + swFeature.GetTypeName2() + " - " + swFeature.Name + " - " + (swFeature.GetDefinition() is IExtrudeFeatureData2));
                    }

                    if (swSelectType_e.swSelMATEGROUPS == swEntityType)
                    {
                        //Get first mate, which is a subfeature
                        IFeature swMateFeature = (Feature)swFeature.GetFirstSubFeature();
                        while (null != swMateFeature)
                        {
                            // Console.WriteLine(swMateFeature.IsSuppressed2(1, null)[0]);
                            mates.Add(new Mate(swMateFeature));
                            swMateFeature = swMateFeature.GetNextSubFeature();
                        }
                    }

                    if (swSelectType_e.swSelCOMPONENTS == swEntityType)
                    {
                        var swModelDoc = ((IComponent2)swFeature.GetSpecificFeature2()).GetModelDoc2();
                        // Console.WriteLine(((IComponent2)swFeature.GetSpecificFeature2()).IsSuppressed());

                        if (swModelDoc is IAssemblyDoc)
                        {
                            SwApp.ActivateDocument(swModelDoc);
                            subAssemblies.Add(new Assembly((IAssemblyDoc)swModelDoc, swFeature));
                        }

                        if (swModelDoc is IPartDoc)
                        {
                            parts.Add(new Part((IPartDoc)swModelDoc, swFeature));
                        }
                    }
                }
                swFeature = swFeature.GetNextFeature();
            }
        }