static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgePart.SheetMetalDocument document = 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 document. document = application.GetActiveDocument <SolidEdgePart.SheetMetalDocument>(false); // Make sure we have a document. if (document != null) { VariablesHelper.ReportVariables(document); } 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.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 CreateExtrudedProtrusion(SolidEdgePart.SheetMetalDocument sheetMetalDocument) { SolidEdgePart.RefPlanes refPlanes = null; SolidEdgePart.RefPlane refPlane = null; SolidEdgePart.Sketchs sketchs = null; SolidEdgePart.Sketch sketch = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile = null; SolidEdgeFrameworkSupport.Circles2d circles2d = null; SolidEdgeFrameworkSupport.Circle2d circle2d = null; SolidEdgePart.Models models = null; SolidEdgePart.Model model = null; // Get refplane. refPlanes = sheetMetalDocument.RefPlanes; refPlane = refPlanes.Item(2); // Create sketch. sketchs = sheetMetalDocument.Sketches; sketch = sketchs.Add(); // Create profile. profiles = sketch.Profiles; profile = profiles.Add(refPlane); // Create 2D circle. circles2d = profile.Circles2d; circle2d = circles2d.AddByCenterRadius(0, 0, 0.05); profile.Visible = false; // Create extruded protrusion. models = sheetMetalDocument.Models; model = models.AddBaseTab(profile, SolidEdgePart.FeaturePropertyConstants.igRight); }
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); // Get a reference to the active sheetmetal document. sheetMetalDocument = application.GetActiveDocument <SolidEdgePart.SheetMetalDocument>(); if (sheetMetalDocument != null) { sheetMetalDocument.Recompute(); } else { throw new System.Exception("No active document."); } } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
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; } }
static void CreateDimples(SolidEdgePart.SheetMetalDocument sheetMetalDocument) { SolidEdgePart.RefPlanes refplanes = null; SolidEdgePart.RefPlane refplane = null; SolidEdgePart.Models models = null; SolidEdgePart.Model model = 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; //List<SolidEdgePart.Profile> profileList = new List<SolidEdgePart.Profile>(); // Get a reference to the RefPlanes collection. refplanes = sheetMetalDocument.RefPlanes; // Get a reference to Right (yz) plane. refplane = refplanes.Item(3); // Get a reference to the Models collection. models = sheetMetalDocument.Models; // Get a reference to Model. model = models.Item(1); // Get a reference to the ProfileSets collection. profileSets = sheetMetalDocument.ProfileSets; // Add new ProfileSet. profileSet = profileSets.Add(); // Get a reference to the Profiles collection. profiles = profileSet.Profiles; // Add new Profile. profile = profiles.Add(refplane); // Draw a line to define the dimple point. lines2d = profile.Lines2d; line2d = lines2d.AddBy2Points(0, 0, 0.01, 0); // Hide the profile. profile.Visible = false; double depth = 0.01; // Add new dimple. model.Dimples.Add( Profile: profile, Depth: depth, ProfileSide: SolidEdgePart.DimpleFeatureConstants.seDimpleDepthLeft, DepthSide: SolidEdgePart.DimpleFeatureConstants.seDimpleDepthRight); }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgePart.SheetMetalDocument sheetMetalDocument = 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(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; Console.WriteLine("Creating a new sheetmetal document."); // Create a new sheetmetal document. sheetMetalDocument = (SolidEdgePart.SheetMetalDocument) documents.Add("SolidEdge.SheetMetalDocument"); // Always a good idea to give SE a chance to breathe. application.DoIdle(); // Create geometry. CreateExtrudedProtrusion(sheetMetalDocument); // Create dimples. CreateDimples(sheetMetalDocument); 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.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; 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; 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(); } }
public static SolidEdgePart.Model CreateBaseTabByCircle(SolidEdgePart.SheetMetalDocument sheetMetalDocument) { SolidEdgePart.RefPlanes refPlanes = null; SolidEdgePart.RefPlane refPlane = null; SolidEdgePart.Sketchs sketchs = null; SolidEdgePart.Sketch sketch = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile = null; SolidEdgeFrameworkSupport.Circles2d circles2d = null; SolidEdgeFrameworkSupport.Circle2d circle2d = null; SolidEdgePart.Models models = null; SolidEdgePart.Model model = null; double x = 0; double y = 0; double radius = 0.05; // Get refplane. refPlanes = sheetMetalDocument.RefPlanes; // Get a reference to front RefPlane. refPlane = refPlanes.GetFrontPlane(); // Create sketch. sketchs = sheetMetalDocument.Sketches; sketch = sketchs.Add(); // Create profile. profiles = sketch.Profiles; profile = profiles.Add(refPlane); // Create 2D circle. circles2d = profile.Circles2d; circle2d = circles2d.AddByCenterRadius(x, y, radius); // Hide profile. profile.Visible = false; // Create extruded protrusion. models = sheetMetalDocument.Models; model = models.AddBaseTab(profile, SolidEdgePart.FeaturePropertyConstants.igRight); return(model); }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = 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); // Get a reference to the documents collection. documents = application.Documents; // Create a new sheetmetal document using PROGID. sheetMetalDocument = (SolidEdgePart.SheetMetalDocument)documents.Add("SolidEdge.SheetMetalDocument"); // Create a new sheetmetal document using PROGID defined in Interop.SolidEdge.dll. sheetMetalDocument = (SolidEdgePart.SheetMetalDocument)documents.Add(SolidEdgeSDK.PROGID.SolidEdge_SheetMetalDocument); // Create a new sheetmetal document using SolidEdge.Community.dll extension method. sheetMetalDocument = documents.AddSheetMetalDocument(); // Create a new sheetmetal document using SolidEdge.Community.dll extension method. sheetMetalDocument = documents.Add <SolidEdgePart.SheetMetalDocument>(); } 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.SheetMetalDocument sheetMetalDocument = null; SolidEdgePart.RefPlanes refPlanes = null; SolidEdgePart.RefPlane refPlane = null; SolidEdgePart.Model model = 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; SolidEdgePart.Dimple dimple = 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); // 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.CreateBaseTabByCircle(sheetMetalDocument); // Get a reference to the RefPlanes collection. refPlanes = sheetMetalDocument.RefPlanes; // Get a reference to front RefPlane. refPlane = refPlanes.GetFrontPlane(); // Get a reference to the ProfileSets collection. profileSets = sheetMetalDocument.ProfileSets; // Add new ProfileSet. profileSet = profileSets.Add(); // Get a reference to the Profiles collection. profiles = profileSet.Profiles; // Add new Profile. profile = profiles.Add(refPlane); // Draw a line to define the dimple point. lines2d = profile.Lines2d; line2d = lines2d.AddBy2Points(0, 0, 0.01, 0); // Hide the profile. profile.Visible = false; double depth = 0.01; // Add new dimple. dimple = model.Dimples.Add( Profile: profile, Depth: depth, ProfileSide: SolidEdgePart.DimpleFeatureConstants.seDimpleDepthLeft, DepthSide: SolidEdgePart.DimpleFeatureConstants.seDimpleDepthRight); // Get a reference to the ActiveSelectSet. selectSet = application.ActiveSelectSet; // Empty ActiveSelectSet. selectSet.RemoveAll(); // Add new Dimple to ActiveSelectSet. selectSet.Add(dimple); // Switch to ISO view. application.StartCommand(SolidEdgeConstants.SheetMetalCommandConstants.SheetMetalViewISOView); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
/// <summary> /// Returns a collection of variables for the referenced document. /// </summary> /// <param name="document"></param> /// <returns></returns> public static SolidEdgeFramework.Variables GetVariables(this SolidEdgePart.SheetMetalDocument document) { return(document.Variables as SolidEdgeFramework.Variables); }
/// <summary> /// Returns the summary information property set for the referenced document. /// </summary> /// <param name="document"></param> /// <returns></returns> public static SolidEdgeFramework.SummaryInfo GetSummaryInfo(this SolidEdgePart.SheetMetalDocument document) { return(document.SummaryInfo as SolidEdgeFramework.SummaryInfo); }
/// <summary> /// Returns the properties for the referenced document. /// </summary> /// <param name="document"></param> /// <returns></returns> public static SolidEdgeFramework.PropertySets GetProperties(this SolidEdgePart.SheetMetalDocument document) { return(document.Properties as SolidEdgeFramework.PropertySets); }
/// <summary> /// Returns the version of Solid Edge that was used the last time the referenced document was saved. /// </summary> /// <param name="document"></param> /// <returns></returns> public static Version GetLastSavedVersion(this SolidEdgePart.SheetMetalDocument document) { return(new Version(document.LastSavedVersion)); }
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(); } }
public static void CreateHolesWithUserDefinedPattern(SolidEdgePart.SheetMetalDocument sheetMetalDocument) { SolidEdgePart.RefPlanes refplanes = null; SolidEdgePart.RefPlane refplane = null; SolidEdgePart.Model model = null; SolidEdgePart.HoleDataCollection holeDataCollection = null; SolidEdgePart.ProfileSets profileSets = null; SolidEdgePart.ProfileSet profileSet = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile = null; SolidEdgePart.Holes2d holes2d = null; SolidEdgePart.Hole2d hole2d = null; SolidEdgePart.Holes holes = null; SolidEdgePart.Hole hole = null; long profileStatus = 0; List <SolidEdgePart.Profile> profileList = new List <SolidEdgePart.Profile>(); SolidEdgePart.UserDefinedPatterns userDefinedPatterns = null; SolidEdgePart.UserDefinedPattern userDefinedPattern = null; // Call helper method to create the actual geometry. model = CreateBaseTabByCircle(sheetMetalDocument); // Get a reference to the RefPlanes collection. refplanes = sheetMetalDocument.RefPlanes; // Get a reference to front RefPlane. refplane = refplanes.GetFrontPlane(); // Get a reference to the ProfileSets collection. profileSets = sheetMetalDocument.ProfileSets; // Add new ProfileSet. profileSet = profileSets.Add(); // Get a reference to the Profiles collection. profiles = profileSet.Profiles; // Add new Profile. profile = profiles.Add(refplane); // Get a reference to the Holes2d collection. holes2d = profile.Holes2d; // This creates a cross pattern of holes. double[,] holeMatrix = new double[, ] { //{x, y} { 0.00, 0.00 }, { -0.01, 0.00 }, { -0.02, 0.00 }, { -0.03, 0.00 }, { -0.04, 0.00 }, { 0.01, 0.00 }, { 0.02, 0.00 }, { 0.03, 0.00 }, { 0.04, 0.00 }, { 0.00, -0.01 }, { 0.00, -0.02 }, { 0.00, -0.03 }, { 0.00, -0.04 }, { 0.00, 0.01 }, { 0.00, 0.02 }, { 0.00, 0.03 }, { 0.00, 0.04 } }; // Draw the Base Profile. for (int i = 0; i <= holeMatrix.GetUpperBound(0); i++) { // Add new Hole2d. hole2d = holes2d.Add( XCenter: holeMatrix[i, 0], YCenter: holeMatrix[i, 1]); } // Hide the profile. profile.Visible = false; // Close profile. profileStatus = profile.End(SolidEdgePart.ProfileValidationType.igProfileClosed); // Get a reference to the ProfileSet. profileSet = (SolidEdgePart.ProfileSet)profile.Parent; // Get a reference to the Profiles collection. profiles = profileSet.Profiles; // Add profiles to list for AddByProfiles(). for (int i = 1; i <= profiles.Count; i++) { profileList.Add(profiles.Item(i)); } // Get a reference to the HoleDataCollection collection. holeDataCollection = sheetMetalDocument.HoleDataCollection; // Add new HoleData. SolidEdgePart.HoleData holeData = holeDataCollection.Add( HoleType: SolidEdgePart.FeaturePropertyConstants.igRegularHole, HoleDiameter: 0.005, BottomAngle: 90); // Get a reference to the Holes collection. holes = model.Holes; // Add hole. hole = holes.AddFinite( Profile: profile, ProfilePlaneSide: SolidEdgePart.FeaturePropertyConstants.igRight, FiniteDepth: 0.005, Data: holeData); // Get a reference to the UserDefinedPatterns collection. userDefinedPatterns = model.UserDefinedPatterns; // Create the user defined pattern. userDefinedPattern = userDefinedPatterns.AddByProfiles( NumberOfProfiles: profileList.Count, ProfilesArray: profileList.ToArray(), SeedFeature: hole); }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgePart.SheetMetalDocument sheetMetalDocument = null; SolidEdgePart.RefPlanes refplanes = null; SolidEdgePart.RefPlane refplane = null; SolidEdgePart.Model model = null; SolidEdgePart.HoleDataCollection holeDataCollection = null; SolidEdgePart.ProfileSets profileSets = null; SolidEdgePart.ProfileSet profileSet = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile = null; SolidEdgePart.Holes2d holes2d = null; SolidEdgePart.Hole2d hole2d = null; SolidEdgePart.Holes holes = null; SolidEdgePart.Hole hole = null; long profileStatus = 0; List <SolidEdgePart.Profile> profileList = new List <SolidEdgePart.Profile>(); SolidEdgePart.UserDefinedPatterns userDefinedPatterns = null; SolidEdgePart.UserDefinedPattern userDefinedPattern = 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); // 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.CreateBaseTabByCircle(sheetMetalDocument); // Get a reference to the RefPlanes collection. refplanes = sheetMetalDocument.RefPlanes; // Get a reference to front RefPlane. refplane = refplanes.GetFrontPlane(); // Get a reference to the ProfileSets collection. profileSets = sheetMetalDocument.ProfileSets; // Add new ProfileSet. profileSet = profileSets.Add(); // Get a reference to the Profiles collection. profiles = profileSet.Profiles; // Add new Profile. profile = profiles.Add(refplane); // Get a reference to the Holes2d collection. holes2d = profile.Holes2d; // This creates a cross pattern of holes. double[,] holeMatrix = new double[, ] { //{x, y} { 0.00, 0.00 }, { -0.01, 0.00 }, { -0.02, 0.00 }, { -0.03, 0.00 }, { -0.04, 0.00 }, { 0.01, 0.00 }, { 0.02, 0.00 }, { 0.03, 0.00 }, { 0.04, 0.00 }, { 0.00, -0.01 }, { 0.00, -0.02 }, { 0.00, -0.03 }, { 0.00, -0.04 }, { 0.00, 0.01 }, { 0.00, 0.02 }, { 0.00, 0.03 }, { 0.00, 0.04 } }; // Draw the Base Profile. for (int i = 0; i <= holeMatrix.GetUpperBound(0); i++) { // Add new Hole2d. hole2d = holes2d.Add( XCenter: holeMatrix[i, 0], YCenter: holeMatrix[i, 1]); } // Hide the profile. profile.Visible = false; // Close profile. profileStatus = profile.End(SolidEdgePart.ProfileValidationType.igProfileClosed); // Get a reference to the ProfileSet. profileSet = (SolidEdgePart.ProfileSet)profile.Parent; // Get a reference to the Profiles collection. profiles = profileSet.Profiles; // Add profiles to list for AddByProfiles(). for (int i = 1; i <= profiles.Count; i++) { profileList.Add(profiles.Item(i)); } // Get a reference to the HoleDataCollection collection. holeDataCollection = sheetMetalDocument.HoleDataCollection; // Add new HoleData. SolidEdgePart.HoleData holeData = holeDataCollection.Add( HoleType: SolidEdgePart.FeaturePropertyConstants.igRegularHole, HoleDiameter: 0.005, BottomAngle: 90); // Get a reference to the Holes collection. holes = model.Holes; // Add hole. hole = holes.AddFinite( Profile: profile, ProfilePlaneSide: SolidEdgePart.FeaturePropertyConstants.igRight, FiniteDepth: 0.005, Data: holeData); // Get a reference to the UserDefinedPatterns collection. userDefinedPatterns = model.UserDefinedPatterns; // Create the user defined pattern. userDefinedPattern = userDefinedPatterns.AddByProfiles( NumberOfProfiles: profileList.Count, ProfilesArray: profileList.ToArray(), SeedFeature: hole); // Get a reference to the ActiveSelectSet. selectSet = application.ActiveSelectSet; // Empty ActiveSelectSet. selectSet.RemoveAll(); // Add new UserDefinedPattern to ActiveSelectSet. selectSet.Add(userDefinedPattern); // Switch to ISO view. application.StartCommand(SolidEdgeConstants.SheetMetalCommandConstants.SheetMetalViewISOView); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
public static void ReportVariables(SolidEdgePart.SheetMetalDocument document) { ReportVariables((SolidEdgeFramework.SolidEdgeDocument)document); }
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; SolidEdgeFramework.Documents documents = null; SolidEdgePart.SheetMetalDocument sheetMetalDocument = null; SolidEdgePart.RefPlanes refPlanes = null; SolidEdgePart.RefPlane refPlane = null; SolidEdgeFramework.SelectSet selectSet = null; Array features = Array.CreateInstance(typeof(object), 0); SolidEdgePart.ExtrudedProtrusion extrudedProtrustion = null; SolidEdgePart.UserDefinedPattern userDefinedPattern = null; SolidEdgePart.MirrorCopy mirrorCopy = 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; // Create a new sheet metal document. sheetMetalDocument = documents.AddSheetMetalDocument(); // Always a good idea to give SE a chance to breathe. application.DoIdle(); // Get a reference to the RefPlanes collection. refPlanes = sheetMetalDocument.RefPlanes; // Get a reference to the top RefPlane using extension method. refPlane = refPlanes.GetTopPlane(); // Get path to Solid Edge training directory. Typically, 'C:\Program Files\Solid Edge XXX\Training'. var trainingDirectory = new System.IO.DirectoryInfo(SolidEdgeCommunity.SolidEdgeUtils.GetTrainingFolderPath()); // Build path to source part document. //string LibName = System.IO.Path.Combine(trainingDirectory.FullName, "Foot1.psm"); string LibName = System.IO.Path.Combine(trainingDirectory.FullName, "base.par"); // This method will take all features from block.par and place them into the new part document. sheetMetalDocument.PlaceFeatureLibrary(LibName, refPlane, 0.0, 0.0, 0.0, out features); // Optionally, iterate through all of the added features. foreach (var feature in features.OfType <object>()) { // Use helper class to get the feature type. var featureType = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetPropertyValue <SolidEdgePart.FeatureTypeConstants>(feature, "Type", (SolidEdgePart.FeatureTypeConstants) 0); // Depending on the feature type, we can cast the weakly typed feature to a strongly typed feature. switch (featureType) { case SolidEdgePart.FeatureTypeConstants.igExtrudedProtrusionFeatureObject: extrudedProtrustion = (SolidEdgePart.ExtrudedProtrusion)feature; break; case SolidEdgePart.FeatureTypeConstants.igUserDefinedPatternFeatureObject: userDefinedPattern = (SolidEdgePart.UserDefinedPattern)feature; break; case SolidEdgePart.FeatureTypeConstants.igMirrorCopyFeatureObject: mirrorCopy = (SolidEdgePart.MirrorCopy)feature; break; } } // Get a reference to the ActiveSelectSet. selectSet = application.ActiveSelectSet; // Empty ActiveSelectSet. selectSet.RemoveAll(); // Add all features to ActiveSelectSet. foreach (object feature in features) { selectSet.Add(feature); } // 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.SheetMetalDocument sheetMetalDocument = null; SolidEdgePart.RefPlanes refPlanes = null; SolidEdgePart.RefPlane refPlane = null; SolidEdgePart.Sketchs sketchs = null; SolidEdgePart.Sketch sketch = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile = null; SolidEdgeFrameworkSupport.Circles2d circles2d = null; SolidEdgeFrameworkSupport.Circle2d circle2d = null; SolidEdgePart.Model model = null; SolidEdgePart.ExtrudedCutouts extrudedCutouts = null; SolidEdgePart.ExtrudedCutout extrudedCutout = null; List <SolidEdgePart.Profile> profileList = new List <SolidEdgePart.Profile>(); double finiteDepth1 = 0.5; 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); // 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.CreateBaseTabByCircle(sheetMetalDocument); // Get a reference to the RefPlanes collection. refPlanes = sheetMetalDocument.RefPlanes; // Get a reference to right RefPlane. refPlane = refPlanes.GetRightPlane(); // Get a reference to the Sketches collection. sketchs = sheetMetalDocument.Sketches; // Add a new Sketch. sketch = sketchs.Add(); // Get a reference to the Profiles collection. profiles = sketch.Profiles; // Add a new Profile. profile = profiles.Add(refPlane); profileList.Add(profile); // Create 2D circle. circles2d = profile.Circles2d; circle2d = circles2d.AddByCenterRadius(0, 0, 0.025); profile.Visible = false; // Get a reference to the ExtrudedCutouts collection. extrudedCutouts = model.ExtrudedCutouts; // Add a new ExtrudedCutout. extrudedCutout = extrudedCutouts.Add( profileList.Count, profileList.ToArray(), SolidEdgePart.FeaturePropertyConstants.igLeft, SolidEdgePart.FeaturePropertyConstants.igFinite, SolidEdgePart.FeaturePropertyConstants.igSymmetric, finiteDepth1, null, SolidEdgePart.KeyPointExtentConstants.igTangentNormal, null, SolidEdgePart.OffsetSideConstants.seOffsetNone, 0, SolidEdgePart.TreatmentTypeConstants.seTreatmentNone, SolidEdgePart.DraftSideConstants.seDraftNone, 0, SolidEdgePart.TreatmentCrownTypeConstants.seTreatmentCrownNone, SolidEdgePart.TreatmentCrownSideConstants.seTreatmentCrownSideNone, SolidEdgePart.TreatmentCrownCurvatureSideConstants.seTreatmentCrownCurvatureNone, 0, 0, SolidEdgePart.FeaturePropertyConstants.igNone, SolidEdgePart.FeaturePropertyConstants.igNone, 0, null, SolidEdgePart.KeyPointExtentConstants.igTangentNormal, null, SolidEdgePart.OffsetSideConstants.seOffsetNone, 0, SolidEdgePart.TreatmentTypeConstants.seTreatmentNone, SolidEdgePart.DraftSideConstants.seDraftNone, 0, SolidEdgePart.TreatmentCrownTypeConstants.seTreatmentCrownNone, SolidEdgePart.TreatmentCrownSideConstants.seTreatmentCrownSideNone, SolidEdgePart.TreatmentCrownCurvatureSideConstants.seTreatmentCrownCurvatureNone, 0, 0); // Get a reference to the ActiveSelectSet. selectSet = application.ActiveSelectSet; // Empty ActiveSelectSet. selectSet.RemoveAll(); // Add new ExtrudedCutout to ActiveSelectSet. selectSet.Add(extrudedCutout); // Switch to ISO view. application.StartCommand(SolidEdgeConstants.SheetMetalCommandConstants.SheetMetalViewISOView); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
public static void SaveAsJT(SolidEdgePart.SheetMetalDocument document) { SaveAsJT((SolidEdgeFramework.SolidEdgeDocument)document); }
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; SolidEdgePart.SheetMetalDocument sheetMetalDocument = null; SolidEdgePart.Models models = null; SolidEdgePart.Model model = null; double density = 0; double accuracy = 0; double volume = 0; double area = 0; double mass = 0; Array cetnerOfGravity = Array.CreateInstance(typeof(double), 3); Array centerOfVolumne = Array.CreateInstance(typeof(double), 3); Array globalMomentsOfInteria = Array.CreateInstance(typeof(double), 6); // Ixx, Iyy, Izz, Ixy, Ixz and Iyz Array principalMomentsOfInteria = Array.CreateInstance(typeof(double), 3); // Ixx, Iyy and Izz Array principalAxes = Array.CreateInstance(typeof(double), 9); // 3 axes x 3 coords Array radiiOfGyration = Array.CreateInstance(typeof(double), 9); // 3 axes x 3 coords double relativeAccuracyAchieved = 0; int status = 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); // Get a reference to the active document. sheetMetalDocument = application.GetActiveDocument <SolidEdgePart.SheetMetalDocument>(false); if (sheetMetalDocument != null) { density = 1; accuracy = 0.05; // Get a reference to the Models collection. models = sheetMetalDocument.Models; // Get a reference to the Model. model = models.Item(1); // Compute the physical properties. model.ComputePhysicalProperties( Density: density, Accuracy: accuracy, Volume: out volume, Area: out area, Mass: out mass, CenterOfGravity: ref cetnerOfGravity, CenterOfVolume: ref centerOfVolumne, GlobalMomentsOfInteria: ref globalMomentsOfInteria, PrincipalMomentsOfInteria: ref principalMomentsOfInteria, PrincipalAxes: ref principalAxes, RadiiOfGyration: ref radiiOfGyration, RelativeAccuracyAchieved: out relativeAccuracyAchieved, Status: out status); Console.WriteLine("ComputePhysicalProperties() results:"); // Write results to screen. Console.WriteLine("Density: {0}", density); Console.WriteLine("Accuracy: {0}", accuracy); Console.WriteLine("Volume: {0}", volume); Console.WriteLine("Area: {0}", area); Console.WriteLine("Mass: {0}", mass); // Convert from System.Array to double[]. double[] is easier to work with. double[] m = cetnerOfGravity.OfType <double>().ToArray(); Console.WriteLine("CenterOfGravity:"); Console.WriteLine("\t|{0}, {1}, {2}|", m[0], m[1], m[2]); m = centerOfVolumne.OfType <double>().ToArray(); Console.WriteLine("CenterOfVolume:"); Console.WriteLine("\t|{0}, {1}, {2}|", m[0], m[1], m[2]); m = globalMomentsOfInteria.OfType <double>().ToArray(); Console.WriteLine("GlobalMomentsOfInteria:"); Console.WriteLine("\t|{0}, {1}, {2}|", m[0], m[1], m[2]); Console.WriteLine("\t|{0}, {1}, {2}|", m[3], m[4], m[5]); m = principalMomentsOfInteria.OfType <double>().ToArray(); Console.WriteLine("PrincipalMomentsOfInteria:"); Console.WriteLine("\t|{0}, {1}, {2}|", m[0], m[1], m[2]); m = principalAxes.OfType <double>().ToArray(); Console.WriteLine("PrincipalAxes:"); Console.WriteLine("\t|{0}, {1}, {2}|", m[0], m[1], m[2]); Console.WriteLine("\t|{0}, {1}, {2}|", m[3], m[4], m[5]); Console.WriteLine("\t|{0}, {1}, {2}|", m[6], m[7], m[8]); m = radiiOfGyration.OfType <double>().ToArray(); Console.WriteLine("RadiiOfGyration:"); Console.WriteLine("\t|{0}, {1}, {2}|", m[0], m[1], m[2]); Console.WriteLine("\t|{0}, {1}, {2}|", m[3], m[4], m[5]); Console.WriteLine("\t|{0}, {1}, {2}|", m[6], m[7], m[8]); Console.WriteLine("RelativeAccuracyAchieved: {0}", relativeAccuracyAchieved); Console.WriteLine("Status: {0}", status); Console.WriteLine(); // Show physical properties window. application.StartCommand(SolidEdgeConstants.SheetMetalCommandConstants.SheetMetalToolsPhysicalProperties); } 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.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(); } }
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 CreateBaseTab(SolidEdgePart.SheetMetalDocument sheetMetalDocument) { SolidEdgePart.ProfileSets profileSets = null; SolidEdgePart.ProfileSet profileSet = null; SolidEdgePart.Profiles profiles = null; SolidEdgePart.Profile profile = null; SolidEdgePart.RefPlanes refplanes = null; SolidEdgeFrameworkSupport.Relations2d relations2d = null; SolidEdgeFrameworkSupport.Relation2d relation2d = null; SolidEdgeFrameworkSupport.Lines2d lines2d = null; SolidEdgeFrameworkSupport.Line2d line2d = null; SolidEdgePart.Models models = null; SolidEdgePart.Model model = null; // Get a reference to the profile sets collection. profileSets = sheetMetalDocument.ProfileSets; // Add a new profile set. profileSet = profileSets.Add(); // Get a reference to the profiles collection. profiles = profileSet.Profiles; // Get a reference to the ref planes collection. refplanes = sheetMetalDocument.RefPlanes; // Add a new profile. profile = profiles.Add(refplanes.Item(1)); // Get a reference to the lines2d collection. lines2d = profile.Lines2d; // UOM = meters. double[,] lineMatrix = new double[, ] { //{x1, y1, x2, y2} { 0.05, 0.025, 0.05, 0.025 }, { -0.05, 0.025, -0.05, -0.025 }, { -0.05, -0.025, 0.05, -0.025 }, { 0.05, -0.025, 0.05, 0.025 } }; // Draw the Base Profile. for (int i = 0; i <= lineMatrix.GetUpperBound(0); i++) { line2d = lines2d.AddBy2Points( lineMatrix[i, 0], lineMatrix[i, 1], lineMatrix[i, 2], lineMatrix[i, 3]); } // Define Relations among the Line objects to make the Profile closed. relations2d = (SolidEdgeFrameworkSupport.Relations2d)profile.Relations2d; // Connect all of the lines. for (int i = 1; i <= lines2d.Count; i++) { int j = i + 1; // When we reach the last line, wrap around and connect it to the first line. if (j > lines2d.Count) { j = 1; } relation2d = relations2d.AddKeypoint( lines2d.Item(i), (int)SolidEdgeConstants.KeypointIndexConstants.igLineEnd, lines2d.Item(j), (int)SolidEdgeConstants.KeypointIndexConstants.igLineStart, true); } // Close the profile. profile.End(SolidEdgePart.ProfileValidationType.igProfileClosed); // Hide the profile. profile.Visible = false; // Get a reference to the models collection. models = sheetMetalDocument.Models; // Create the base tab. model = models.AddBaseTab(profile, SolidEdgePart.FeaturePropertyConstants.igRight); }