獲取鈑金件厚度

????????在處理鈑金件的時候,有時需要提取鈑金件厚度的情況,獲取方式一般有兩種,一種是通過切割清單,還有一種是通過鈑金特征獲取厚度值,這里我推薦后者。
廢話不多說,直接上代碼:
????Dim swApp As SldWorks.SldWorks
? ? Dim swModel As SldWorks.ModelDoc2
? ? Dim swSelMgr As SldWorks.SelectionMgr
? ? Dim swFeat As SldWorks.Feature
? ? Dim featMgr As SldWorks.FeatureManager
? ? Dim swFeatm() As Object
? ? Dim fa As Variant
? ? Dim boolstatus As Boolean
????Set swApp = CreateObject("SldWorks.Application")
? ? Set swModel = swApp.ActiveDoc
? ? Set featMgr = swModel.FeatureManager
? ? swFeatm = featMgr.GetFeatures(False)
? ? Set swSelMgr = swModel.SelectionManager
? ? ? ? For Each fa In swFeatm'遍歷到鈑金特征
? ? ? ? ? ? If Left(fa.Name, 2) = "基體" Then
? ? ? ? ? ? ? ? boolstatus = swModel.Extension.SelectByID2(fa.Name, "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)
? ? ? ? ? ? ? ? Exit For
? ? ? ? ? ? End If
? ? ? ? Next
? ? ? ? Set swFeat = swSelMgr.GetSelectedObject(1)
? ? ? ? swModel.ClearSelection2 True
? ? ? ? Set swfeaturedata = swFeat.GetDefinition'這個GetDefinition里有許多東西可以獲取,不僅限于厚度
? ? ? ? Thickness = swfeaturedata.Thickness'獲取厚度
獲得厚度后就可以寫入到屬性里,供你索取。

如果有更好的方法或者想法可以私聊~~
