public void 添加技术要求()
{
ModelDoc2 swModel = (ModelDoc2)this.sldWorks.ActiveDoc;
var ConfigNames = (string[])swModel.GetConfigurationNames();
Configuration swConfig = null;
var configName = ConfigNames[0];
swConfig = (Configuration)swModel.GetConfigurationByName(configName);
this.manger = swModel.Extension.CustomPropertyManager[configName];
object vPropNames = null;
object vPropTypes = null;
object vPropValues = null;
object[] propValues;
object resolved = null;
object linkProp = null;
var nNbrProps = manger.Count;
manger.GetAll3(ref vPropNames, ref vPropTypes, ref vPropValues, ref resolved, ref linkProp);
propValues = (object[])vPropValues;
var propNames = (string[])vPropNames;
manger.Add3("技术要求1", (int)swCustomInfoType_e.swCustomInfoText, "去除毛刺;", (int)swCustomPropertyAddOption_e.swCustomPropertyReplaceValue);
manger.Add3("技术要求2", (int)swCustomInfoType_e.swCustomInfoText, "表面无锈蚀、无污渍;", (int)swCustomPropertyAddOption_e.swCustomPropertyReplaceValue);
manger.Add3("技术要求3", (int)swCustomInfoType_e.swCustomInfoText, "表面不允许有划伤、凹坑等缺陷;", (int)swCustomPropertyAddOption_e.swCustomPropertyReplaceValue);
manger.Add3("技术要求4", (int)swCustomInfoType_e.swCustomInfoText, "未注公差按GB/T1804-M级执行。", (int)swCustomPropertyAddOption_e.swCustomPropertyReplaceValue);
if (this.存货名称 != null && this.物料号 != null)
{
manger.Add3("名称", (int)swCustomInfoType_e.swCustomInfoText, this.存货名称.Replace(this.物料号, "").Replace("-", ""), (int)swCustomPropertyAddOption_e.swCustomPropertyReplaceValue);
manger.Add3("图号", (int)swCustomInfoType_e.swCustomInfoText, this.物料号, (int)swCustomPropertyAddOption_e.swCustomPropertyReplaceValue);
}
}
c# solidworks 添加自定义属性
最新推荐文章于 2024-09-23 22:10:12 发布