Hi all,
Here is the VB code. I have test it successful in SolidWorks VBA. but ,when I copy it in VB.net,it failed.
So I try to change "Dim obj() As Object" to "Dim obj() As Face2", it is OK when I select some faces in SolidWorks Part document.
But in practice, I can't change it to "face2". becuase, I don't know what type entity will be selected(it may faces/sketch/solid/edge......,even their combination).
What should I do now?
thank you very much!
===========================================================================================
Sub main()
Dim swAppp As SldWorks.SldWorks
Dim Doc As SldWorks.ModelDoc2
Dim SelMgr As SelectionMgr
Set swApp = Application.SldWorks
Set Doc = swApp.ActiveDoc
Set SelMgr = Doc.SelectionManager
If SelMgr.GetSelectedObjectCount = 0 Then Debug.Print "No selections found.": Exit Sub
'Put the Selected object in an array
Dim i As Integer
Dim obj() As Object
ReDim obj(SelMgr.GetSelectedObjectCount - 1)
For i = 1 To SelMgr.GetSelectedObjectCount
Set obj(i - 1) = SelMgr.GetSelectedObject6(i, -1)
Next i
Doc.ClearSelection
'MultiSelect the object in "obj" array
Dim seldata As SelectData
Set seldata = Nothing
Dim boolstatus As Boolean
boolstatus = Doc.Extension.MultiSelect(obj, True, seldata) 'This code doesn't work in VB.Net
End Sub
===========================================================================================
SolidworksApi macros