Message 1 of 12
Not applicable
01-26-2015
11:24 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All
I need to check if the point inside or outside the polyline.
I know that many posts talked about this, but i did not found a real result till now.
Now i am trying with a peace of code that using TraceBoundary method, when user select a point inside an object, the boject color changed, the problem that i can not select the polylines only from other objects.
any help please, it very important for me.
Thanks
This my try.
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Runtime.Interop
Imports Autodesk.AutoCAD.BoundaryRepresentation
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports ErrorStatus = Autodesk.AutoCAD.Runtime.ErrorStatus
Imports acApp = Autodesk.AutoCAD.ApplicationServices.Application
Imports Autodesk.AutoCAD.ApplicationServices.DocumentExtension
<CommandMethod("TB")> _
Public Sub TraceBoundary()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
' Select a seed point for our boundary
Dim ppr As PromptPointResult = ed.GetPoint(vbLf & "Select internal point: ")
If ppr.Status <> PromptStatus.OK Then
Return
End If
' Get the objects making up our boundary
Dim objs As DBObjectCollection = ed.TraceBoundary(ppr.Value, True)
If objs.Count > 0 Then
Dim tr As Transaction = doc.TransactionManager.StartTransaction()
Using tr
' We'll add the objects to the model space
Dim bt As BlockTable = DirectCast(tr.GetObject(doc.Database.BlockTableId, OpenMode.ForRead), BlockTable)
Dim btr As BlockTableRecord = DirectCast(tr.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord)
' Add our boundary objects to the drawing and
' collect their ObjectIds for later use
Dim ids As New ObjectIdCollection()
For Each obj As DBObject In objs
'If TypeOf obj Is Polyline Then
' MsgBox("Yes")
'End If
Dim ent As Entity = TryCast(obj, Entity)
If ent IsNot Nothing Then
' Set our boundary objects to be of
' our auto-incremented colour index
ent.ColorIndex = _index
' Set the lineweight of our object
ent.LineWeight = LineWeight.LineWeight050
' Add each boundary object to the modelspace
' and add its ID to a collection
ids.Add(btr.AppendEntity(ent))
tr.AddNewlyCreatedDBObject(ent, True)
End If
Next
' Increment our colour index
_index += 1
' Commit the transaction
tr.Commit()
End Using
End If
End Sub
Solved! Go to Solution.