Arc Finding

Arc Finding

Anonymous
Not applicable
253 Views
2 Replies
Message 1 of 3

Arc Finding

Anonymous
Not applicable
-code follows
Sorry I'm kind of new to VBA so hopefully this isn't to trivial...

I'm trying to search a drawing for arcs. My problem is what to declare what I'm looking for. If I set my elem to AcadArc I find arcs but if there are other objects in the drawing it screws up. If i set elem to AcadEntity or Object the search works but then I have trouble reading some of the arc properties. How do i typecast a AcadEntity to an AcadArc?... or do i even have to do this?

Thanks

''''''''''code'''''''''''''''''''''''''''''''''''
Dim elem As AcadEntity
Dim Stuff As AcadArc

For Each elem In ThisDrawing.ModelSpace
If StrComp(elem.EntityName, "AcDbArc", 1) = 0 Then
Set Stuff = ThisDrawing.ModelSpace.elem
''''' Do something with Stuff ''''''''''
End If
0 Likes
254 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
There are two methods you can use. The first would be to iterate the
drawing for entities like you are doing and then testing the entity to
see if it is an arc:

dim ent as acadentity
dim arc as acadarc
for each ent in thisdrawing.modelspace
if typeof ent is acardarc then
set arc = ent
'do wahtever
end if
next

The second method would be to create a selectionset using acselectall
and apply a filter that only selects the arcs, then iterate the
selectionset. Do a search on this ng for filter and you should find all
the sample code you need.
-Josh

apowley wrote:

> -code follows
> Sorry I'm kind of new to VBA so hopefully this isn't to trivial...
>
> I'm trying to search a drawing for arcs. My problem is what to declare
> what I'm looking for. If I set my elem to AcadArc I find arcs but if
> there are other objects in the drawing it screws up. If i set elem to
> AcadEntity or Object the search works but then I have trouble reading
> some of the arc properties. How do i typecast a AcadEntity to an
> AcadArc?... or do i even have to do this?
>
> Thanks
>
> ''''''''''code'''''''''''''''''''''''''''''''''''
> Dim elem As AcadEntity
> Dim Stuff As AcadArc
>
> For Each elem In ThisDrawing.ModelSpace
> If StrComp(elem.EntityName, "AcDbArc", 1) = 0 Then
> Set Stuff = ThisDrawing.ModelSpace.elem
> ''''' Do something with Stuff ''''''''''
> End If
>
0 Likes
Message 3 of 3

Anonymous
Not applicable
'Build a filtered selection set:

Sub GetArcs()
Dim objArc As AcadArc
Dim ArcSS As AcadSelectionSet
Dim fType(0) As Integer
Dim fData(0) As Variant
Set ArcSS = ThisDrawing.SelectionSets.Add("ArcSS")
fType(0) = 0: fData(0) = "ARC"
ArcSS.Select acSelectionSetAll, , , fType, fData
For Each objArc In ArcSS
'Process arcs
Next objArc
ArcSS.Delete
End Sub

-- Walter -- http://www.ActiveDwg.com
0 Likes