不用跪,喜歡拿去~~
- Dim swApp As SldWorks.SldWorks
- Dim swModel As ModelDoc2
- Dim swCustProp As CustomPropertyManager
- Dim val As String
- Dim valout As String
- Dim bool As Boolean
-
- Sub main()
- Set swApp = Application.SldWorks
- Set swModel = swApp.ActiveDoc
- Set swCustProp = swModel.Extension.CustomPropertyManager("")
- bool = swCustProp.Get4("材質", True, val, valout) '獲取"材質"的數值
- mat = Left(valout, InStr(valout, "/") - 1)
- fin = Right(valout, Len(valout) - Len(mat) - 1)
- '寫入材質和表面處理的屬性
- retval = swApp.ActiveDoc.DeleteCustomInfo2("", "Material")
- retval = swApp.ActiveDoc.AddCustomInfo3("", "Material", swCustomInfoText, mat)
- retval = swApp.ActiveDoc.DeleteCustomInfo2("", "Finishing")
- retval = swApp.ActiveDoc.AddCustomInfo3("", "Finishing", swCustomInfoText, fin)
- MsgBox "Done!"
- End Sub
复制代码
|