You need to loop through the selected object from 1 to SelectionMgr::GetSelectedObjectCount2. Then you can get the pointer either using the SelectionMgr::GetSelectedObject6 or SelectionMgr::GetSelectedObjectsDrawingView2. to allow users selected any entity from the view. Check the 'Selection Lists (VBA)' example in API Help for a sample code.
Regards, Artem Taturevych | Snr. Developer | IC3D ANZ
IC3DSteel – New Steel Solution for SolidWorks
translationXpert – SolidWorks files language translator
That got the ball rolling. Im well on my way now!
here is a sample of what im trying to do. it mostly works but im getting unexpected results and I have no idea why.
1.) CTRL Select drawing views in this order; topview, bottomview & then middleview
2.) run macro
DESIRED post conditions:
1.) middle view moves midway between the top and bottom views
2.) top and bottom views remain unmoved
Actual post conditions:
1.) middle AND Top views move up instead of middle view moving to the midway point
do you see what im doing wrong?
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swView As SldWorks.View
Dim TopView As Variant
Dim BottomView As Variant
Dim MiddleView As Variant
Dim Distance As Double
Dim spacing As Double
'Connect to Solidworks & active document
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSelMgr = swModel.SelectionManager
'Get TopView pos
Set swView = swSelMgr.GetSelectedObject6(1, -1)
TopView = swView.Position
'Get BottomView pos
Set swView = swSelMgr.GetSelectedObject6(2, -1)
BottomView = swView.Position
Set swView = Nothing
'Reposition Middle View
Set swView = swSelMgr.GetSelectedObject6(3, -1)
Distance = TopView(1) - BottomView(1)
spacing = Distance / 2
MiddleView = swView.Position
MiddleView(1) = TopView(1) - spacing
swView.Position = MiddleView
Set swApp = Nothing
further extermination indicates the odd behavior seems to be related to the drawing views being aligned to each other.
I suppose I need to break the alignments before I attempt to move the individual views.