簡體   English   中英

從solidworks獲取自定義材料

[英]Getting custom materials from solidworks

首先注意我的計算機上沒有安裝solidworks,但是將這些文件用於項目。

Solidworks能夠為文件屬性創建自定義選項卡。 在此選項卡中,您可以找到有關在solidworks中制作的模型(零件)的所有類型的信息。

我讀出所有這些信息並將其存儲在.txt文件中,見圖像。 在此信息中,您可以找到我的問題所在的零件的材料類型。 在此輸入圖像描述

我知道材質類型,但在solidworks中,用戶還可以將custom materials指定給custom materials定義屬性中定義的材質。 例如,材料只是普通木材,但用戶希望這種木材是粉紅色的。

是否可以讀出custom materials附加到材料中的自定義屬性?

如果您沒有安裝SOLIDWORKS,則可以使用文檔管理器 (需要有效的SOLIDWORKS訂閱來獲取密鑰)來訪問自定義屬性:

String sLicenseKey = "Your key from SOLIDWORKS";
SwDmDocumentOpenError nRetVal = 0;
SwDmCustomInfoType customInfoType;
SwDMClassFactory swClassFact = new SwDMClassFactory();
SwDMApplication swDocMgr = (SwDMApplication)swClassFact.GetApplication(sLicenseKey);
SwDMDocument17 swDoc = (SwDMDocument17)swDocMgr.GetDocument("C:\Filepath", SwDmDocumentType.swDmDocumentPart, false, out nRetVal);
SwDMConfigurationMgr swCfgMgr = swDoc.ConfigurationManager;
SwDMConfiguration14 swCfg = (SwDMConfiguration14)swCfgMgr.GetConfigurationByName("Config Name");
String materialProperty = swCfg.GetCustomProperty2("Property Name", out customInfoType);

要閱讀材料屬性,請嘗試:

ModelDoc2 swModel = (ModelDoc2)swApp.ActiveDoc;
PartDoc swPart = (PartDoc)swModel;
double[] propertyValues = swPart.MaterialPropertyValues;

根據SOLIDWORKS文檔

材料值包括顏色(R,G,B值),反射率(環境,漫反射,鏡面反射,光澤度),透明度和發射。

參數或返回值的格式是雙精度數組,如下所示:[R,G,B,Ambient,Diffuse,Specular,Shininess,Transparency,Emission]

所有元素必須在0到1的范圍內。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM