示例#1
0
        static void AddItemsToSelectSet(SolidEdgeFramework.SolidEdgeDocument document)
        {
            SolidEdgeAssembly.AssemblyDocument assemblyDocument = null;
            SolidEdgeAssembly.AsmRefPlanes     asmRefPlanes     = null;
            SolidEdgeDraft.DraftDocument       draftDocument    = null;
            SolidEdgeDraft.Sheet             sheet              = null;
            SolidEdgeDraft.DrawingViews      drawingViews       = null;
            SolidEdgePart.PartDocument       partDocument       = null;
            SolidEdgePart.SheetMetalDocument sheetMetalDocument = null;
            SolidEdgePart.EdgebarFeatures    edgeBarFeatures    = null;

            switch (document.Type)
            {
            case SolidEdgeFramework.DocumentTypeConstants.igAssemblyDocument:
                assemblyDocument = (SolidEdgeAssembly.AssemblyDocument)document;
                asmRefPlanes     = assemblyDocument.AsmRefPlanes;

                for (int i = 1; i <= asmRefPlanes.Count; i++)
                {
                    assemblyDocument.SelectSet.Add(asmRefPlanes.Item(i));
                }
                break;

            case SolidEdgeFramework.DocumentTypeConstants.igDraftDocument:
                draftDocument = (SolidEdgeDraft.DraftDocument)document;
                sheet         = draftDocument.ActiveSheet;
                drawingViews  = sheet.DrawingViews;

                for (int i = 1; i <= drawingViews.Count; i++)
                {
                    draftDocument.SelectSet.Add(drawingViews.Item(i));
                }

                break;

            case SolidEdgeFramework.DocumentTypeConstants.igPartDocument:
                partDocument    = (SolidEdgePart.PartDocument)document;
                edgeBarFeatures = partDocument.DesignEdgebarFeatures;

                for (int i = 1; i <= edgeBarFeatures.Count; i++)
                {
                    partDocument.SelectSet.Add(edgeBarFeatures.Item(i));
                }

                break;

            case SolidEdgeFramework.DocumentTypeConstants.igSheetMetalDocument:
                sheetMetalDocument = (SolidEdgePart.SheetMetalDocument)document;
                edgeBarFeatures    = sheetMetalDocument.DesignEdgebarFeatures;

                for (int i = 1; i <= edgeBarFeatures.Count; i++)
                {
                    partDocument.SelectSet.Add(edgeBarFeatures.Item(i));
                }
                break;
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application   application        = null;
            SolidEdgePart.SheetMetalDocument sheetMetalDocument = null;
            SolidEdgePart.EdgebarFeatures    edgebarFeatures    = null;

            try
            {
                // Register with OLE to handle concurrency issues on the current thread.
                SolidEdgeCommunity.OleMessageFilter.Register();

                // Connect to or start Solid Edge.
                application = SolidEdgeCommunity.SolidEdgeUtils.Connect(true, true);

                // Bring Solid Edge to the foreground.
                application.Activate();

                // Get a reference to the active sheetmetal document.
                sheetMetalDocument = application.GetActiveDocument <SolidEdgePart.SheetMetalDocument>(false);

                if (sheetMetalDocument != null)
                {
                    // Get a reference to the DesignEdgebarFeatures collection.
                    edgebarFeatures = sheetMetalDocument.DesignEdgebarFeatures;

                    // Interate through the features.
                    for (int i = 1; i <= edgebarFeatures.Count; i++)
                    {
                        // Get the EdgebarFeature at current index.
                        var edgebarFeature = edgebarFeatures.Item(i);

                        // Get the managed type.
                        var type = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetType(edgebarFeature);

                        Console.WriteLine("Item({0}) is of type '{1}'", i, type);
                    }
                }
                else
                {
                    throw new System.Exception("No active document.");
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
示例#3
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application   application        = null;
            SolidEdgeFramework.Documents     documents          = null;
            SolidEdgePart.SheetMetalDocument sheetMetalDocument = null;
            SolidEdgePart.FamilyMembers      familyMembers      = null;
            SolidEdgePart.FamilyMember       familyMember       = null;
            SolidEdgePart.EdgebarFeatures    edgebarFeatures    = null;

            try
            {
                // Register with OLE to handle concurrency issues on the current thread.
                SolidEdgeCommunity.OleMessageFilter.Register();

                // Connect to or start Solid Edge.
                application = SolidEdgeCommunity.SolidEdgeUtils.Connect(true, true);

                // Get a reference to the documents collection.
                documents = application.Documents;

                // Add a new sheetmetal document.
                sheetMetalDocument = documents.AddSheetMetalDocument();

                // Invoke existing sample to create geometry.
                SheetMetalHelper.CreateHolesWithUserDefinedPattern(sheetMetalDocument);

                // Get a reference to the FamilyMembers collection.
                familyMembers = sheetMetalDocument.FamilyMembers;

                // Add a new FamilyMember.
                familyMember = familyMembers.Add("Member 1");

                // Get a reference to the DesignEdgebarFeatures collection.
                edgebarFeatures = sheetMetalDocument.DesignEdgebarFeatures;

                // Iterate through the DesignEdgebarFeatures.
                for (int i = 1; i <= edgebarFeatures.Count; i++)
                {
                    // Get the EdgebarFeature at the current index.
                    object edgebarFeature = edgebarFeatures.Item(i);

                    // Use helper class to get the feature type.
                    var featureType = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetPropertyValue <SolidEdgePart.FeatureTypeConstants>(edgebarFeature, "Type", (SolidEdgePart.FeatureTypeConstants) 0);

                    // Looking for a Hole pattern to suppress.
                    if (featureType == SolidEdgePart.FeatureTypeConstants.igUserDefinedPatternFeatureObject)
                    {
                        // Suppress the feature.
                        familyMember.AddSuppressedFeature(edgebarFeature);
                    }
                }

                // Apply the FamilyMember.
                familyMember.Apply();
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
示例#4
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application       application      = null;
            SolidEdgeFramework.SolidEdgeDocument document         = null;
            SolidEdgeFramework.SelectSet         selectSet        = null;
            SolidEdgeAssembly.AssemblyDocument   assemblyDocument = null;
            SolidEdgeAssembly.AsmRefPlanes       asmRefPlanes     = null;
            SolidEdgeDraft.DraftDocument         draftDocument    = null;
            SolidEdgeDraft.Sheet             sheet              = null;
            SolidEdgeDraft.DrawingViews      drawingViews       = null;
            SolidEdgePart.PartDocument       partDocument       = null;
            SolidEdgePart.SheetMetalDocument sheetMetalDocument = null;
            SolidEdgePart.EdgebarFeatures    edgeBarFeatures    = null;

            try
            {
                // Register with OLE to handle concurrency issues on the current thread.
                SolidEdgeCommunity.OleMessageFilter.Register();

                // Connect to or start Solid Edge.
                application = SolidEdgeCommunity.SolidEdgeUtils.Connect();

                // Get a reference to the active selectset.
                selectSet = application.ActiveSelectSet;

                // Temporarily suspend selectset UI updates.
                selectSet.SuspendDisplay();

                // Clear the selectset.
                selectSet.RemoveAll();

                // Get a reference to the active document.
                document = application.GetActiveDocument <SolidEdgeFramework.SolidEdgeDocument>(false);

                if (document != null)
                {
                    // Determine document type.
                    switch (document.Type)
                    {
                    case SolidEdgeFramework.DocumentTypeConstants.igAssemblyDocument:
                        assemblyDocument = (SolidEdgeAssembly.AssemblyDocument)document;
                        asmRefPlanes     = assemblyDocument.AsmRefPlanes;

                        for (int i = 1; i <= asmRefPlanes.Count; i++)
                        {
                            selectSet.Add(asmRefPlanes.Item(i));
                        }

                        break;

                    case SolidEdgeFramework.DocumentTypeConstants.igDraftDocument:
                        draftDocument = (SolidEdgeDraft.DraftDocument)document;
                        sheet         = draftDocument.ActiveSheet;
                        drawingViews  = sheet.DrawingViews;

                        for (int i = 1; i <= drawingViews.Count; i++)
                        {
                            draftDocument.SelectSet.Add(drawingViews.Item(i));
                        }

                        break;

                    case SolidEdgeFramework.DocumentTypeConstants.igPartDocument:
                        partDocument    = (SolidEdgePart.PartDocument)document;
                        edgeBarFeatures = partDocument.DesignEdgebarFeatures;

                        for (int i = 1; i <= edgeBarFeatures.Count; i++)
                        {
                            partDocument.SelectSet.Add(edgeBarFeatures.Item(i));
                        }

                        break;

                    case SolidEdgeFramework.DocumentTypeConstants.igSheetMetalDocument:
                        sheetMetalDocument = (SolidEdgePart.SheetMetalDocument)document;
                        edgeBarFeatures    = sheetMetalDocument.DesignEdgebarFeatures;

                        for (int i = 1; i <= edgeBarFeatures.Count; i++)
                        {
                            partDocument.SelectSet.Add(edgeBarFeatures.Item(i));
                        }
                        break;
                    }
                }
                else
                {
                    throw new System.Exception("No active document");
                }

                // Re-enable selectset UI display.
                selectSet.ResumeDisplay();

                // Manually refresh the selectset UI display.
                selectSet.RefreshDisplay();
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }