Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to sort items in a selection set

Status
Not open for further replies.

jremy68

Materials
Aug 12, 2004
4
I am looking for a vba program that will add numbers to all of the items in a selection set. The only problem is when I do this with a simple program I have to pick the items one by one in order to get the numbering in order is there anyway way to get the numbers to be in numeric order.


Sub numdemo()
Dim objSset As AcadSelectionSet
Dim objEnt As Object
Dim count As Integer
Dim textObj As AcadText
Dim textString As String
Dim height As Double
Dim minExt As Variant
Dim maxExt As Variant
Set objSset = ThisDrawing.SelectionSets.Add("ss")
objSset.SelectOnScreen

count = 0
For Each objEnt In objSset
objEnt.GetBoundingBox minExt, maxExt
minExt(0) = minExt(0) + 5
minExt(1) = minExt(1) + 5
count = count + 1
minExt(0) = minExt(0) + 5
minExt(1) = minExt(1) + 5
textString = count

height = 6

Set textObj = ThisDrawing.ModelSpace.AddText(textString, minExt, height)

Next 'objEnt
objSset.Delete
End Sub
 
Replies continue below

Recommended for you

There are a few ways. From your code, you are outputting the info and it cycles through the selection set one by one. You would need to store all of the info first, sort it, and then output the info. You could store the info into a dynamic array, or place it in a listbox (hidden or not) and then sort it, or place it on screen and then go back and get all of the text and work through them to sort them and then move them around. A few ideas.

"Everybody is ignorant, only on different subjects." — Will Rogers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor