Hello Tony,
What I'm doing is traversing down a Civil3D alignment at each station, detecting
if any plan view graphics would intersect with a line that is perpendicular
at the station out a certain distance then doing some special coding. I've
dropped all the problem entities down to plan Autocad entities and tested
in plain Autocad 2010 and get the same result.
This is working great except for a few places where intersections are detected
where they don't exist. ADN said these show up sometimes when "Large Coordinates"
are encountered. The Civil3D team now codes around this known bug by transforming
copies of the objects in memory closer to the drawing origin (thus smaller
coordinates) where the bug doesn't show itself.
I've attached at dwg file that shows this behavior of Large Coordinates.
The green line represents the station line and the yellow line is the plan
graphic.
Below is my method that takes in: a SelectionSet and the line representing
the line perpendicular to the alignment at the current station
It returns a ObjectIDCollection and Point3D collection of what and where
it found intersections.
{code}
Public Shared Sub GetIntersections(ByRef cPts As Point3dCollection, ByRef
cObjs As ObjectIdCollection, ByVal ss As SelectionSet, ByVal db As Database,
ByVal oLine As Line)
Dim ent As Autodesk.AutoCAD.DatabaseServices.Entity = Nothing
Dim tm As DBTransactionManager = db.TransactionManager
cObjs = New ObjectIdCollection
cPts = New Point3dCollection
Using ta As Transaction = tm.StartTransaction()
If Not ss Is Nothing Then
'see if the entities found intersect with the corridor frequency
lines at the current station
For i As Integer = 0 To ss.Count
Try
ent = ta.GetObject(ss.Item(i).ObjectId, OpenMode.ForRead,
False, True)
Dim iPts As Point3dCollection = New Point3dCollection
'create plane perpendicular to the alignment at the
current station origin
Dim xyPlane As Plane = New Plane(New Point3d(0, 0,
0), New Vector3d(0, 0, 1))
Dim int As Integer = 0
Dim intPointer As IntPtr = int
ent.IntersectWith(oLine, Intersect.OnBothOperands,
xyPlane, iPts, System.IntPtr.Zero, System.IntPtr.Zero)
If Not iPts Is Nothing Then 'intersection found
For Each tPt As Point3d In iPts
Dim bInserted As Boolean = False
If cPts.Count > 0 Then
Dim j As Integer = 0
Dim sPt As Point3d = oLine.StartPoint
Dim tDist As Double = sPt.DistanceTo(tPt)
For j = 0 To cPts.Count
If tDist < sPt.DistanceTo(cPts(j))
Then
cPts.Insert(j, tPt)
cObjs.Insert(j, ent.ObjectId)
bInserted = True
Exit For
End If
Next
End If
If Not bInserted Then
cPts.Add(tPt)
cObjs.Add(ent.ObjectId)
End If
Next
End If
Catch
End Try
Next
End If
End Using
End Sub
{code}
> {quote}
>
> I'm detecting the intersection between a plane and a 3d line.
>
> {quote}
>
> IntersectWith() operates on two entities.
>
> What kind of entity is the 'plane'?
>
> AcadXTabs: MDI Document Tabs for AutoCAD
> Supporting AutoCAD 2000 through 2010
> http://www.acadxtabs.com
>
> Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");
>