private void button3_Click(object sender, EventArgs e) { // Connect to or start Solid Edge. YCC_solidedge.getEdgeApplication(ref SEApp, true); SolidEdgeAssembly.AssemblyDocument asydoc = (SolidEdgeAssembly.AssemblyDocument)SEApp.ActiveDocument; SolidEdgeAssembly.Occurrences occs = (SolidEdgeAssembly.Occurrences)asydoc.Occurrences; SolidEdgeAssembly.Occurrence occ = (SolidEdgeAssembly.Occurrence)occs.Item(2); Array MinRangePoint = Array.CreateInstance(typeof(double), 0); Array MaxRangePoint = Array.CreateInstance(typeof(double), 0); //object[] w = new object[3]; occ.GetRangeBox(ref MinRangePoint, ref MaxRangePoint); SolidEdgePart.PartDocument ps = (SolidEdgePart.PartDocument)occ.OccurrenceDocument; //SolidEdgePart.Models ms = (SolidEdgePart.Models)ps.Models.Item[1]; SolidEdgePart.Model m = (SolidEdgePart.Model)ps.Models.Item(1); SolidEdgeGeometry.Body b = (SolidEdgeGeometry.Body)m.Body; SolidEdgeGeometry.Edges ees = (SolidEdgeGeometry.Edges)b.Edges[SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll]; SolidEdgeGeometry.Edge ee = (SolidEdgeGeometry.Edge)ees.Item(1); //ee.GetRange(ref MinRangePoint, ref MaxRangePoint); b.GetRange(ref MinRangePoint, ref MaxRangePoint); }
private void ProcessAssembly(int level, SolidEdgeAssembly.AssemblyDocument assemblyDocument, Dictionary <string, BomItem> bomItems) { // Increment level (depth). level++; // Loop through the Occurrences. foreach (SolidEdgeAssembly.Occurrence occurrence in assemblyDocument.Occurrences) { // Filter out certain occurrences. if (!occurrence.IncludeInBom) { continue; } if (occurrence.IsPatternItem) { continue; } if (occurrence.OccurrenceDocument == null) { continue; } // Get a reference to the SolidEdgeDocument. SolidEdgeFramework.SolidEdgeDocument document = (SolidEdgeFramework.SolidEdgeDocument)occurrence.OccurrenceDocument; // Add the BomItem. AddBomItem(level, document, bomItems); if (occurrence.Subassembly) { // Sub Assembly. Recurisve call to drill down. ProcessAssembly(level, (SolidEdgeAssembly.AssemblyDocument)occurrence.OccurrenceDocument, bomItems); } } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeAssembly.AssemblyDocument assemblyDocument = null; SolidEdgeAssembly.Occurrences occurrences = 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 the active document. assemblyDocument = application.GetActiveDocument <SolidEdgeAssembly.AssemblyDocument>(false); if (assemblyDocument != null) { // Get a reference to the Occurrences collection. occurrences = assemblyDocument.Occurrences; foreach (var occurrence in occurrences.OfType <SolidEdgeAssembly.Occurrence>()) { Array MinRangePoint = Array.CreateInstance(typeof(double), 0); Array MaxRangePoint = Array.CreateInstance(typeof(double), 0); occurrence.GetRangeBox(ref MinRangePoint, ref MaxRangePoint); // Convert from System.Array to double[]. double[] is easier to work with. double[] a1 = MinRangePoint.OfType <double>().ToArray(); double[] a2 = MaxRangePoint.OfType <double>().ToArray(); // Report the occurrence matrix. Console.WriteLine("{0} range box:", occurrence.Name); Console.WriteLine("|MinRangePoint: {0}, {1}, {2}|", a1[0], a1[1], a1[2]); Console.WriteLine("|MaxRangePoint: {0}, {1}, {2}|", a2[0], a2[1], a2[2]); } } else { throw new System.Exception("No active document."); } } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
static void CreateDoc() { Console.WriteLine("Creation de document test"); documents = application.Documents; assembly = (SolidEdgeAssembly.AssemblyDocument)documents.Add("SolidEdge.AssemblyDocument", Missing.Value); draft = (SolidEdgeDraft.DraftDocument)documents.Add("SolidEdge.DraftDocument", Missing.Value); part = (SolidEdgePart.PartDocument)documents.Add("SolidEdge.PartDocument", Missing.Value); CleanSE(); }
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; } }
public BomItem[] GetBomItems() { // Dictionary to hold BomItem(s). Key is the full path to the SolidEdgeDocument. Dictionary <string, BomItem> bomItems = new Dictionary <string, BomItem>(); SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgeAssembly.AssemblyDocument assemblyDocument = null; OleMessageFilter.Register(); try { // Attempt to connect to a running instance of Solid Edge. application = SolidEdgeUtils.Connect(); // Get a reference to the Documents collection. documents = application.Documents; // Make sure a document is open and that it's an AssemblyDocument. if ((documents.Count > 0) && (application.ActiveDocumentType == SolidEdgeFramework.DocumentTypeConstants.igAssemblyDocument)) { // Get a reference to the AssemblyDocument. assemblyDocument = (SolidEdgeAssembly.AssemblyDocument)application.ActiveDocument; // Start walking the assembly tree. ProcessAssembly(0, assemblyDocument, bomItems); } else { throw new System.Exception("No assembly open."); } } catch (System.Runtime.InteropServices.COMException ex) { if (ex.ErrorCode == -2147221021 /* MK_E_UNAVAILABLE */) { throw new System.Exception("Solid Edge is not running."); } else { throw; } } catch { throw; } finally { } return(bomItems.Values.ToArray()); }
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; SolidEdgeAssembly.AssemblyDocument document = null; SolidEdgeAssembly.Configurations configurations = null; SolidEdgeAssembly.Configuration configuration = 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 assembly document. document = application.GetActiveDocument <SolidEdgeAssembly.AssemblyDocument>(false); if (document != null) { // Get a reference to the Configurations collection. configurations = document.Configurations; // Configuration name has to be unique so for demonstration // purposes, use a random number. Random random = new Random(); string configName = String.Format("Configuration {0}", random.Next()); configuration = configurations.Item(1); object configList = new string[] { configuration.Name }; object missing = Missing.Value; // NOTE: Not sure why but this is causing Solid Edge ST6 to crash. // Add the new configuration. configuration = configurations.AddDerivedConfig(1, 0, 0, ref configList, ref missing, ref missing, configName); } 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; 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 PopulateBom(int level, SolidEdgeAssembly.AssemblyDocument assemblyDocument, BomItem parentBomItem) { // Increment level (depth). level++; // This sample BOM is not exploded. Define a dictionary to store unique occurrences. Dictionary <string, SolidEdgeAssembly.Occurrence> uniqueOccurrences = new Dictionary <string, SolidEdgeAssembly.Occurrence>(); // Populate the unique occurrences dictionary. foreach (SolidEdgeAssembly.Occurrence occurrence in assemblyDocument.Occurrences) { // To make sure nothing silly happens with our dictionary key, force the file path to lowercase. var lowerFileName = occurrence.OccurrenceFileName.ToLower(); // If the dictionary does not already contain the occurrence, add it. if (uniqueOccurrences.ContainsKey(lowerFileName) == false) { uniqueOccurrences.Add(lowerFileName, occurrence); } } // Loop through the unique occurrences. foreach (SolidEdgeAssembly.Occurrence occurrence in uniqueOccurrences.Values.ToArray()) { // Filter out certain occurrences. if (!occurrence.IncludeInBom) { continue; } if (occurrence.IsPatternItem) { continue; } if (occurrence.OccurrenceDocument == null) { continue; } // Create an instance of the child BomItem. var bomItem = new BomItem(occurrence, level); // Add the child BomItem to the parent. parentBomItem.Children.Add(bomItem); if (bomItem.IsSubassembly == true) { // Sub Assembly. Recurisve call to drill down. PopulateBom(level, (SolidEdgeAssembly.AssemblyDocument)occurrence.OccurrenceDocument, bomItem); } } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeAssembly.AssemblyDocument assemblyDocument = null; SolidEdgeAssembly.Configurations configurations = null; SolidEdgeAssembly.Configuration configuration = 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 refrence to the active assembly document. assemblyDocument = application.GetActiveDocument <SolidEdgeAssembly.AssemblyDocument>(false); if (assemblyDocument != null) { // Get a reference tot he Configurations collection. configurations = assemblyDocument.Configurations; // Configuration name has to be unique so for demonstration // purposes, use a random number. Random random = new Random(); string configName = String.Format("Configuration {0}", random.Next()); // Add the new configuration. configuration = configurations.Add(configName); // Make the new configuration the active configuration. configuration.Apply(); } 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; SolidEdgeAssembly.Occurrences occurrences = null; SolidEdgeAssembly.Occurrence occurrence = 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 assembly document. assemblyDocument = documents.AddAssemblyDocument(); // Always a good idea to give SE a chance to breathe. application.DoIdle(); // Get a reference to the Occurrences collection. occurrences = assemblyDocument.Occurrences; // Build path to file. string filename = System.IO.Path.Combine(SolidEdgeCommunity.SolidEdgeUtils.GetTrainingFolderPath(), "Coffee Pot.par"); // Add the base feature at 0 (X), 0 (Y), 0 (Z). occurrence = occurrences.AddByFilename(filename); // Switch to ISO view. application.StartCommand(SolidEdgeConstants.AssemblyCommandConstants.AssemblyViewISOView); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeAssembly.AssemblyDocument assemblyDocument = null; SolidEdgeAssembly.Configurations configurations = 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 active assembly document. assemblyDocument = application.GetActiveDocument <SolidEdgeAssembly.AssemblyDocument>(false); if (assemblyDocument != null) { // Get a reference tot he Configurations collection. configurations = assemblyDocument.Configurations; // Iterate through all of the configurations. foreach (SolidEdgeAssembly.Configuration configuration in configurations.OfType <SolidEdgeAssembly.Configuration>()) { Console.WriteLine("Configuration Name: '{0}' | Configuration Type: {1}.", configuration.Name, configuration.ConfigurationType); } } else { throw new System.Exception("No active document."); } } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
static void PopulateBom(int level, SolidEdgeAssembly.AssemblyDocument assemblyDocument, BomItem parentBomItem) { // Increment level (depth). level++; // This sample BOM is not exploded. Define a dictionary to store unique occurrences. //Dictionary<string, SolidEdgeAssembly.Occurrence> uniqueOccurrences = new Dictionary<string, SolidEdgeAssembly.Occurrence>(); // Loop through the unique occurrences. foreach (SolidEdgeAssembly.Occurrence occurrence in assemblyDocument.Occurrences) // uniqueOccurrences.Values.ToArray()) { // Filter out certain occurrences. if (!occurrence.IncludeInBom) { continue; } if (occurrence.IsPatternItem) { continue; } if (occurrence.OccurrenceDocument == null) { continue; } // Create an instance of the child BomItem. var bomItem = new BomItem(occurrence, level); // Add the child BomItem to the parent. parentBomItem.Children.Add(bomItem); if (bomItem.IsSubassembly == true) { // Sub Assembly. Recurisve call to drill down. PopulateBom(level, (SolidEdgeAssembly.AssemblyDocument)occurrence.OccurrenceDocument, bomItem); } } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgeAssembly.AssemblyDocument assemblyDocument = 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 assembly document using PROGID. assemblyDocument = (SolidEdgeAssembly.AssemblyDocument)documents.Add("SolidEdge.AssemblyDocument"); // Create a new assembly document using PROGID defined in Interop.SolidEdge.dll. assemblyDocument = (SolidEdgeAssembly.AssemblyDocument)documents.Add(SolidEdgeSDK.PROGID.SolidEdge_AssemblyDocument); // Create a new assembly document using SolidEdge.Community.dll extension method. assemblyDocument = documents.AddAssemblyDocument(); // Create a new assembly document using SolidEdge.Community.dll extension method. assemblyDocument = documents.Add <SolidEdgeAssembly.AssemblyDocument>(); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
static void AddStructuralFrame(SolidEdgeAssembly.AssemblyDocument assemblyDocument) { SolidEdgeAssembly.LineSegments lineSegments = null; SolidEdgeAssembly.LineSegment lineSegment = null; List <SolidEdgeAssembly.LineSegment> lineSegmentList = new List <SolidEdgeAssembly.LineSegment>(); SolidEdgeAssembly.StructuralFrames structuralFrames = null; SolidEdgeAssembly.StructuralFrame structuralFrame = null; double[] startPoint = { 0.0, 0.0, 0.0 }; double[] endPoint = { 0.0, 0.0, 0.5 }; // Get a reference to the LineSegments collection. lineSegments = assemblyDocument.LineSegments; // Add a new line segment. lineSegment = lineSegments.Add( StartPoint: startPoint, EndPoint: endPoint); // Store line segment in array. lineSegmentList.Add(lineSegment); // Get a reference to the StructuralFrames collection. structuralFrames = assemblyDocument.StructuralFrames; // Build path to part file. In this case, it is a .par from standard install. string partFilePath = Path.Combine(GetSolidEdgeInstallPath(), @"Frames\DIN\I-Beam\I-Beam 80x46.par"); Console.WriteLine("Adding structural frame '{0}'.", partFilePath); // Add new structural frame. structuralFrame = structuralFrames.Add( PartFileName: partFilePath, NumPaths: lineSegmentList.Count, Path: lineSegmentList.ToArray()); }
public static void ReportVariables(SolidEdgeAssembly.AssemblyDocument document) { ReportVariables((SolidEdgeFramework.SolidEdgeDocument)document); }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeAssembly.AssemblyDocument 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 <SolidEdgeAssembly.AssemblyDocument>(false); // Make sure we have a document. if (document != null) { SolidEdgeFramework.Variables variables = null; SolidEdgeFramework.VariableList variableList = null; SolidEdgeFramework.variable variable = null; SolidEdgeFrameworkSupport.Dimension dimension = null; if (document == null) { throw new ArgumentNullException("document"); } // Get a reference to the Variables collection. variables = (SolidEdgeFramework.Variables)document.Variables; // Get a reference to the variablelist. variableList = (SolidEdgeFramework.VariableList)variables.Query( pFindCriterium: "*", NamedBy: SolidEdgeConstants.VariableNameBy.seVariableNameByBoth, VarType: SolidEdgeConstants.VariableVarType.SeVariableVarTypeBoth); // Process variables. foreach (var variableListItem in variableList.OfType <object>()) { // Not used in this sample but a good example of how to get the runtime type. var variableListItemType = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetType(variableListItem); // Use helper class to get the object type. var objectType = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetPropertyValue <SolidEdgeFramework.ObjectType>(variableListItem, "Type", (SolidEdgeFramework.ObjectType) 0); // Process the specific variable item type. switch (objectType) { case SolidEdgeFramework.ObjectType.igDimension: // Get a reference to the dimension. dimension = (SolidEdgeFrameworkSupport.Dimension)variableListItem; Console.WriteLine("Dimension: '{0}' = '{1}' ({2})", dimension.DisplayName, dimension.Value, objectType); break; case SolidEdgeFramework.ObjectType.igVariable: variable = (SolidEdgeFramework.variable)variableListItem; Console.WriteLine("Variable: '{0}' = '{1}' ({2})", variable.DisplayName, variable.Value, objectType); break; default: // Other SolidEdgeConstants.ObjectType's may exist. break; } } } else { throw new System.Exception("No active document."); } } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
public static void SaveAsJT(SolidEdgeAssembly.AssemblyDocument document) { SaveAsJT((SolidEdgeFramework.SolidEdgeDocument)document); }
/// <summary> /// Returns a collection of variables for the referenced document. /// </summary> /// <param name="document"></param> /// <returns></returns> public static SolidEdgeFramework.Variables GetVariables(this SolidEdgeAssembly.AssemblyDocument 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 SolidEdgeAssembly.AssemblyDocument 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 SolidEdgeAssembly.AssemblyDocument document) { return(document.Properties as SolidEdgeFramework.PropertySets); }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgeAssembly.AssemblyDocument assemblyDocument = null; SolidEdgeAssembly.LineSegments lineSegments = null; SolidEdgeAssembly.LineSegment lineSegment = null; List <SolidEdgeAssembly.LineSegment> lineSegmentList = new List <SolidEdgeAssembly.LineSegment>(); SolidEdgeAssembly.StructuralFrames structuralFrames = null; SolidEdgeAssembly.StructuralFrame structuralFrame = null; SolidEdgeFramework.SelectSet selectSet = null; Array startPointArray = new double[] { 0.0, 0.0, 0.0 }; Array endPointArray = new double[] { 0.0, 0.0, 0.5 }; 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 assembly document. assemblyDocument = documents.AddAssemblyDocument(); // Always a good idea to give SE a chance to breathe. application.DoIdle(); // Get a reference to the LineSegments collection. lineSegments = assemblyDocument.LineSegments; // Add a new line segment. lineSegment = lineSegments.Add( StartPoint: ref startPointArray, EndPoint: ref endPointArray); // Store line segment in array. lineSegmentList.Add(lineSegment); // Get a reference to the StructuralFrames collection. structuralFrames = assemblyDocument.StructuralFrames; // Build path to part file. In this case, it is a .par from standard install. string filename = System.IO.Path.Combine(SolidEdgeCommunity.SolidEdgeUtils.GetInstalledPath(), @"Frames\DIN\I-Beam\I-Beam 80x46.par"); // Add new structural frame. structuralFrame = structuralFrames.Add( PartFileName: filename, NumPaths: lineSegmentList.Count, Path: lineSegmentList.ToArray()); // Close the Frame environment. application.StartCommand(SolidEdgeConstants.AssemblyCommandConstants.AssemblyEnvironmentsExit); // Get a reference to the ActiveSelectSet. selectSet = application.ActiveSelectSet; // Add the StructuralFrame to the select set. selectSet.Add(structuralFrame); // Switch to ISO view. application.StartCommand(SolidEdgeConstants.AssemblyCommandConstants.AssemblyViewISOView); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
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(); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeAssembly.AssemblyDocument assemblyDocument = null; SolidEdgeAssembly.Occurrences occurrences = null; SolidEdgeAssembly.InterferenceStatusConstants interferenceStatus; SolidEdgeConstants.InterferenceComparisonConstants compare = SolidEdgeConstants.InterferenceComparisonConstants.seInterferenceComparisonSet1vsAllOther; SolidEdgeConstants.InterferenceReportConstants reportType = SolidEdgeConstants.InterferenceReportConstants.seInterferenceReportPartNames; 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 assembly document. assemblyDocument = application.GetActiveDocument <SolidEdgeAssembly.AssemblyDocument>(false); if (assemblyDocument != null) { // Get a reference to the Occurrences collection. occurrences = assemblyDocument.Occurrences; foreach (var occurrence in occurrences.OfType <SolidEdgeAssembly.Occurrence>()) { Array set1 = Array.CreateInstance(occurrence.GetType(), 1); object numInterferences = 0; object retSet1 = Array.CreateInstance(typeof(SolidEdgeAssembly.Occurrence), 0); object retSet2 = Array.CreateInstance(typeof(SolidEdgeAssembly.Occurrence), 0); object confirmedInterference = null; object interferenceOccurrence = null; set1.SetValue(occurrence, 0); // Check interference. assemblyDocument.CheckInterference( NumElementsSet1: set1.Length, Set1: ref set1, Status: out interferenceStatus, ComparisonMethod: compare, NumElementsSet2: 0, Set2: Missing.Value, AddInterferenceAsOccurrence: false, ReportFilename: Missing.Value, ReportType: reportType, NumInterferences: out numInterferences, InterferingPartsSet1: ref retSet1, InterferingPartsOtherSet: ref retSet2, ConfirmedInterference: ref confirmedInterference, InterferenceOccurrence: out interferenceOccurrence, IgnoreThreadInterferences: Missing.Value ); // Process status. switch (interferenceStatus) { case SolidEdgeAssembly.InterferenceStatusConstants.seInterferenceStatusNoInterference: break; case SolidEdgeAssembly.InterferenceStatusConstants.seInterferenceStatusConfirmedAndProbableInterference: case SolidEdgeAssembly.InterferenceStatusConstants.seInterferenceStatusConfirmedInterference: case SolidEdgeAssembly.InterferenceStatusConstants.seInterferenceStatusIncompleteAnalysis: case SolidEdgeAssembly.InterferenceStatusConstants.seInterferenceStatusProbableInterference: if (retSet2 != null) { for (int j = 0; j < (int)numInterferences; j++) { object obj1 = ((Array)retSet1).GetValue(j); object obj2 = ((Array)retSet2).GetValue(j); // Use helper class to get the object type. var objectType1 = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetPropertyValue <SolidEdgeFramework.ObjectType>(obj1, "Type", (SolidEdgeFramework.ObjectType) 0); var objectType2 = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetPropertyValue <SolidEdgeFramework.ObjectType>(obj2, "Type", (SolidEdgeFramework.ObjectType) 0); SolidEdgeFramework.Reference reference1 = null; SolidEdgeFramework.Reference reference2 = null; SolidEdgeAssembly.Occurrence occurrence1 = null; SolidEdgeAssembly.Occurrence occurrence2 = null; switch (objectType1) { case SolidEdgeFramework.ObjectType.igReference: reference1 = (SolidEdgeFramework.Reference)obj1; break; case SolidEdgeFramework.ObjectType.igPart: case SolidEdgeFramework.ObjectType.igOccurrence: occurrence1 = (SolidEdgeAssembly.Occurrence)obj1; break; } switch (objectType2) { case SolidEdgeFramework.ObjectType.igReference: reference2 = (SolidEdgeFramework.Reference)obj2; break; case SolidEdgeFramework.ObjectType.igPart: case SolidEdgeFramework.ObjectType.igOccurrence: occurrence2 = (SolidEdgeAssembly.Occurrence)obj2; break; } } } 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; SolidEdgeAssembly.AssemblyDocument assemblyDocument = null; SolidEdgeAssembly.Occurrences occurrences = null; SolidEdgeAssembly.Occurrence occurrence = null; string[] filenames = { "strainer.asm", "handle.par" }; // Jagged array // {OriginX, OriginY, OriginZ, AngleX, AngleY, AngleZ} // Origin in meters. // Angle in radians. double[][] transforms = new double[][] { new double[] { 0, 0, 0.02062, 0, 0, 0 }, new double[] { -0.06943, -0.00996, 0.05697, 0, 0, 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 documents collection. documents = application.Documents; // Create a new assembly document. assemblyDocument = documents.AddAssemblyDocument(); // Always a good idea to give SE a chance to breathe. application.DoIdle(); // Get a reference to the Occurrences collection. occurrences = assemblyDocument.Occurrences; // Get path to Solid Edge training directory. Typically, 'C:\Program Files\Solid Edge XXX\Training'. DirectoryInfo trainingDirectory = new DirectoryInfo(SolidEdgeCommunity.SolidEdgeUtils.GetTrainingFolderPath()); // Add each occurrence in array. for (int i = 0; i < transforms.Length; i++) { // Build path to file. string filename = Path.Combine(trainingDirectory.FullName, filenames[i]); // Add the new occurrence using a transform. occurrence = occurrences.AddWithTransform( OccurrenceFileName: filename, OriginX: transforms[i][0], OriginY: transforms[i][1], OriginZ: transforms[i][2], AngleX: transforms[i][3], AngleY: transforms[i][4], AngleZ: transforms[i][5]); } // Switch to ISO view. application.StartCommand(SolidEdgeConstants.AssemblyCommandConstants.AssemblyViewISOView); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
static void OuvrirAsm(string fname) { //string fName = @"K:\PROJET_IMAGE_WEB\PORTE_2016\P-04A\32X73\P04.asm"; Console.WriteLine("Creation de document test"); documents = application.Documents; assembly = (SolidEdgeAssembly.AssemblyDocument)documents.Open(fname); SolidEdgeFramework.Window window = (SolidEdgeFramework.Window)application.ActiveWindow; window.View.Fit(); SaveAsImage(window, Path.GetDirectoryName(fname)); assembly.Save(); assembly.Close(); documents.Close(); Marshal.FinalReleaseComObject(documents); documents = null; application.DoIdle(); }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgeAssembly.AssemblyDocument assemblyDocument = null; SolidEdgeAssembly.Occurrences occurrences = null; SolidEdgeAssembly.Occurrence occurrence = null; // A single-dimension array that defines a valid transformation matrix. double[] matrix = { 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.07913, 1.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 documents collection. documents = application.Documents; // Create a new assembly document. assemblyDocument = documents.AddAssemblyDocument(); // Always a good idea to give SE a chance to breathe. application.DoIdle(); // Build path to part file. string filename = System.IO.Path.Combine(SolidEdgeCommunity.SolidEdgeUtils.GetTrainingFolderPath(), "Strap Handle.par"); // Get a reference to the Occurrences collection. occurrences = assemblyDocument.Occurrences; // Convert from double[] to System.Array. Array matrixArray = matrix; // Add the new occurrence using a matrix. occurrence = occurrences.AddWithMatrix( OccurrenceFileName: filename, Matrix: ref matrixArray); // Switch to ISO view. application.StartCommand(SolidEdgeConstants.AssemblyCommandConstants.AssemblyViewISOView); } 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; SolidEdgeAssembly.Occurrences occurrences = null; SolidEdgeAssembly.Tube tube = 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); try { // Get the active document. assemblyDocument = application.GetActiveDocument <SolidEdgeAssembly.AssemblyDocument>(false); } catch { } // If there is not an active assembly, we can use an assembly from the training folder. if (assemblyDocument == null) { documents = application.Documents; // Build path to part file. string filename = System.IO.Path.Combine(SolidEdgeCommunity.SolidEdgeUtils.GetTrainingFolderPath(), @"Try It\zone_try_it.asm"); assemblyDocument = (SolidEdgeAssembly.AssemblyDocument)documents.Open(filename); } if (assemblyDocument != null) { // Get a reference to the Occurrences collection. occurrences = assemblyDocument.Occurrences; foreach (var occurrence in occurrences.OfType <SolidEdgeAssembly.Occurrence>()) { if (occurrence.IsTube()) { tube = occurrence.GetTube(); Console.WriteLine("Occurrences[{0}] is a tube.", occurrence.Index); Console.WriteLine("PartFileName: {0}", tube.PartFileName); object CutLength = 0.0; object NumOfBends = 0; object FeedLengthArray = new double[] { }; object RotationAngleArray = new double[] { }; object BendRadiusArray = new double[] { }; object ReverseBendOrder = 0; object SaveToFileName = Missing.Value; object BendAngleArray = new double[] { }; tube.BendTable( CutLength: out CutLength, NumOfBends: out NumOfBends, FeedLength: out FeedLengthArray, RotationAngle: out RotationAngleArray, BendRadius: out BendRadiusArray, ReverseBendOrder: ref ReverseBendOrder, SaveToFileName: SaveToFileName, BendAngle: out BendAngleArray); StringBuilder FeedLength = new StringBuilder(); foreach (double d in (double[])FeedLengthArray) { FeedLength.AppendFormat("{0}, ", d); } StringBuilder RotationAngle = new StringBuilder(); foreach (double d in (double[])RotationAngleArray) { RotationAngle.AppendFormat("{0}, ", d); } StringBuilder BendRadius = new StringBuilder(); foreach (double d in (double[])BendRadiusArray) { BendRadius.AppendFormat("{0}, ", d); } StringBuilder BendAngle = new StringBuilder(); foreach (double d in (double[])BendAngleArray) { BendAngle.AppendFormat("{0}, ", d); } Console.WriteLine("BendTable information:"); Console.WriteLine("CutLength: {0}", CutLength); Console.WriteLine("NumOfBends: {0}", NumOfBends); Console.WriteLine("FeedLength: {0}", FeedLength.ToString().Trim().TrimEnd(',')); Console.WriteLine("RotationAngle: {0}", RotationAngle.ToString().Trim().TrimEnd(',')); Console.WriteLine("BendRadius: {0}", BendRadius.ToString().Trim().TrimEnd(',')); Console.WriteLine("BendAngle: {0}", BendAngle.ToString().Trim().TrimEnd(',')); Console.WriteLine(); } } } else { throw new System.Exception("No active document."); } } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
/// <summary> /// Returns the version of Solid Edge that was used to create the referenced document. /// </summary> /// <param name="document"></param> /// <returns></returns> public static Version GetCreatedVersion(this SolidEdgeAssembly.AssemblyDocument document) { return(new Version(document.CreatedVersion)); }
/// <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 SolidEdgeAssembly.AssemblyDocument document) { return(new Version(document.LastSavedVersion)); }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeAssembly.AssemblyDocument document = null; try { // Register with OLE to handle concurrency issues on the current thread. SolidEdgeCommunity.OleMessageFilter.Register(); // Connect to Solid Edge. application = SolidEdgeCommunity.SolidEdgeUtils.Connect(true, true); // Get a reference to the active document. document = application.GetActiveDocument <SolidEdgeAssembly.AssemblyDocument>(false); if (document != null) { // Note: Some of the parameters are obvious by their name but we need to work on getting better descriptions for some. var NewName = String.Empty; var Include_PreciseGeom = 0; var Prod_Structure_Option = 1; var Export_PMI = 0; var Export_CoordinateSystem = 0; var Export_3DBodies = 0; var NumberofLODs = 1; var JTFileUnit = 0; var Write_Which_Files = 1; var Use_Simplified_TopAsm = 0; var Use_Simplified_SubAsm = 0; var Use_Simplified_Part = 0; var EnableDefaultOutputPath = 0; var IncludeSEProperties = 0; var Export_VisiblePartsOnly = 0; var Export_VisibleConstructionsOnly = 0; var RemoveUnsafeCharacters = 0; var ExportSEPartFileAsSingleJTFile = 0; if (document == null) { throw new ArgumentNullException("document"); } switch (document.Type) { case SolidEdgeFramework.DocumentTypeConstants.igAssemblyDocument: case SolidEdgeFramework.DocumentTypeConstants.igPartDocument: case SolidEdgeFramework.DocumentTypeConstants.igSheetMetalDocument: case SolidEdgeFramework.DocumentTypeConstants.igWeldmentAssemblyDocument: case SolidEdgeFramework.DocumentTypeConstants.igWeldmentDocument: NewName = System.IO.Path.ChangeExtension(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), document.Name), ".jt"); document.SaveAsJT( NewName, Include_PreciseGeom, Prod_Structure_Option, Export_PMI, Export_CoordinateSystem, Export_3DBodies, NumberofLODs, JTFileUnit, Write_Which_Files, Use_Simplified_TopAsm, Use_Simplified_SubAsm, Use_Simplified_Part, EnableDefaultOutputPath, IncludeSEProperties, Export_VisiblePartsOnly, Export_VisibleConstructionsOnly, RemoveUnsafeCharacters, ExportSEPartFileAsSingleJTFile); break; default: throw new System.Exception(String.Format("'{0}' cannot be converted to JT.", document.Type)); } } else { throw new System.Exception("No active document."); } } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }