VB.Net - how to select multiple solid objects in part?

VB.Net - how to select multiple solid objects in part?

magicdl96
Advocate Advocate
785 Views
3 Replies
Message 1 of 4

VB.Net - how to select multiple solid objects in part?

magicdl96
Advocate
Advocate

Can anyone help me write code VB.Net so I can select multiple solid objects in a part? (Not Select all solid)

 

Thank you so much.

 

0 Likes
786 Views
3 Replies
Replies (3)
Message 2 of 4

J-Camper
Advisor
Advisor

I'm not sure if you wanted the user to select bodies, or if you have another way to determine which parts get selected.  The below code will let user pick bodies and store them into an Object collection for later use.

Dim selectThis As HighlightSet = ThisApplication.ActiveDocument.CreateHighlightSet
Dim DocCollection As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection

Dim BodyCount As Integer = InputBox("How many Solid bodies will you need?", "Body Count", "3")
While DocCollection.Count < BodyCount
	Dim PickThis As SurfaceBody = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartBodyFilter, "Select Body")
	If IsNothing(PickThis) Then Exit Sub ' If nothing gets selected then we're done
		'Perform any checks to limit selection, if any
		DocCollection.Add(PickThis)
End While

selectThis.AddMultipleItems(DocCollection)
MessageBox.Show("","Bodies Picked:")

 

If you were looking for something else, let me know.

0 Likes
Message 3 of 4

magicdl96
Advocate
Advocate

I had a fresh look .. thank you.

I want to choose bodies ones so I can change their names in the order they are selected ..

I have to find out and you know about SelectSet.GetEnumerator()

 

0 Likes
Message 4 of 4

J-Camper
Advisor
Advisor

When the bodies get added to the object collection "DocCollection" you can then work through those bodies in the order they are selected by looping through "DocCollection.Item(i)" or you could do you name changing right after the User Pick if you don't need to know how many solids will be renamed before starting the renaming process.

 

An example of what you are exactly looking for would help, if this hasn't answered your question.

0 Likes