.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Erase color a rectangular Poly Line using vb.net

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
040905
677 Views, 2 Replies

Erase color a rectangular Poly Line using vb.net

Hi everyone, i have a rectangular poliline and i input number in it. I want erase poly line after i erase text (number)

 

untitled.JPG

 

I erased text (number) but I was not erased yet, and when erase poly line , it would be white color. 

My code:

 

Public Sub DeleteStone(ByVal Collec As DBObjectCollection)
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
doc.LockDocument()
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Dim _mStoneCadID = ""
Using tr As Transaction = db.TransactionManager.StartTransaction()
Try
Dim poli As Polyline = Collec.Item(0)
If Collec.Count > 1 Then
Dim j As Integer = 0
For j = 0 To Collec.Count - 1
Dim pl As Polyline = Collec.Item(j)
If pl.Area > poli.Area Then
poli = pl
End If
Next
End If
'get poins inpolynile
Dim iP As New Point3dCollection
iP = GetpoinFromPolyline(poli)
'set selected on polyline
Dim res = ed.SelectCrossingPolygon(iP)
Dim oSset As SelectionSet = Nothing
If (res.Status = PromptStatus.OK) Then
oSset = res.Value
Else
Return
End If
Dim btr As BlockTableRecord = CType(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
'' iterate through selected texts
For Each obj As SelectedObject In oSset
Dim id As ObjectId = obj.ObjectId
''Cast obj as entity
Dim currentEntity As Entity = TryCast(tr.GetObject(id, OpenMode.ForWrite, False), Entity)
If currentEntity = Nothing Then
Continue For
End If
If currentEntity.Layer.ToString <> "LText" And currentEntity.Layer.ToString <> "LText1" Then
Continue For
End If
If currentEntity.[GetType]() = GetType(DBText) Then
'delete on cad
Dim acText As New DBText
acText = DirectCast(currentEntity, DBText)
If acText.Layer.ToString = "LText" Then
Dim po As Point3d = acText.Position
'check position of text in curren lolyline
Dim re As Boolean = CheckpointOnPolyline(ed, poli, po)
If re = True Then
acText.UpgradeOpen()
acText.Erase()
End If
Else
acText.UpgradeOpen()
_mStoneCadID = acText.Id.ToString
acText.Erase()
End If
End If
Next
'Delete PlyLine before commit
Dim polyLine As New DBPoint
Dim point As Point3d = polyLine.Position
Dim del As Boolean = CheckpointOnPolyline(ed, poli, point)

polyLine.UpgradeOpen()
polyLine.Erase()


tr.Commit()
Catch ex As Autodesk.AutoCAD.Runtime.Exception
ed.WriteMessage("Error: {0}" & vbLf & "Stack trace: {1}", ex.Message, ex.StackTrace)
End Try
End Using
'delete on database
DeleteStoneNumberByID(_mStoneCadID)
End Sub

 

 

Thanks everyone so much.

 

2 REPLIES 2
Message 2 of 3
040905
in reply to: 040905

erased text (number) but I was not erased a rectangular Poly Line yet, and when erase poly line , it would be white color.
Message 3 of 3
040905
in reply to: 040905

I have solved this...thanks everyone so much

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost