c# solidworks 添加自定义属性

    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);
           
        }
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值