|
發表於 2015/1/12 17:26:20
|
顯示全部樓層
不用解dll,這是solidworks官網裡面的範例,我在VB.NET 2013實作過,沒有問題
權限不夠不能發連結>_<,請自行google下面第一個就是了
Get Feature Type and Name Example (VB.NET)
程式碼如下(我改在Form下作大家比較容易懂):
Imports SolidWorks.Interop.sldworks
Public Class Form1
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim swApp As New SldWorks
Dim swModel As ModelDoc2
Dim swModelDocExt As ModelDocExtension
Dim swSelMgr As SelectionMgr
Dim swFeat As Feature
Dim featName As String, featType As String
swModel = swApp.ActiveDoc
swSelMgr = swModel.SelectionManager
swModelDocExt = swModel.Extension
' Get the selected feature
swFeat = swSelMgr.GetSelectedObject6(1, -1)
swModel.ClearSelection2(True)
featType = ""
featName = ""
' Get the feature's type and name
featName = swFeat.GetNameForSelection(featType)
swModelDocExt.SelectByID2(featName, featType, 0, 0, 0, True, 0, Nothing, 0)
' Print the feature's type and name
' to the Immediate window
MsgBox(featType)
MsgBox(featName)
End Sub
End Class |
|