SolidEdge二開程式-材質同步到自訂性質Material to Custom
公司內部最近有需求
要將材質同步到自訂性質內
因為SolidEdge做不到,所以只好用二次開發的方式進行
這部分材質也是性質的一部分,所以可以參考下面連結:
https://timshyue.com/solidedge-api-property-%e6%8a%93%e5%8f%96%e6%80%a7%e8%b3%aa/
Material to Custom
範例如下:
SolidEdgeFramework.Application seApplication = null;
SolidEdgeFramework.Documents seDocuments = null;
SolidEdgePart.PartDocument sePartDoc = null;
SolidEdgeFramework.PropertySets propertySets = null;
SolidEdgeFramework.Properties MechanicalModeling = null;
SolidEdgeFramework.Properties Custom = null;
try
{
seApplication = (SolidEdgeFramework.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("SolidEdge.Application");
seDocuments = seApplication.Documents;
sePartDoc = (SolidEdgePart.PartDocument)seApplication.ActiveDocument;
sePartDoc.Save();//先存檔,防止後面因為增加時失敗
propertySets = (SolidEdgeFramework.PropertySets)sePartDoc.Properties;
MechanicalModeling = propertySets.Item("MechanicalModeling");
string Material = ((dynamic)MechanicalModeling.Item("Material")).Value(); //因為get_value無法使用,所以換一種方式
Custom = propertySets.Item("Custom");
Custom.Add("材質2", Material);//性質名稱,可以改成自己喜歡的
Custom.Save();
sePartDoc.Save();
}
catch (Exception ee)
{
MessageBox.Show(ee.Message);
}
finally
{
}
功能說明:
此程式會進行存檔與同步零件的 材質名稱 到 自訂性質
![Material to Custom
材質同步到自訂性質](https://timshyue.tk/wp-content/uploads/2019/08/Material-to-Custom.png)
材質同步到自訂性質
只有零件有材質!!!這部分要注意
“材質2″的這部分可以自己改成自己喜歡的喔
參考:
https://blogs.sw.siemens.com/solidedge/the-myriad-of-solid-edge-file-properties-apis/