SolidEdge二開程式-抓取組立件的事例性質內之參數設定值

SolidEdge二開程式-抓取組立件的事例性質內之參數設定值

連接方式可以參考https://timshyue.com/solidedge-api-property-%e6%8a%93%e5%8f%96%e6%80%a7%e8%b3%aa/

本範例使用C#製作

!!!!! —- 只有組立件有事例性質 —- !!!!!

打開solidedge 並打開要設定的組立件

以下程式碼只對組立件有效!

範例:

try
{
    SolidEdgeFramework.Application seApplication = null;
    SolidEdgeFramework.Documents seDocuments = null;
    seApplication = (SolidEdgeFramework.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("SolidEdge.Application");
    seDocuments = seApplication.Documents;

    SolidEdgeAssembly.AssemblyDocument assembly = null;
    SolidEdgeAssembly.Occurrences occurrences = null;
    assembly = (SolidEdgeAssembly.AssemblyDocument)seApplication.ActiveDocument;

    occurrences = assembly.Occurrences;
    foreach (SolidEdgeAssembly.Occurrence Occurrence in occurrences)
    {
        string name = Occurrence.Name;

        bool IncludeInInterference = Occurrence.IncludeInInterference;//干涉分析
        bool IncludeInBom = Occurrence.IncludeInBom; // 報告/零件明細表
        bool IncludeInPhysicalProperties = Occurrence.IncludeInPhysicalProperties; //物理性質
        bool DisplayInDrawings = Occurrence.DisplayInDrawings; //圖紙視圖
        bool DisplayAsReference = Occurrence.DisplayAsReference; //工程圖參照
        int qty = Occurrence.Quantity; // 數量
        
        /*以下為自訂欄位可以參考
C:\Program Files\Siemens\Solid Edge 2019\Preferences\CustomOccurrenceProperty.xml
使用CustomPropertyValue 或 get_CustomPropertyValue 得到設定值

*/
        string value2 = Occurrence.CustomPropertyValue["自訂欄位的名稱"];
        string a = Occurrence.get_CustomPropertyValue("自訂欄位的名稱");


    }
}
catch (Exception e)
{
    MessageBox.Show(e.Message);
}

如果有自訂義欄位,可以參考電腦路徑:
C:\Program Files\Siemens\Solid Edge 2019\Preferences\CustomOccurrenceProperty.xml
進行編輯

如有設定,要記得點選事例性質內的”新增自訂事例性質”才會生效喔

要設定資料的話可以使用:

Occurrence.set_CustomPropertyValue("自訂欄位的名稱", "內容");


API可以參考:
https://support.industrysoftware.automation.siemens.com/training/se/107/api/SolidEdgeAssembly~Occurrence_members.html
https://docs.plm.automation.siemens.com/tdoc/se/2019/se_help/#uid:index#goto:assemble_parts:prtprp1d