!!!開發時必需使用64位元編譯!!!
可以使用
1. (離線抓取方式)SolidEdgeFileProperties.PropertySets
2. (在線抓取方式)SolidEdgeFramework.PropertySets
使用 SolidEdgeFileProperties.PropertySets 的範例:
/*全部*/ SolidEdgeFileProperties.PropertySets filePropertySets; filePropertySets = new PropertySets(); try { filePropertySets.Open(@"D:\Part1.par", System.IO.FileShare.ReadWrite); }catch (System.Runtime.InteropServices.COMException see) { Console.WriteLine(see.Message + see.ToString()); } foreach (SolidEdgeFileProperties.Properties Properties in filePropertySets) { foreach (SolidEdgeFileProperties.Property item in Properties) { object Value = item.Value; object ID = item.ID; object Name = item.Name; /*--------------------------------*/ } }
/*個別標籤(例如自訂性質)*/ SolidEdgeFileProperties.PropertySets filePropertySets; SolidEdgeFileProperties.Properties fileProperties; filePropertySets = new PropertySets(); try{ filePropertySets.Open(@"D:\Part1.par", System.IO.FileShare.ReadWrite); }catch (System.Runtime.InteropServices.COMException see) { Console.WriteLine(see.Message + see.ToString()); } fileProperties = (SolidEdgeFileProperties.Properties)filePropertySets["Custom"]; // Use ["Custom"] foreach (SolidEdgeFileProperties.Property item in fileProperties) { object Value = item.Value; object ID = item.ID; object Name = item.Name; }
使用 SolidEdgeFramework.PropertySets 的範例:
- Item(1) : SummaryInformation
- Item(2) : ExtendedSummaryInformation
- Item(3) : DocumentSummaryInformation
- Item(4) : Custom
- Item(5) : ProjectInformation
- Item(7) : MechanicalModeling
/* 注意! SolidEdge 必須是啟動狀態 */ /*範例一 全部 */ SolidEdgeFramework.Application application = null; SolidEdgeFramework.Window window = null; SolidEdgeFramework.View view = null; try { application = (SolidEdgeFramework.Application)Marshal.GetActiveObject("SolidEdge.Application"); //application.Documents.Open(@"D:\Part1.par"); // A 3D document must be open. window = application.ActiveWindow as SolidEdgeFramework.Window; SolidEdgeFramework.Documents seDocuments = application.Documents; SolidEdgePart.PartDocument seDocument = (SolidEdgePart.PartDocument)application.ActiveDocument; application.DoIdle(); SolidEdgeFramework.PropertySets propertySets = (SolidEdgeFramework.PropertySets)seDocument.Properties; foreach (SolidEdgeFramework.Properties Properties in propertySets) { foreach (SolidEdgeFramework.Property item in Properties) { string a = (string)item.get_Value(); //dynamic value = item.get_Value(); } } } catch (Exception) { throw; } /*範例二 個別 例如檔案基本資料*/ SolidEdgeFramework.Application application = null; SolidEdgeFramework.Window window = null; SolidEdgeFramework.View view = null; try { application = (SolidEdgeFramework.Application)Marshal.GetActiveObject("SolidEdge.Application"); //application.Documents.Open(@"D:\Part1.par"); // A 3D document must be open. window = application.ActiveWindow as SolidEdgeFramework.Window; SolidEdgeFramework.Documents seDocuments = application.Documents; SolidEdgePart.PartDocument seDocument = (SolidEdgePart.PartDocument)application.ActiveDocument; application.DoIdle(); SolidEdgeFramework.PropertySets propertySets = (SolidEdgeFramework.PropertySets)seDocument.Properties; SolidEdgeFramework.Properties Properties = propertySets.Item(1);//檔案基本資料 SolidEdgeFramework.Property properties = (SolidEdgeFramework.Property)Properties.Item(1); foreach (SolidEdgeFramework.Property item in Properties) { dynamic value = item.get_Value(); } } catch (Exception) { throw; }
參考:
https://community.plm.automation.siemens.com/t5/Solid-Edge-Blog/The-Myriad-of-Solid-Edge-File-Properties-APIs/ba-p/434400
在〈“solidedge-API-PropertySets抓取性質”〉中有 2 則留言
留言功能已關閉。