AnsweredAssumed Answered

how to use SelectByID2 and GetSelectedObject6 together?

Question asked by Ross John on Apr 10, 2017
Latest reply on Apr 11, 2017 by Deepak Gupta

Hello Forum,

 

I am following the example to mate a part with an assembly. 2017 SOLIDWORKS API Help - Add and Mate Component Example (VB.NET)

 

My question is about the flowing two lines...

boolstat = swDocExt.SelectByID2(FirstSelection, "PLANE", 0, 0, 0, True, 1, Nothing, swSelectOption_e.swSelectOptionDefault)

boolstat = swDocExt.SelectByID2(SecondSelection, "PLANE", 0, 0, 0, True, 1, Nothing, swSelectOption_e.swSelectOptionDefault)

The FirstSelection and SecondSelection are defined as Strings. boolstat is  Boolean.

 

 

Because I have a selection command in UserPMPage.vb. so I want to use the selected object directly. Thus I rewrite the codes as follows...

Dim FirstSelectedObject as Object

FirstSelectedObject = swSelectionManager.GetSelectedObject6(1, -1)   'Get the selection from the user PMPage selection controll

boolstat = swDocExt.SelectByID2(SecondSelection, "PLANE", 0, 0, 0, True, 1, Nothing, swSelectOption_e.swSelectOptionDefault)

...And then run the AddMate5.

 

 

I could tell you that my code does not work, sadly. The difference between my code and example is mainly on the GetSelectedObject6. I have tried a lot of ways, but just could not get the correct method... Although I dont think the selection method is wrong, because sometimes we need to do so on SolidWorks.

 

Could somebody please give me some hints? Thank you in advance!

Outcomes