I accually figured the rest out on my own....but couldn't have done it without your help
<<<<<Roar of the Crowd>>>>>
Thx everyone!
|
I accually figured the rest out on my own....but couldn't have done it without your help
<<<<<Roar of the Crowd>>>>>
Thx everyone!
.. while we're on the subject of selection sets - how does one build 'filter data' for non-graphical entites? Specifically, Im hoping to filter only "Group" objects, and, hopefully, only Group objects whose name starts with a specific set of letters....
any takers? is this even possible?
There are no ways to select certain group
by filter
Try another method
~'J'~Code:Option Explicit ' request check on 'Break on Unhadled Errors' option button ' in Tools->Options->General Public Function IsGroupExist(groupName As String) As Boolean ' Frank Oquendo's technic Dim oGroup As AcadGroup On Error Resume Next Set oGroup = ThisDrawing.Groups.Item(groupName) IsGroupExist = (Err.Number = 0) End Function ''========================='' Public Sub GetGroupItems() Dim oGroup As AcadGroup Dim gpName As String Dim objEnt As AcadObject On Error GoTo Err_Control gpName = InputBox("Enter group name to discover items: ", "Group Manipulation") ' if emtpy string entered If gpName = vbNullString Then Exit Sub ' check for existing group If Not IsGroupExist(gpName) Then MsgBox "Group named " & gpName & vbCr & _ "does not exist" Exit Sub End If ' get the group from Groups collection Set oGroup = ThisDrawing.Groups.Item(gpName) ' Check fro count items in the group MsgBox "There are " & oGroup.Count & " items in this group" ' Test ' loop trough the group items, say change color to red For Each objEnt In oGroup objEnt.color = acRed Debug.Print objEnt.ObjectName Next Exit_Here: ' Clean up If Not oGroup Is Nothing Then Set oGroup = Nothing End If Exit Sub ' error handler Err_Control: If Err.Number <> 0 Then MsgBox Err.Description Err.Clear End If Resume Exit_Here End Sub
The following code is the VBA method of accessing the Acad "FILTER" command. It can get quite complicated if you use multiple boolean filters like and/or, so I have kept it simple. Note that you do not iterate the entities.
This code collects all text on a drawing into the named selection set "ALLTEXT". Once you have that set, you can process them in a loop.
This example just loops through the selection set and prints the contents of the text string.
The trick here is understanding the Codes and CodeValues arrays. They are dxf codes for what you are searching for. They could be blocks, circles or whatever. [layers DXF code is 8] This is a topic you should investigate in a good VBA manual. It's a bit too complicated to explain here. The main reason for learning it: It's FAST!!!!!Code:Option Base 0 Sub SelectText() 'set up variables Dim oText As AcadText Dim Sset As AcadSelectionSet Dim Codes(0) As Integer Dim CodeValues(0) As Variant 'set up filter Codes(0) = 0 CodeValues(0) = "TEXT" 'create selection set and fill it Set Sset = ThisDrawing.SelectionSets.Add("AllText") Sset.Select acSelectionSetAll, , , Codes, CodeValues 'display results If Sset.Count > 0 Then For Each oText In Sset Debug.Print oText.TextString Next oText Else debug.print "NO TEXT FOUND" End If 'delete selection set ThisDrawing.SelectionSets("AllText").Delete End Sub