using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Runtime.InteropServices; using System.Reflection; using SolidEdgeFramework; using SolidEdgeFileProperties; using SolidEdgeAssembly; using SolidEdgePart; using SolidEdgeFrameworkSupport; namespace Stuecklisten_Tool_V_1_00 { class Program { static void Main(string[] args) { SolidEdgeFramework.Application application=null; SolidEdgeFramework.Documents documents = null; SolidEdgeAssembly.AssemblyDocument assembly = null; SolidEdgeAssembly.Occurrences occurrences = null; //SolidEdgeAssembly.Occurrence objOccurrence =null; SolidEdgePart.PartDocument objSEDocument =null; //SolidEdgeFileProperties.PropertySets propertySets =null; //SolidEdgeFileProperties.Properties properties= null; //SolidEdgeFileProperties.Property property =null; // define Bom-Array string[][] BOM; // counter vars int i; //BOM-row-number int j; //fill assembly information in array // Connect to a running instance of Solid Edge application = (SolidEdgeFramework.Application) Marshal.GetActiveObject("SolidEdge.Application"); // Ausgabe der Verbindungsbestätgung in der Console. Console.WriteLine("Mit SolideEdge verbunden!"); Console.ReadLine(); // Get a Reference to the documents collection documents = application.Documents; // Get a Reference to the ActiveDocument // and show the name assembly= (SolidEdgeAssembly.AssemblyDocument) application.ActiveDocument; // Get reference to the occurrences collection occurrences = assembly.Occurrences; // count all occurrences // define size of Bom-array i = occurrences.Count; BOM = new string[i][]; //fill Bom with assemblyinformation of all occurences for (j = 1; j <= i; j++) { BOM[j-1] = new string[6]; //write occurence name in array --> ROW 1 BOM[j-1][1] = occurrences.Item(j).Name; //write occurence number in array --> ROW 2 BOM[j-1][2] = Convert.ToString(occurrences.Item(j).Quantity); // write path in array --> ROW 3 BOM[j-1][3] = occurrences.Item(j).OccurrenceFileName; // write material in array --> ROW 4 objSEDocument = (SolidEdgePart.PartDocument) occurrences.Item(j).OccurrenceDocument; BOM[j-1][4] = objSEDocument.Properties("MechanicalModeling").Item("Material").value; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)