资源描述:
《solidworks代号名称分离宏命令属性”自定义“或”配置特定“中》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、标准文档SolidWorks2014基于宏实现快速"图号名称"分离1.两类代码Ø代码1(内容添加至“自定义下”)DimswAppAsObjectDimPartAsObjectDimSelMgrAsObjectDimboolstatusAsBooleanDimlongstatusAsLong,longwarningsAsLongDimFeatureAsObjectDimaAsIntegerDimbAsStringDimmAsStringDimeAsStringDimkAsStringDimtAsStringDimcAsStringDimjAsIntegerDimstrmat
2、AsStringDimtempvalueAsStringSubmain()'linksolidworksSetswApp=Application.SldWorksSetPart=swApp.ActiveDocSetSelMgr=Part.SelectionManagerswApp.ActiveDoc.ActiveView.FrameState=1'设定变量c=swApp.ActiveDoc.GetTitle()'零件名实用文案标准文档strmat=Chr(34)+Trim("SW-Material"+"@")+c+Chr(34)blnretval=Part.DeleteC
3、ustomInfo2("","图样代号")blnretval=Part.DeleteCustomInfo2("","图样名称")blnretval=Part.DeleteCustomInfo2("","材料")a=InStr(c,"")-1'重点:分隔标识符,这里是一个空格,也可用其他符号区分Ifa>0Thenk=Left(c,a)t=Left(LTrim(e),3)Ift="GBT"Thene="GB/T"+Mid(k,4)Elsee=kEndIfb=Mid(c,a+2)t=Right(c,7)Ift=".SLDPRT"Ort=".SLDASM"Ort=".sldprt
4、"Ort=".sldasm"Thenj=Len(b)-7'消除后缀(区分大小写,即含4种)Elsej=Len(b)EndIfm=Left(b,j)EndIfblnretval=Part.AddCustomInfo3("","图样代号",swCustomInfoText,e)'代号blnretval=Part.AddCustomInfo3("","图样名称",swCustomInfoText,m)'名称blnretval=Part.AddCustomInfo3("","表面处理",swCustomInfoText,"")EndSubØ代码2(内容添加至“配置特定”下)'定义
5、sw实用文案标准文档DimaAsIntegerDimbAsStringDimmAsStringDimeAsStringDimkAsStringDimtAsStringDimcAsStringDimjAsIntegerDimstrmatAsStringDimtempvalueAsStringDimPartAsObjectDimswAppAsSldWorks.SldWorksDimswModelDocAsSldWorks.ModelDoc2DimswConfigAsSldWorks.ConfigurationDimCustPropMgrAsSldWorks.CustomPro
6、pertyManagerDimswModelAsSldWorks.ModelDoc2Submain()SetswApp=Application.SldWorksSetswModelDoc=swApp.ActiveDocSetswConfig=swModelDoc.ConfigurationManager.ActiveConfigurationSetswModel=swApp.ActiveDocSetCustPropMgr=swModel.Extension.CustomPropertyManager(swModel.ConfigurationManager.ActiveC
7、onfiguration.Name)'配置特定延伸'设定变量c=swApp.ActiveDoc.GetTitle()'零件名实用文案标准文档strmat=Chr(34)+Trim("SW-Material"+"@")+c+Chr(34)a=InStr(c,"")-1'重点:分隔标识符,这里是一个空格,也可换成其他符号Ifa>0Thenk=Left(c,a)t=Left(LTrim(e),3)Ift="GBT"Thene="GB/T"+Mid(k,4)Elsee=kEndIfb=Mid(c,a+2)t=Right(c,7)Ift