capture radius in ent with other entities in selection.

capture radius in ent with other entities in selection.

Anonymous
Not applicable
268 Views
2 Replies
Message 1 of 3

capture radius in ent with other entities in selection.

Anonymous
Not applicable
Looking for help with a selection set.
What I'm trying to do is get all lines, arcs & lwpolylines on layers curb
and 0. so that I can get the xy location of the end points of all these
items and pass them to
query the station & offset to a Land alignment. I'm able to get all items on
the named layers but I'm having trouble with the varDataPnt.
I used the varDataPnt = ent.EndPoint but this skips the start point of arcs.
What can I use to get both the start & endpoint of all items.

Also I create the SS with layer curb & 0 but in the If.ent.layer test I
don't see how to inclues addtional layers without adding another line and
place the addtional layer names in it. can you add a array of layers to the
ent.layer test with type of ent.

As always thanks you for any comments
John Coon

Set ss = ThisDrawing.SelectionSets.Add("ss")
fType(0) = 8: fData(0) = "CURB, 0"
fType(1) = 0: fData(1) = "LINE,ARC,AcadLWPolyline"
ss.Select acSelectionSetAll, , , fType, fData
For Each ent In ThisDrawing.ModelSpace
If TypeOf ent Is AcadArc Then
dblRadius = ent.RADIUS
End If
If ent.Layer = "CURB" And (TypeOf ent Is AcadArc Or TypeOf ent Is
AcadLine Or TypeOf ent Is AcadLWPolyline) Then
count = count + 1
Dim varDataPnt As Variant
varDataPnt = ent.EndPoint

'''''''''''''''''''''''''''''''''''''''''''''''more stuff....load land
alingment for station offset values

Set mtxtLabel = ThisDrawing.ModelSpace.AddMText(varDataPnt, dblWidth,
stastrlen)
mtxtLabel.Height = dblHeight
mtxtLabel.Rotation = dblRot

If TypeOf ent Is AcadArc Then
Set mtxtLabel = ThisDrawing.ModelSpace.AddMText(varDataPnt, dblWidth,
strradius)
mtxtLabel.Height = dblHeight
mtxtLabel.Rotation = dblRot

End If
End If

Print #1, strSta & "," & strOff & "," & dblRadius & "," & STRY & "," & STRX
& "," & dblDir
0 Likes
269 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
OK, John, I'm confused......as usual. 🙂
Why do you create a selection set of the desired items on the desired
layers, then not use it and step through model space trying to filter for
the exact same thing?

Make sure to get the StartPoint AND EndPoint properties of each Line & Arc.
For the Polylines obtain the Startpoint by ent.Coordinate(0) and the
endpoint by ent.Coordinate((Ubound(ent.coordinates) / 2) - 1)

Here's how I would go about this:
[code]
Dim ent As AcadEntity
Dim endp As Variant
Dim dRadius As Double
Dim mtxt As AcadMText
Dim ss As AcadSelectionSet
Dim fType(1) As Integer
Dim fData(1) As Variant

On Error Resume Next
Set ss = ThisDrawing.SelectionSets.Item("ss")
If Err.Number <> 0 Then
Set ss = ThisDrawing.SelectionSets.Add("ss")
End If
On Error GoTo 0
Err.Clear
ss.Clear
fType(0) = 8: fData(0) = "CURB,0" 'note, no space between items
fType(1) = 0: fData(1) = "LINE,ARC,LWPOLYLINE"

ss.Select acSelectionSetAll, , , fType, fData

For Each ent In ss
If TypeOf ent Is AcadLWPolyline Then
endp = ent.Coordinate((UBound(ent.Coordinates) / 2) - 1)
Set mtxt = PlaceMtextAtEnd(endp)
ElseIf TypeOf ent Is AcadArc Then
endp = ent.EndPoint
dRadius = ent.Radius
Set mtxt = PlaceMtextAtEnd(endp, dRadius)
ElseIf TypeOf ent Is AcadLine Then
endp = ent.EndPoint
Set mtxt = PlaceMtextAtEnd(endp)
End If
Next
End Sub

Function PlaceMtextAtEnd(insPt As Variant, Optional dRad As Double) As
AcadMText
'do your station calcs & mtext creation here, using the dRad if it exists
End Function


"John Coon" wrote in message
news:4859546@discussion.autodesk.com...
Looking for help with a selection set.
What I'm trying to do is get all lines, arcs & lwpolylines on layers curb
and 0. so that I can get the xy location of the end points of all these
items and pass them to
0 Likes
Message 3 of 3

Anonymous
Not applicable
Jeff,

Thanks for your help. This was one of the first times I had the need to use
or filter for more than one element or type. normally I only need
to filter for a single type block, polyline... This was my first go at multi
type elements.
I also didn't understand how to approach collecting the insertion points
from all these types. thanks to your help I see how to collect the endpoints
of the items filtered and pass the end points coords.

Thank you for you comments. It was a good lesson.

John Coon


"Jeff Mishler" wrote in message
news:4859559@discussion.autodesk.com...
OK, John, I'm confused......as usual. 🙂
Why do you create a selection set of the desired items on the desired
layers, then not use it and step through model space trying to filter for
the exact same thing?

Make sure to get the StartPoint AND EndPoint properties of each Line & Arc.
For the Polylines obtain the Startpoint by ent.Coordinate(0) and the
endpoint by ent.Coordinate((Ubound(ent.coordinates) / 2) - 1)

Here's how I would go about this:
[code]
Dim ent As AcadEntity
Dim endp As Variant
Dim dRadius As Double
Dim mtxt As AcadMText
Dim ss As AcadSelectionSet
Dim fType(1) As Integer
Dim fData(1) As Variant

On Error Resume Next
Set ss = ThisDrawing.SelectionSets.Item("ss")
If Err.Number <> 0 Then
Set ss = ThisDrawing.SelectionSets.Add("ss")
End If
On Error GoTo 0
Err.Clear
ss.Clear
fType(0) = 8: fData(0) = "CURB,0" 'note, no space between items
fType(1) = 0: fData(1) = "LINE,ARC,LWPOLYLINE"

ss.Select acSelectionSetAll, , , fType, fData

For Each ent In ss
If TypeOf ent Is AcadLWPolyline Then
endp = ent.Coordinate((UBound(ent.Coordinates) / 2) - 1)
Set mtxt = PlaceMtextAtEnd(endp)
ElseIf TypeOf ent Is AcadArc Then
endp = ent.EndPoint
dRadius = ent.Radius
Set mtxt = PlaceMtextAtEnd(endp, dRadius)
ElseIf TypeOf ent Is AcadLine Then
endp = ent.EndPoint
Set mtxt = PlaceMtextAtEnd(endp)
End If
Next
End Sub

Function PlaceMtextAtEnd(insPt As Variant, Optional dRad As Double) As
AcadMText
'do your station calcs & mtext creation here, using the dRad if it exists
End Function


"John Coon" wrote in message
news:4859546@discussion.autodesk.com...
Looking for help with a selection set.
What I'm trying to do is get all lines, arcs & lwpolylines on layers curb
and 0. so that I can get the xy location of the end points of all these
items and pass them to
0 Likes