static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgePart.SheetMetalDocument sheetMetalDocument = null; SolidEdgePart.Model model = null; SolidEdgePart.Tabs tabs = null; SolidEdgePart.Tab tab = null; SolidEdgeFramework.SelectSet selectSet = 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 Documents collection. documents = application.Documents; // Create a new SheetMetal document. sheetMetalDocument = documents.AddSheetMetalDocument(); // Always a good idea to give SE a chance to breathe. application.DoIdle(); // Call helper method to create the actual geometry. model = SheetMetalHelper.CreateBaseTab(sheetMetalDocument); // Get a reference to the Tabs collection. tabs = model.Tabs; // Get a reference to the new Tab. tab = tabs.Item(1); // Get a reference to the ActiveSelectSet. selectSet = application.ActiveSelectSet; // Empty ActiveSelectSet. selectSet.RemoveAll(); // Add new Tab to ActiveSelectSet. selectSet.Add(tab); // Switch to ISO view. application.StartCommand(SolidEdgeConstants.SheetMetalCommandConstants.SheetMetalViewISOView); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgePart.PartDocument partDocument = null; try { Console.WriteLine("Registering OleMessageFilter."); // Register with OLE to handle concurrency issues on the current thread. OleMessageFilter.Register(); Console.WriteLine("Connecting to Solid Edge."); // Connect to or start Solid Edge. application = SolidEdgeUtils.Connect(true); // Make sure user can see the GUI. application.Visible = true; // Bring Solid Edge to the foreground. application.Activate(); // Get a reference to the documents collection. documents = application.Documents; Console.WriteLine("Creating a new part document."); // Create a new part document. partDocument = (SolidEdgePart.PartDocument) documents.Add("SolidEdge.PartDocument"); // Always a good idea to give SE a chance to breathe. application.DoIdle(); Console.WriteLine("Creating geometry."); // Create geometry. CreateFiniteExtrudedProtrusion(partDocument); Console.WriteLine("Creating holes with user defined patterns."); // Create holes. CreateHolesWithUserDefinedPattern(partDocument); Console.WriteLine("Switching to ISO view."); // Switch to ISO view. application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)SolidEdgeConstants.PartCommandConstants.PartViewISOView); } catch (System.Exception ex) { #if DEBUG System.Diagnostics.Debugger.Break(); #endif Console.WriteLine(ex.Message); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgeDraft.DraftDocument draftDocument = null; SolidEdgeDraft.Sections sections = null; try { Console.WriteLine("Registering OleMessageFilter."); // Register with OLE to handle concurrency issues on the current thread. OleMessageFilter.Register(); Console.WriteLine("Connecting to Solid Edge."); // Connect to or start Solid Edge. application = SolidEdgeUtils.Connect(true); // Make sure user can see the GUI. application.Visible = true; // Bring Solid Edge to the foreground. application.Activate(); // Get a reference to the documents collection. documents = application.Documents; // Note: these two will throw exceptions if no document is open. //application.ActiveDocument //application.ActiveDocumentType; if ((documents.Count > 0) && (application.ActiveDocumentType == SolidEdgeFramework.DocumentTypeConstants.igDraftDocument)) { // Get a reference to the documents collection. draftDocument = (SolidEdgeDraft.DraftDocument)application.ActiveDocument; } else { throw new System.Exception("Draft file not open."); } sections = draftDocument.Sections; // Update all views in the working section. UpdateAllViewsInWorkingSection(sections.WorkingSection); // Update all views in all sheets. //UpdateAllViewsInAllSheets(draftDocument.Sheets); } catch (System.Exception ex) { #if DEBUG System.Diagnostics.Debugger.Break(); #endif Console.WriteLine(ex.Message); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgeFramework.SolidEdgeDocument document = null; SolidEdgeFramework.PropertySets propertySets = null; try { Console.WriteLine("Registering OleMessageFilter."); // Register with OLE to handle concurrency issues on the current thread. OleMessageFilter.Register(); Console.WriteLine("Connecting to Solid Edge."); // Connect to or start Solid Edge. application = SolidEdgeUtils.Connect(true); // Make sure user can see the GUI. application.Visible = true; // Bring Solid Edge to the foreground. application.Activate(); // Get a reference to the Documents collection. documents = application.Documents; // Note: these two will throw exceptions if no document is open. //application.ActiveDocument //application.ActiveDocumentType; if (documents.Count > 0) { // Get a reference to the documents collection. document = (SolidEdgeFramework.SolidEdgeDocument)application.ActiveDocument; } else { throw new System.Exception("No document open."); } propertySets = (SolidEdgeFramework.PropertySets)document.Properties; ProcessPropertySets(propertySets); AddCustomProperties(propertySets); } catch (System.Exception ex) { #if DEBUG System.Diagnostics.Debugger.Break(); #endif Console.WriteLine(ex.Message); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgeFramework.SolidEdgeDocument document = null; SolidEdgeFramework.Variables variables = null; try { Console.WriteLine("Registering OleMessageFilter."); // Register with OLE to handle concurrency issues on the current thread. OleMessageFilter.Register(); Console.WriteLine("Connecting to Solid Edge."); // Connect to or start Solid Edge. application = SolidEdgeUtils.Connect(true); // Make sure user can see the GUI. application.Visible = true; // Bring Solid Edge to the foreground. application.Activate(); // Get a reference to the Documents collection. documents = application.Documents; // This check is necessary because application.ActiveDocument will throw an // exception if no documents are open... if (documents.Count > 0) { // Attempt to connect to ActiveDocument. document = (SolidEdgeFramework.SolidEdgeDocument)application.ActiveDocument; } // Make sure we have a document. if (document == null) { throw new System.Exception("No active document."); } variables = (SolidEdgeFramework.Variables)document.Variables; ProcessVariables(variables); } catch (System.Exception ex) { #if DEBUG System.Diagnostics.Debugger.Break(); #endif Console.WriteLine(ex.Message); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgePart.PartDocument partDocument = null; SolidEdgePart.Models models = null; SolidEdgePart.Model model = null; SolidEdgeGeometry.Body body = 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 part document. partDocument = application.GetActiveDocument <SolidEdgePart.PartDocument>(false); if (partDocument != null) { models = partDocument.Models; if (models.Count == 0) { throw new System.Exception("No geometry defined."); } model = models.Item(1); body = (SolidEdgeGeometry.Body)model.Body; Array MinRangePoint = Array.CreateInstance(typeof(double), 0); Array MaxRangePoint = Array.CreateInstance(typeof(double), 0); body.GetRange(ref MinRangePoint, ref MaxRangePoint); } else { throw new System.Exception("No active document."); } } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgeAssembly.AssemblyDocument assemblyDocument = null; try { Console.WriteLine("Registering OleMessageFilter."); // Register with OLE to handle concurrency issues on the current thread. OleMessageFilter.Register(); Console.WriteLine("Connecting to Solid Edge."); // Connect to or start Solid Edge. application = SolidEdgeUtils.Connect(true); // Make sure user can see the GUI. application.Visible = true; // Bring Solid Edge to the foreground. application.Activate(); // Get a reference to the documents collection. documents = application.Documents; Console.WriteLine("Creating a new assembly document."); // Create a new assembly document. assemblyDocument = (SolidEdgeAssembly.AssemblyDocument) documents.Add("SolidEdge.AssemblyDocument"); // Always a good idea to give SE a chance to breathe. application.DoIdle(); AddStructuralFrame(assemblyDocument); Console.WriteLine("Switching to ISO view."); // Switch to ISO view. application.StartCommand( (SolidEdgeFramework.SolidEdgeCommandConstants) SolidEdgeConstants.AssemblyCommandConstants.AssemblyViewISOView); } catch (System.Exception ex) { #if DEBUG System.Diagnostics.Debugger.Break(); #endif Console.WriteLine(ex.Message); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgeAssembly.AssemblyDocument assemblyDocument = null; SolidEdgeAssembly.Relations3d relations3d = null; try { Console.WriteLine("Registering OleMessageFilter."); // Register with OLE to handle concurrency issues on the current thread. OleMessageFilter.Register(); Console.WriteLine("Connecting to Solid Edge."); // Connect to or start Solid Edge. application = SolidEdgeUtils.Connect(true); // Make sure user can see the GUI. application.Visible = true; // Bring Solid Edge to the foreground. application.Activate(); // Get a reference to the documents collection. documents = application.Documents; Console.WriteLine("Opening Coffee Pot.asm."); string fileName = Path.Combine(SolidEdgeUtils.GetTrainingPath(), "Coffee Pot.asm"); // Create a new assembly document. assemblyDocument = (SolidEdgeAssembly.AssemblyDocument) documents.Open(fileName); // Always a good idea to give SE a chance to breathe. application.DoIdle(); // Get a reference to the Relations3d collection. relations3d = assemblyDocument.Relations3d; ReportRelations3d(relations3d); } catch (System.Exception ex) { #if DEBUG System.Diagnostics.Debugger.Break(); #endif Console.WriteLine(ex.Message); } }
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(); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgeFramework.SolidEdgeDocument document = null; string[] progIds = { "SolidEdge.AssemblyDocument", "SolidEdge.DraftDocument", "SolidEdge.PartDocument", "SolidEdge.SheetMetalDocument" }; try { Console.WriteLine("Registering OleMessageFilter."); // Register with OLE to handle concurrency issues on the current thread. OleMessageFilter.Register(); Console.WriteLine("Connecting to Solid Edge."); // Connect to or start Solid Edge. application = SolidEdgeUtils.Connect(true); // Ensure Solid Edge GUI is visible. application.Visible = true; // Bring Solid Edge to the foreground. application.Activate(); // Get a reference to the documents collection. documents = application.Documents; // Create a new document for each ProgId. foreach (string progId in progIds) { Console.WriteLine("Creating a new '{0}'. No template specified.", progId); // Create the new document. document = (SolidEdgeFramework.SolidEdgeDocument)documents.Add(progId); } } catch (System.Exception ex) { #if DEBUG System.Diagnostics.Debugger.Break(); #endif Console.WriteLine(ex.Message); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgePart.SheetMetalDocument sheetMetalDocument = 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) { switch (sheetMetalDocument.ModelingMode) { case SolidEdgePart.ModelingModeConstants.seModelingModeOrdered: sheetMetalDocument.ModelingMode = SolidEdgePart.ModelingModeConstants.seModelingModeSynchronous; Console.WriteLine("Modeling mode changed to synchronous."); break; case SolidEdgePart.ModelingModeConstants.seModelingModeSynchronous: sheetMetalDocument.ModelingMode = SolidEdgePart.ModelingModeConstants.seModelingModeOrdered; Console.WriteLine("Modeling mode changed to ordered (traditional)."); break; } } else { throw new System.Exception("No active document."); } } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgeFramework.SolidEdgeDocument document = null; try { Console.WriteLine("Registering OleMessageFilter."); // Register with OLE to handle concurrency issues on the current thread. OleMessageFilter.Register(); Console.WriteLine("Connecting to Solid Edge."); // Connect to or start Solid Edge. application = SolidEdgeUtils.Connect(true); // Ensure Solid Edge GUI is visible. application.Visible = true; // Bring Solid Edge to the foreground. application.Activate(); // Get a reference to the documents collection. documents = application.Documents; Console.WriteLine("Creating a new part document. No template specified."); document = (SolidEdgeFramework.SolidEdgeDocument)documents.Add("SolidEdge.PartDocument"); //string template = "your template.par"; //Console.WriteLine("Creating a new part document. Template '{0}' specified.", template); //document = (SolidEdgeFramework.SolidEdgeDocument)documents.Add("SolidEdge.PartDocument", template); //Console.WriteLine("Quitting Solid Edge."); // Quit Solid Edge. //application.Quit(); } catch (System.Exception ex) { #if DEBUG System.Diagnostics.Debugger.Break(); #endif Console.WriteLine(ex.Message); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgePart.SheetMetalDocument sheetMetalDocument = null; SolidEdgePart.Models models = null; SolidEdgePart.Model model = 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 document. sheetMetalDocument = application.GetActiveDocument <SolidEdgePart.SheetMetalDocument>(false); if (sheetMetalDocument != null) { models = sheetMetalDocument.Models; for (int i = 1; i <= models.Count; i++) { model = models.Item(i); model.HealAndOptimizeBody(true, true); } } else { throw new System.Exception("No active document."); } } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgeDraft.DraftDocument draftDocument = null; try { Console.WriteLine("Registering OleMessageFilter."); // Register with OLE to handle concurrency issues on the current thread. OleMessageFilter.Register(); Console.WriteLine("Connecting to Solid Edge."); // Connect to or start Solid Edge. application = SolidEdgeUtils.Connect(true); // Make sure user can see the GUI. application.Visible = true; // Bring Solid Edge to the foreground. application.Activate(); // Get a reference to the documents collection. documents = application.Documents; // Create a new draft document. draftDocument = (SolidEdgeDraft.DraftDocument)documents.Add("SolidEdge.DraftDocument"); // Demonstrate dimensioning a part drawving view. AddPartViewAndDimension(draftDocument); // Demonstrate dimensioning a 2D line. AddLineAndDimension(draftDocument); } catch (System.Exception ex) { #if DEBUG System.Diagnostics.Debugger.Break(); #endif Console.WriteLine(ex.Message); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgePart.PartDocument partDocument = null; SolidEdgePart.Models models = 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 part document. partDocument = application.GetActiveDocument <SolidEdgePart.PartDocument>(false); if (partDocument != null) { models = partDocument.Models; foreach (var model in models.OfType <SolidEdgePart.Model>()) { model.Recompute(); } } else { throw new System.Exception("No active document."); } } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgePart.PartDocument partDocument = null; SolidEdgePart.Models models = null; SolidEdgePart.Model model = null; SolidEdgeGeometry.Body body = 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 part document. partDocument = application.GetActiveDocument <SolidEdgePart.PartDocument>(false); if (partDocument != null) { models = partDocument.Models; if (models.Count == 0) { throw new System.Exception("No geometry defined."); } model = models.Item(1); body = (SolidEdgeGeometry.Body)model.Body; int facetCount = 0; Array points = Array.CreateInstance(typeof(double), 0); object normals = Array.CreateInstance(typeof(double), 0); object textureCoords = Array.CreateInstance(typeof(double), 0); object styleIds = Array.CreateInstance(typeof(int), 0); object faceIds = Array.CreateInstance(typeof(int), 0); //Returns the number of facets and the number of points on the facets for the referenced object. // If Tolerance <= 0, then data is returned from the geometry cache, and not from Parasolid. body.GetFacetData( Tolerance: 0.1, FacetCount: out facetCount, Points: ref points, Normals: out normals, TextureCoords: out textureCoords, StyleIDs: out styleIds, FaceIDs: out faceIds, bHonourPrefs: false); // We really need an explpanation from development on how to process the out variables. } else { throw new System.Exception("No active document."); } } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgePart.PartDocument partDocument = null; SolidEdgePart.Models models = null; SolidEdgeGeometry.Body body = null; SolidEdgeGeometry.Shells shells = null; SolidEdgeGeometry.Shell shell = null; SolidEdgePart.Constructions constructions = null; SolidEdgePart.ConstructionModel constructionModel = null; int bodyCount = 0; 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 part document. partDocument = application.GetActiveDocument <SolidEdgePart.PartDocument>(false); if (partDocument != null) { models = partDocument.Models; // Check for solid design bodies. foreach (var model in models.OfType <SolidEdgePart.Model>()) { body = (SolidEdgeGeometry.Body)model.Body; if (body.IsSolid) { shells = (SolidEdgeGeometry.Shells)body.Shells; for (int i = 1; i <= shells.Count; i++) { shell = (SolidEdgeGeometry.Shell)shells.Item(i); if (shell != null) { if ((shell.IsClosed) && (shell.IsVoid == false)) { bodyCount++; } } } } } // Check for solid construction bodies. constructions = partDocument.Constructions; for (int i = 1; i <= constructions.Count; i++) { constructionModel = constructions.Item(i) as SolidEdgePart.ConstructionModel; if (constructionModel != null) { body = (SolidEdgeGeometry.Body)constructionModel.Body; if (body.IsSolid) { bodyCount++; } } } Console.WriteLine("Active part document contains ({0}) solid bodies.", bodyCount); } else { throw new System.Exception("No active document."); } } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgePart.PartDocument partDocument = null; try { Console.WriteLine("Registering OleMessageFilter."); // Register with OLE to handle concurrency issues on the current thread. OleMessageFilter.Register(); Console.WriteLine("Connecting to Solid Edge."); // Connect to or start Solid Edge. application = SolidEdgeUtils.Connect(true); // Make sure user can see the GUI. application.Visible = true; // Bring Solid Edge to the foreground. application.Activate(); // Get a reference to the documents collection. documents = application.Documents; Console.WriteLine("Creating a new part document."); // Create a new part document. partDocument = (SolidEdgePart.PartDocument) documents.Add("SolidEdge.PartDocument"); // Always a good idea to give SE a chance to breathe. application.DoIdle(); Console.WriteLine("Drawing part."); // Create geometry. CreateFiniteExtrudedProtrusion(partDocument); Console.WriteLine(); // Physical properties have not yet been computed for this model // so all values will be 0 with a status of 2. GetPhysicalProperties(partDocument, false); // This time, we will compute the physical properties of the model. GetPhysicalProperties(partDocument, true); Console.WriteLine("Switching to ISO view."); // Switch to ISO view. application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)SolidEdgeConstants.PartCommandConstants.PartViewISOView); // Show physical properties window. application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)SolidEdgeConstants.PartCommandConstants.PartToolsPhysicalProperties); } catch (System.Exception ex) { #if DEBUG System.Diagnostics.Debugger.Break(); #endif Console.WriteLine(ex.Message); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgePart.PartDocument partDocument = null; SolidEdgePart.RefPlanes refPlanes = null; SolidEdgePart.RefPlane refPlane = null; SolidEdgePart.ProfileSets profileSets = null; SolidEdgePart.ProfileSet profileSet = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile = null; SolidEdgeFrameworkSupport.Lines2d lines2d = null; SolidEdgeFrameworkSupport.Line2d line2d = null; SolidEdgeFrameworkSupport.Relations2d relations2d = null; SolidEdgeFrameworkSupport.Relation2d relation2d = null; SolidEdgePart.Models models = null; SolidEdgePart.Model model = null; List <SolidEdgePart.Profile> profileList = new List <SolidEdgePart.Profile>(); int status = 0; SolidEdgePart.ExtrudedProtrusions extrudedProtrusions = null; SolidEdgePart.ExtrudedProtrusion extrudedProtrusion = null; SolidEdgeGeometry.Edges edges = null; List <object> edgeList = new List <object>(); SolidEdgeGeometry.Faces faces = null; SolidEdgePart.Chamfers chamfers = null; SolidEdgePart.Chamfer chamfer = 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 documents collection. documents = application.Documents; // Create a new part document. partDocument = documents.AddPartDocument(); // Always a good idea to give SE a chance to breathe. application.DoIdle(); refPlanes = partDocument.RefPlanes; refPlane = refPlanes.Item(1); profileSets = partDocument.ProfileSets; profileSet = profileSets.Add(); profiles = profileSet.Profiles; profile = profiles.Add(refPlane); profileList.Add(profile); lines2d = profile.Lines2d; line2d = lines2d.AddBy2Points(0, 0, 0.06, 0); line2d = lines2d.AddBy2Points(0.06, 0, 0.06, 0.06); line2d = lines2d.AddBy2Points(0.06, 0.06, 0, 0.06); line2d = lines2d.AddBy2Points(0, 0.06, 0, 0); relations2d = (SolidEdgeFrameworkSupport.Relations2d)profile.Relations2d; relation2d = relations2d.AddKeypoint( Object1: lines2d.Item(1), Index1: (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, Object2: lines2d.Item(2), Index2: (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart); relation2d = relations2d.AddKeypoint( Object1: lines2d.Item(2), Index1: (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, Object2: lines2d.Item(3), Index2: (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart); relation2d = relations2d.AddKeypoint( Object1: lines2d.Item(3), Index1: (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, Object2: lines2d.Item(4), Index2: (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart); relation2d = relations2d.AddKeypoint( Object1: lines2d.Item(4), Index1: (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, Object2: lines2d.Item(1), Index2: (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart); // Make sure profile is closed. status = profile.End(SolidEdgePart.ProfileValidationType.igProfileClosed); if (status != 0) { throw new System.Exception("Profile not closed."); } models = partDocument.Models; model = models.AddFiniteExtrudedProtrusion( NumberOfProfiles: profileList.Count, ProfileArray: profileList.ToArray(), ProfilePlaneSide: SolidEdgePart.FeaturePropertyConstants.igRight, ExtrusionDistance: 0.02); profile.Visible = false; extrudedProtrusions = model.ExtrudedProtrusions; extrudedProtrusion = extrudedProtrusions.Item(1); //edges = (SolidEdgeGeometry.Edges)extrudedProtrusion.get_Edges( // SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll); //edgeList.Add(edges.Item(5)); //edgeList.Add(edges.Item(8)); faces = (SolidEdgeGeometry.Faces) extrudedProtrusion.get_Faces(SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll); chamfers = model.Chamfers; SolidEdgeGeometry.Face face = (SolidEdgeGeometry.Face)faces.Item(1); double setbackDistance1 = 0.009; double setbackDistance2 = 0.001; edges = (SolidEdgeGeometry.Edges)face.Edges; edgeList.Add(edges.Item(1)); chamfer = chamfers.AddUnequalSetback( ReferenceFace: face, NumberOfEdgeSets: edgeList.Count, EdgeSetArray: edgeList.ToArray(), SetbackDistance1: setbackDistance1, SetbackDistance2: setbackDistance2); // Switch to ISO view. application.StartCommand(SolidEdgeConstants.PartCommandConstants.PartViewISOView); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgePart.PartDocument partDocument = null; SolidEdgePart.Models models = null; SolidEdgePart.Model model = null; SolidEdgePart.Sketchs sketches = null; SolidEdgePart.Sketch sketch = null; SolidEdgePart.RefPlanes refPlanes = null; SolidEdgePart.RefPlane refPlane = null; SolidEdgePart.ProfileSets profileSets = null; SolidEdgePart.ProfileSet profileSet = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile sketchProfile = null; SolidEdgePart.Profile profile = null; SolidEdgeFrameworkSupport.Circles2d circles2d = null; List <SolidEdgePart.Profile> listPaths = new List <SolidEdgePart.Profile>(); List <SolidEdgePart.FeaturePropertyConstants> listPathTypes = new List <SolidEdgePart.FeaturePropertyConstants>(); List <SolidEdgePart.Profile> listSections = new List <SolidEdgePart.Profile>(); List <SolidEdgePart.FeaturePropertyConstants> listSectionTypes = new List <SolidEdgePart.FeaturePropertyConstants>(); List <int> listOrigins = new List <int>(); try { Console.WriteLine("Registering OleMessageFilter."); // Register with OLE to handle concurrency issues on the current thread. OleMessageFilter.Register(); Console.WriteLine("Connecting to Solid Edge."); // Connect to or start Solid Edge. application = SolidEdgeUtils.Connect(true); // Make sure user can see the GUI. application.Visible = true; // Bring Solid Edge to the foreground. application.Activate(); // Get a reference to the Documents collection. documents = application.Documents; Console.WriteLine("Creating a new part document."); // Create a new PartDocument. partDocument = (SolidEdgePart.PartDocument) documents.Add("SolidEdge.PartDocument"); // Always a good idea to give SE a chance to breathe. application.DoIdle(); Console.WriteLine("Drawing part."); // Get a reference to the models collection. models = (SolidEdgePart.Models)partDocument.Models; // Get a reference to the Sketches collections. sketches = (SolidEdgePart.Sketchs)partDocument.Sketches; // Get a reference to the profile sets collection. profileSets = (SolidEdgePart.ProfileSets)partDocument.ProfileSets; // Get a reference to the ref planes collection. refPlanes = (SolidEdgePart.RefPlanes)partDocument.RefPlanes; // Front (xz). refPlane = (SolidEdgePart.RefPlane)refPlanes.Item(3); // Add a new sketch. sketch = (SolidEdgePart.Sketch)sketches.Add(); // Add profile for sketch on specified refplane. sketchProfile = sketch.Profiles.Add(refPlane); // Get a reference to the Circles2d collection. circles2d = sketchProfile.Circles2d; // Draw the Base Profile. circles2d.AddByCenterRadius(0, 0, 0.02); // Close the profile. sketchProfile.End(SolidEdgePart.ProfileValidationType.igProfileClosed); // Arrays for AddSweptProtrusion(). listPaths.Add(sketchProfile); listPathTypes.Add(SolidEdgePart.FeaturePropertyConstants.igProfileBasedCrossSection); // NOTE: profile is the Curve. refPlane = refPlanes.AddNormalToCurve( sketchProfile, SolidEdgePart.ReferenceElementConstants.igCurveEnd, refPlanes.Item(3), SolidEdgePart.ReferenceElementConstants.igPivotEnd, true, System.Reflection.Missing.Value); // Add a new profile set. profileSet = (SolidEdgePart.ProfileSet)profileSets.Add(); // Get a reference to the profiles collection. profiles = (SolidEdgePart.Profiles)profileSet.Profiles; // add a new profile. profile = (SolidEdgePart.Profile)profiles.Add(refPlane); // Get a reference to the Circles2d collection. circles2d = profile.Circles2d; // Draw the Base Profile. circles2d.AddByCenterRadius(0, 0, 0.01); // Close the profile. profile.End(SolidEdgePart.ProfileValidationType.igProfileClosed); // Arrays for AddSweptProtrusion(). listSections.Add(profile); listSectionTypes.Add(SolidEdgePart.FeaturePropertyConstants.igProfileBasedCrossSection); listOrigins.Add(0); //Use 0 for closed profiles. Console.WriteLine("Creating swept protrusion."); // Create the extended protrusion. model = models.AddSweptProtrusion( listPaths.Count, listPaths.ToArray(), listPathTypes.ToArray(), listSections.Count, listSections.ToArray(), listSectionTypes.ToArray(), listOrigins.ToArray(), 0, SolidEdgePart.FeaturePropertyConstants.igLeft, SolidEdgePart.FeaturePropertyConstants.igNone, 0.0, null, SolidEdgePart.FeaturePropertyConstants.igNone, 0.0, null); // Hide profiles. sketchProfile.Visible = false; profile.Visible = false; // Switch to ISO view. application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)SolidEdgeConstants.PartCommandConstants.PartViewISOView); } catch (System.Exception ex) { #if DEBUG System.Diagnostics.Debugger.Break(); #endif Console.WriteLine(ex.Message); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgePart.PartDocument partDocument = null; SolidEdgePart.RefPlanes refPlanes = null; SolidEdgePart.RefPlane refPlane = null; SolidEdgePart.ProfileSets profileSets = null; SolidEdgePart.ProfileSet profileSet = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile = null; SolidEdgePart.Models models = null; SolidEdgePart.Model model = null; SolidEdgeFrameworkSupport.Lines2d lines2d = null; SolidEdgeFrameworkSupport.Line2d axis = null; SolidEdgeFrameworkSupport.Arcs2d arcs2d = null; SolidEdgeFrameworkSupport.Relations2d relations2d = null; SolidEdgePart.RefAxis refaxis = null; Array aProfiles = null; SolidEdgeGeometry.Edges edges = null; SolidEdgeGeometry.Circle circle = null; SolidEdgePart.RevolvedProtrusions revolvedProtrusions = null; SolidEdgePart.RevolvedProtrusion revolvedProtrusion = null; Array center = null; SolidEdgePart.Rounds rounds = null; try { Console.WriteLine("Registering OleMessageFilter."); // Register with OLE to handle concurrency issues on the current thread. OleMessageFilter.Register(); Console.WriteLine("Connecting to Solid Edge."); // Connect to or start Solid Edge. application = SolidEdgeUtils.Connect(true); // Make sure user can see the GUI. application.Visible = true; // Bring Solid Edge to the foreground. application.Activate(); // Get a reference to the Documents collection. documents = application.Documents; Console.WriteLine("Creating a new part document."); // Create a new PartDocument. partDocument = (SolidEdgePart.PartDocument) documents.Add("SolidEdge.PartDocument"); // Always a good idea to give SE a chance to breathe. application.DoIdle(); Console.WriteLine("Drawing part."); // Get a reference to the models collection. models = (SolidEdgePart.Models)partDocument.Models; // D1 to FA are parameters in a form, introduced by the user. double D1 = 0.020; double D2 = 0.026; double D3 = 0.003; double D4 = 0.014; double L1 = 0.040; double L2 = 0.030; double L3 = 0.005; double FA = 0.0005; // round // Get a reference to the ref planes collection. refPlanes = partDocument.RefPlanes; // Front (xz). refPlane = refPlanes.Item(3); // Get a reference to the profile sets collection. profileSets = (SolidEdgePart.ProfileSets)partDocument.ProfileSets; // Create a new profile set. profileSet = profileSets.Add(); // Get a reference to the profiles collection. profiles = profileSet.Profiles; // Create a new profile. profile = profiles.Add(refPlane); // Get a reference to the profile lines2d collection. lines2d = profile.Lines2d; // Get a reference to the profile arcs2d collection. arcs2d = profile.Arcs2d; double H = L1 - L2; double y = L1 - L3 - (D4 - D3) / (2 * Math.Tan((118 / 2) * (Math.PI / 180))); lines2d.AddBy2Points(D3 / 2, 0, D2 / 2, 0); // Line1 lines2d.AddBy2Points(D2 / 2, 0, D2 / 2, H); // Line2 lines2d.AddBy2Points(D2 / 2, H, D1 / 2, H); // Line3 lines2d.AddBy2Points(D1 / 2, H, D1 / 2, L1); // Line4 lines2d.AddBy2Points(D1 / 2, L1, D4 / 2, L1); // Line5 lines2d.AddBy2Points(D4 / 2, L1, D4 / 2, L1 - L3); // Line6 lines2d.AddBy2Points(D4 / 2, L1 - L3, D3 / 2, y); // Line7 lines2d.AddBy2Points(D3 / 2, y, D3 / 2, 0); // Line8 axis = lines2d.AddBy2Points(0, 0, 0, L1); profile.ToggleConstruction(axis); // relations relations2d = (SolidEdgeFrameworkSupport.Relations2d)profile.Relations2d; relations2d.AddKeypoint(lines2d.Item(1), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(2), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true); relations2d.AddKeypoint(lines2d.Item(2), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(3), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true); relations2d.AddKeypoint(lines2d.Item(3), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(4), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true); relations2d.AddKeypoint(lines2d.Item(4), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(5), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true); relations2d.AddKeypoint(lines2d.Item(5), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(6), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true); relations2d.AddKeypoint(lines2d.Item(6), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(7), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true); relations2d.AddKeypoint(lines2d.Item(7), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(8), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true); relations2d.AddKeypoint(lines2d.Item(8), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(1), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true); refaxis = (SolidEdgePart.RefAxis)profile.SetAxisOfRevolution(axis); // Close the profile. int status = profile.End(SolidEdgePart.ProfileValidationType.igProfileRefAxisRequired); profile.Visible = false; // Create a new array of profile objects. aProfiles = Array.CreateInstance(typeof(SolidEdgePart.Profile), 1); aProfiles.SetValue(profile, 0); Console.WriteLine("Creating finite revolved protrusion."); // add Finite Revolved Protrusion. model = models.AddFiniteRevolvedProtrusion(1, ref aProfiles, refaxis, SolidEdgePart.FeaturePropertyConstants.igRight, 2 * Math.PI, null, null); Console.WriteLine("Creating adding rounds."); SolidEdgeGeometry.Edge[] arrEdges = { null }; double[] arrRadii = { FA }; revolvedProtrusions = model.RevolvedProtrusions; revolvedProtrusion = revolvedProtrusions.Item(1); edges = (SolidEdgeGeometry.Edges)revolvedProtrusion.Edges[SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll]; foreach (SolidEdgeGeometry.Edge edge in edges) { circle = (SolidEdgeGeometry.Circle)edge.Geometry; if (circle.Radius == D2 / 2) { center = Array.CreateInstance(typeof(double), 3); circle.GetCenterPoint(ref center); if ((double)center.GetValue(0) == 0 && (double)center.GetValue(1) == 0 && (double)center.GetValue(2) == H) { arrEdges[0] = edge; break; } } } rounds = model.Rounds; object optArg = Type.Missing; rounds.Add(1, arrEdges, arrRadii, optArg, optArg, optArg, optArg); Console.WriteLine("Switching to ISO view."); // Switch to ISO view. application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)SolidEdgeConstants.PartCommandConstants.PartViewISOView); } catch (System.Exception ex) { #if DEBUG System.Diagnostics.Debugger.Break(); #endif Console.WriteLine(ex.Message); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgePart.SheetMetalDocument sheetMetalDocument = null; SolidEdgePart.FamilyMembers familyMembers = null; SolidEdgePart.Round round = null; SolidEdgePart.UserDefinedPattern userDefinedPattern = null; SolidEdgeFrameworkSupport.Dimension dimension = 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 part document. sheetMetalDocument = application.GetActiveDocument <SolidEdgePart.SheetMetalDocument>(false); if (sheetMetalDocument != null) { // Get a reference to the FamilyMembers collection. familyMembers = sheetMetalDocument.FamilyMembers; // Interate through the family members. foreach (var familyMember in familyMembers.OfType <SolidEdgePart.FamilyMember>()) { Console.WriteLine(familyMember.Name); // Determine FamilyMember MovePrecedence. switch (familyMember.MovePrecedence) { case SolidEdgePart.MovePrecedenceConstants.igModelMovePredecence: break; case SolidEdgePart.MovePrecedenceConstants.igSelectSetMovePrecedence: break; } // Warning: Accessing certain LiveRule[...] properties may throw an exception. //Console.WriteLine("igConcentricLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igConcentricLiveRule]); //Console.WriteLine("igCoplanarAxesAboutXLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igCoplanarAxesAboutXLiveRule]); //Console.WriteLine("igCoplanarAxesAboutYLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igCoplanarAxesAboutYLiveRule]); //Console.WriteLine("igCoplanarAxesAboutZLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igCoplanarAxesAboutZLiveRule]); //Console.WriteLine("igCoplanarAxesLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igCoplanarAxesLiveRule]); //Console.WriteLine("igCoplanarLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igCoplanarLiveRule]); //Console.WriteLine("igMaintainRadiusLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igMaintainRadiusLiveRule]); //Console.WriteLine("igOrthoLockingLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igOrthoLockingLiveRule]); //Console.WriteLine("igParallelLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igParallelLiveRule]); //Console.WriteLine("igPerpendicularLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igPerpendicularLiveRule]); //Console.WriteLine("igSymmetricLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igSymmetricLiveRule]); //Console.WriteLine("igSymmetricXYLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igSymmetricXYLiveRule]); //Console.WriteLine("igSymmetricYZLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igSymmetricYZLiveRule]); //Console.WriteLine("igSymmetricZXLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igSymmetricZXLiveRule]); //Console.WriteLine("igTangentEdgeLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igTangentEdgeLiveRule]); //Console.WriteLine("igTangentTouchingLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igTangentTouchingLiveRule]); //Console.WriteLine("igThicknessChainLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igThicknessChainLiveRule]); // Interate through the suppressed features of the current family member. for (int j = 1; j <= familyMember.SuppressedFeatureCount; j++) { object suppressedFeature = familyMember.SuppressedFeature[j]; // Use helper class to get the feature type. var featureType = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetPropertyValue <SolidEdgePart.FeatureTypeConstants>(suppressedFeature, "Type", (SolidEdgePart.FeatureTypeConstants) 0); switch (featureType) { case SolidEdgePart.FeatureTypeConstants.igRoundFeatureObject: round = (SolidEdgePart.Round)suppressedFeature; break; case SolidEdgePart.FeatureTypeConstants.igUserDefinedPatternFeatureObject: userDefinedPattern = (SolidEdgePart.UserDefinedPattern)suppressedFeature; break; } } // Interate through the variables of the current family member. for (int j = 1; j <= familyMember.VariableCount; j++) { object variable = familyMember.Variable[j]; // Use helper class to get the object type. var objectType = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetPropertyValue <SolidEdgeFramework.ObjectType>(variable, "Type", (SolidEdgeFramework.ObjectType) 0); switch (objectType) { case SolidEdgeFramework.ObjectType.igDimension: dimension = (SolidEdgeFrameworkSupport.Dimension)variable; break; } } } } else { throw new System.Exception("No active document."); } } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgeDraft.DraftDocument draftDocument = null; SolidEdgeDraft.Sheet sheet = null; SolidEdgeFrameworkSupport.TextBoxes textBoxes = null; SolidEdgeFrameworkSupport.TextBox textBox = null; SolidEdgeFrameworkSupport.Leaders leaders = null; SolidEdgeFrameworkSupport.Leader leader = null; SolidEdgeFrameworkSupport.DimStyle dimStyle = null; try { Console.WriteLine("Registering OleMessageFilter."); // Register with OLE to handle concurrency issues on the current thread. OleMessageFilter.Register(); Console.WriteLine("Connecting to Solid Edge."); // Connect to or start Solid Edge. application = SolidEdgeUtils.Connect(true); // Make sure user can see the GUI. application.Visible = true; // Bring Solid Edge to the foreground. application.Activate(); // Get a reference to the documents collection. documents = application.Documents; // Create a new draft document. draftDocument = (SolidEdgeDraft.DraftDocument)documents.Add("SolidEdge.DraftDocument"); // Get a reference to the active sheet. sheet = draftDocument.ActiveSheet; // Get a reference to the TextBoxes collection. textBoxes = (SolidEdgeFrameworkSupport.TextBoxes)sheet.TextBoxes; Console.WriteLine("Creating a new textbox. "); // Add a new text box. textBox = textBoxes.Add(0.25, 0.25, 0); textBox.TextScale = 1; textBox.VerticalAlignment = SolidEdgeFrameworkSupport.TextVerticalAlignmentConstants.igTextHzAlignVCenter; textBox.Text = "Leader"; // Get a reference to the Leaders collection. leaders = (SolidEdgeFrameworkSupport.Leaders)sheet.Leaders; Console.WriteLine("Creating a new leader. "); // Add a new leader. leader = leaders.Add(0.225, 0.225, 0, 0.25, 0.25, 0); dimStyle = leader.Style; dimStyle.FreeSpaceTerminatorType = SolidEdgeFrameworkSupport.DimTermTypeConstants.igDimStyleTermFilled; } catch (System.Exception ex) { #if DEBUG System.Diagnostics.Debugger.Break(); #endif Console.WriteLine(ex.Message); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgePart.SheetMetalDocument sheetMetalDocument = null; SolidEdgePart.FlatPatternModels flatPatternModels = null; SolidEdgePart.FlatPatternModel flatPatternModel = null; SolidEdgePart.Models models = null; SolidEdgePart.Model model = null; SolidEdgeGeometry.Face face = null; SolidEdgeGeometry.Edge edge = null; SolidEdgeGeometry.Vertex vertex = null; bool useFlatPattern = true; bool flatPatternIsUpToDate = false; string outFile = null; try { Console.WriteLine("Registering OleMessageFilter."); // Register with OLE to handle concurrency issues on the current thread. OleMessageFilter.Register(); Console.WriteLine("Connecting to Solid Edge."); // Connect to Solid Edge, application = SolidEdgeUtils.Connect(false); // Make sure user can see the GUI. application.Visible = true; // Bring Solid Edge to the foreground. application.Activate(); // Get a reference to the documents collection. documents = application.Documents; // This check is necessary because application.ActiveDocument will throw an // exception if no documents are open... if (documents.Count > 0) { // Attempt to open specified SheetMetalDocument. sheetMetalDocument = application.ActiveDocument as SolidEdgePart.SheetMetalDocument; } if (sheetMetalDocument == null) { throw new System.Exception("No active Sheet Metal document."); } // Get a reference to the Models collection, models = sheetMetalDocument.Models; // Check for geometry. if (models.Count == 0) { throw new System.Exception("No geometry defined."); } // Get a reference to the one and only model. model = models.Item(1); // Get a reference to the FlatPatternModels collection, flatPatternModels = sheetMetalDocument.FlatPatternModels; // Observation: SaveAsFlatDXFEx() will fail if useFlatPattern is specified and // flatPatternModels.Count = 0. // The following code will turn off the useFlatPattern switch if flatPatternModels.Count = 0. if (useFlatPattern) { if (flatPatternModels.Count > 0) { for (int i = 1; i <= flatPatternModels.Count; i++) { flatPatternModel = flatPatternModels.Item(i); flatPatternIsUpToDate = flatPatternModel.IsUpToDate; // If we find one that is up to date, call it good and bail. if (flatPatternIsUpToDate) { break; } } if (flatPatternIsUpToDate == false) { // Flat patterns exist but are out of date. useFlatPattern = false; } } else { // Can't use flat pattern if none exist. useFlatPattern = false; } } Console.WriteLine("Determining desired face, edge & vertex for SaveAsFlatDXFEx()."); // Some routine to get face, edge & vertex. GetFaceEdgeVertexForModel(model, out face, out edge, out vertex); outFile = Path.ChangeExtension(sheetMetalDocument.FullName, ".dxf"); //outFile = Path.ChangeExtension(sheetMetalDocument.FullName, ".par"); //outFile = Path.ChangeExtension(sheetMetalDocument.FullName, ".psm"); // Observation: If .par or .psm is specified in outFile, SE will open the file. // Even if useFlatPattern = true, it's a good idea to specify defaults for face, edge & vertex. // I've seen where outFile of .dxf would work but .psm would fail if the defaults were null; Console.WriteLine("Saving '{0}'.", outFile); models.SaveAsFlatDXFEx(outFile, face, edge, vertex, useFlatPattern); if (useFlatPattern) { Console.WriteLine("Saved '{0}' using Flat Pattern.", outFile); } else { Console.WriteLine("Saved '{0}' without using Flat Pattern.", outFile); } } catch (System.Exception ex) { #if DEBUG System.Diagnostics.Debugger.Break(); #endif Console.WriteLine(ex.Message); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgePart.SheetMetalDocument sheetMetalDocument = null; SolidEdgePart.Models models = null; SolidEdgePart.Model model = null; SolidEdgePart.Features features = null; bool bIgnoreWarnings = true; bool bExtendSelection = true; 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 part document. sheetMetalDocument = application.GetActiveDocument <SolidEdgePart.SheetMetalDocument>(false); if (sheetMetalDocument != null) { // Get a reference to the Models collection. models = sheetMetalDocument.Models; // Get a reference to the 1st model. model = models.Item(1); // Get a reference to the Features collection. features = model.Features; // Iterate through the features. foreach (var feature in features.OfType <object>()) { var featureEdgeBarName = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetPropertyValue <string>(feature, "EdgeBarName", "Unknown"); var featureModelingMode = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetPropertyValue <SolidEdgePart.ModelingModeConstants>(feature, "ModelingModeType", (SolidEdgePart.ModelingModeConstants) 0); // Check to see if the feature is ordered. // NOTE: I've found that not all features have a ModelingModeType property. SolidEdgePart.FaceRotate is one of them. // This is a bit of a problem because I see no way to know if the FaceRotate is Ordered or Synchronous... if (featureModelingMode == SolidEdgePart.ModelingModeConstants.seModelingModeOrdered) { int NumberOfFeaturesCausingError = 0; Array ErrorMessageArray = Array.CreateInstance(typeof(string), 0); int NumberOfFeaturesCausingWarning = 0; Array WarningMessageArray = Array.CreateInstance(typeof(string), 0); // Move the ordered feature to synchronous. sheetMetalDocument.MoveToSynchronous( pFeatureUnk: feature, bIgnoreWarnings: bIgnoreWarnings, bExtendSelection: bExtendSelection, NumberOfFeaturesCausingError: out NumberOfFeaturesCausingError, ErrorMessageArray: out ErrorMessageArray, NumberOfFeaturesCausingWarning: out NumberOfFeaturesCausingWarning, WarningMessageArray: out WarningMessageArray); Console.WriteLine("Feature '{0}' results:", featureEdgeBarName); // Process error messages. for (int i = 0; i < ErrorMessageArray.Length; i++) { Console.WriteLine("Error: '{0}'.", ErrorMessageArray.GetValue(i)); } // Process warning messages. for (int i = 0; i < WarningMessageArray.Length; i++) { Console.WriteLine("Warning: '{0}'.", WarningMessageArray.GetValue(i)); } // If you get any error or warning messages, it's probably a good idea to stop. if ((ErrorMessageArray.Length > 0) || (WarningMessageArray.Length > 0)) { break; } else { Console.WriteLine("Success"); } } } } else { throw new System.Exception("No active document."); } } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgeDraft.DraftDocument draftDocument = null; SolidEdgeDraft.Sheet sheet = null; SolidEdgeFrameworkSupport.Balloons balloons = null; SolidEdgeFrameworkSupport.Balloon balloon = null; SolidEdgeFrameworkSupport.DimStyle dimStype = null; try { Console.WriteLine("Registering OleMessageFilter."); // Register with OLE to handle concurrency issues on the current thread. OleMessageFilter.Register(); Console.WriteLine("Connecting to Solid Edge."); // Connect to or start Solid Edge. application = SolidEdgeUtils.Connect(true); // Make sure user can see the GUI. application.Visible = true; // Bring Solid Edge to the foreground. application.Activate(); // Get a reference to the documents collection. documents = application.Documents; // Create a new draft document. draftDocument = (SolidEdgeDraft.DraftDocument)documents.Add("SolidEdge.DraftDocument"); // Get a reference to the active sheet. sheet = draftDocument.ActiveSheet; // Get a reference to the balloons collection. balloons = (SolidEdgeFrameworkSupport.Balloons)sheet.Balloons; balloon = balloons.Add(0.05, 0.05, 0); balloon.TextScale = 1.0; balloon.BalloonText = "B"; balloon.Leader = true; balloon.BreakLine = true; balloon.BalloonSize = 3; balloon.SetTerminator(balloon, 0, 0, 0, false); balloon.BalloonType = SolidEdgeFrameworkSupport.DimBalloonTypeConstants.igDimBalloonCircle; dimStype = balloon.Style; dimStype.TerminatorType = SolidEdgeFrameworkSupport.DimTermTypeConstants.igDimStyleTermFilled; balloon = balloons.Add(0.1, 0.1, 0); balloon.Callout = 1; balloon.TextScale = 1.0; balloon.BalloonText = "This is a callout"; balloon.Leader = true; balloon.BreakLine = true; balloon.BalloonSize = 3; balloon.SetTerminator(balloon, 0, 0, 0, false); balloon.BalloonType = SolidEdgeFrameworkSupport.DimBalloonTypeConstants.igDimBalloonCircle; dimStype = balloon.Style; dimStype.TerminatorType = SolidEdgeFrameworkSupport.DimTermTypeConstants.igDimStyleTermFilled; } catch (System.Exception ex) { #if DEBUG System.Diagnostics.Debugger.Break(); #endif Console.WriteLine(ex.Message); } }