Message 1 of 1
Get Area from hatch
Not applicable
11-28-2007
08:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I'm searching a way to get area from a hatch, in VB.NET 2005 with AutoCAD 2007.
At this point this is my code :
Public Function SurfaceHachures_Valeur() As Double
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
Dim resultat As Double
Using docLock As DocumentLock = Application.DocumentManager.MdiActiveDocument.LockDocument()
Using trans As Transaction = db.TransactionManager.StartTransaction()
Try
Dim prSelection As New PromptSelectionOptions
Dim prSelectionRes As PromptSelectionResult = ed.GetSelection(prSelection)
If prSelectionRes.Status = PromptStatus.OK Then
For Each objId As ObjectId In prSelectionRes.Value.GetObjectIds
Dim ent As Entity = (CType(trans.GetObject(objId, OpenMode.ForRead, False), Entity))
If (TypeOf ent Is Hatch) Then
Dim h As Hatch = CType(ent, Hatch)
Dim pl As Polyline 'this polyline should be the boundaries of the hatch zone, but I can't get it.
Dim DBObjColl As New DBObjectCollection()
DBObjColl.Add(pl)
Dim reg As Region = Region.CreateFromCurves(DBObjColl)(0)
MsgBox(reg.Area)
End If
Next objId
End If
trans.Abort()
ed.WriteMessage("OK")
Catch ex As Exception
ed.WriteMessage(ex.Message)
End Try
End Using
End Using
Return resultat
End Function
I need to know how to retrieve boundaries of a hatch in a polyline, or to do the command that recreate them, but in vb.net.
I know that there's a command in line like "edithatch recreate boundaries" but I don't know how to use it in VB.NET, retrieving the Objectid of the polyline...
Thanks for your help if you have some !
I'm searching a way to get area from a hatch, in VB.NET 2005 with AutoCAD 2007.
At this point this is my code :
Public Function SurfaceHachures_Valeur() As Double
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
Dim resultat As Double
Using docLock As DocumentLock = Application.DocumentManager.MdiActiveDocument.LockDocument()
Using trans As Transaction = db.TransactionManager.StartTransaction()
Try
Dim prSelection As New PromptSelectionOptions
Dim prSelectionRes As PromptSelectionResult = ed.GetSelection(prSelection)
If prSelectionRes.Status = PromptStatus.OK Then
For Each objId As ObjectId In prSelectionRes.Value.GetObjectIds
Dim ent As Entity = (CType(trans.GetObject(objId, OpenMode.ForRead, False), Entity))
If (TypeOf ent Is Hatch) Then
Dim h As Hatch = CType(ent, Hatch)
Dim pl As Polyline 'this polyline should be the boundaries of the hatch zone, but I can't get it.
Dim DBObjColl As New DBObjectCollection()
DBObjColl.Add(pl)
Dim reg As Region = Region.CreateFromCurves(DBObjColl)(0)
MsgBox(reg.Area)
End If
Next objId
End If
trans.Abort()
ed.WriteMessage("OK")
Catch ex As Exception
ed.WriteMessage(ex.Message)
End Try
End Using
End Using
Return resultat
End Function
I need to know how to retrieve boundaries of a hatch in a polyline, or to do the command that recreate them, but in vb.net.
I know that there's a command in line like "edithatch recreate boundaries" but I don't know how to use it in VB.NET, retrieving the Objectid of the polyline...
Thanks for your help if you have some !