<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Get Area from hatch in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/get-area-from-hatch/m-p/2125608#M76244</link>
    <description>Hello, &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I'm searching a way to get area from a hatch, in VB.NET 2005 with AutoCAD 2007.&lt;BR /&gt;
&lt;BR /&gt;
At this point this is my code :&lt;BR /&gt;
&lt;BR /&gt;
Public Function SurfaceHachures_Valeur() As Double&lt;BR /&gt;
        Dim db As Database = HostApplicationServices.WorkingDatabase&lt;BR /&gt;
        Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor&lt;BR /&gt;
        Dim resultat As Double&lt;BR /&gt;
&lt;BR /&gt;
        Using docLock As DocumentLock = Application.DocumentManager.MdiActiveDocument.LockDocument()&lt;BR /&gt;
            Using trans As Transaction = db.TransactionManager.StartTransaction()&lt;BR /&gt;
                Try&lt;BR /&gt;
                    Dim prSelection As New PromptSelectionOptions&lt;BR /&gt;
                    Dim prSelectionRes As PromptSelectionResult = ed.GetSelection(prSelection)&lt;BR /&gt;
                    If prSelectionRes.Status = PromptStatus.OK Then&lt;BR /&gt;
                        For Each objId As ObjectId In prSelectionRes.Value.GetObjectIds&lt;BR /&gt;
                            Dim ent As Entity = (CType(trans.GetObject(objId, OpenMode.ForRead, False), Entity))&lt;BR /&gt;
                            If (TypeOf ent Is Hatch) Then&lt;BR /&gt;
                                Dim h As Hatch = CType(ent, Hatch)&lt;BR /&gt;
&lt;BR /&gt;
                                Dim pl As Polyline 'this polyline should be the boundaries of the hatch zone, but I can't get it.&lt;BR /&gt;
                                Dim DBObjColl As New DBObjectCollection()&lt;BR /&gt;
                                DBObjColl.Add(pl)&lt;BR /&gt;
                                Dim reg As Region = Region.CreateFromCurves(DBObjColl)(0)&lt;BR /&gt;
                                MsgBox(reg.Area)&lt;BR /&gt;
&lt;BR /&gt;
                            End If&lt;BR /&gt;
                        Next objId&lt;BR /&gt;
                    End If&lt;BR /&gt;
                    trans.Abort()&lt;BR /&gt;
                    ed.WriteMessage("OK")&lt;BR /&gt;
                Catch ex As Exception&lt;BR /&gt;
                    ed.WriteMessage(ex.Message)&lt;BR /&gt;
                End Try&lt;BR /&gt;
            End Using&lt;BR /&gt;
&lt;BR /&gt;
        End Using&lt;BR /&gt;
        Return resultat&lt;BR /&gt;
    End Function&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
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.&lt;BR /&gt;
&lt;BR /&gt;
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...&lt;BR /&gt;
&lt;BR /&gt;
Thanks for your help if you have some !</description>
    <pubDate>Wed, 28 Nov 2007 16:46:28 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2007-11-28T16:46:28Z</dc:date>
    <item>
      <title>Get Area from hatch</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-area-from-hatch/m-p/2125608#M76244</link>
      <description>Hello, &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I'm searching a way to get area from a hatch, in VB.NET 2005 with AutoCAD 2007.&lt;BR /&gt;
&lt;BR /&gt;
At this point this is my code :&lt;BR /&gt;
&lt;BR /&gt;
Public Function SurfaceHachures_Valeur() As Double&lt;BR /&gt;
        Dim db As Database = HostApplicationServices.WorkingDatabase&lt;BR /&gt;
        Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor&lt;BR /&gt;
        Dim resultat As Double&lt;BR /&gt;
&lt;BR /&gt;
        Using docLock As DocumentLock = Application.DocumentManager.MdiActiveDocument.LockDocument()&lt;BR /&gt;
            Using trans As Transaction = db.TransactionManager.StartTransaction()&lt;BR /&gt;
                Try&lt;BR /&gt;
                    Dim prSelection As New PromptSelectionOptions&lt;BR /&gt;
                    Dim prSelectionRes As PromptSelectionResult = ed.GetSelection(prSelection)&lt;BR /&gt;
                    If prSelectionRes.Status = PromptStatus.OK Then&lt;BR /&gt;
                        For Each objId As ObjectId In prSelectionRes.Value.GetObjectIds&lt;BR /&gt;
                            Dim ent As Entity = (CType(trans.GetObject(objId, OpenMode.ForRead, False), Entity))&lt;BR /&gt;
                            If (TypeOf ent Is Hatch) Then&lt;BR /&gt;
                                Dim h As Hatch = CType(ent, Hatch)&lt;BR /&gt;
&lt;BR /&gt;
                                Dim pl As Polyline 'this polyline should be the boundaries of the hatch zone, but I can't get it.&lt;BR /&gt;
                                Dim DBObjColl As New DBObjectCollection()&lt;BR /&gt;
                                DBObjColl.Add(pl)&lt;BR /&gt;
                                Dim reg As Region = Region.CreateFromCurves(DBObjColl)(0)&lt;BR /&gt;
                                MsgBox(reg.Area)&lt;BR /&gt;
&lt;BR /&gt;
                            End If&lt;BR /&gt;
                        Next objId&lt;BR /&gt;
                    End If&lt;BR /&gt;
                    trans.Abort()&lt;BR /&gt;
                    ed.WriteMessage("OK")&lt;BR /&gt;
                Catch ex As Exception&lt;BR /&gt;
                    ed.WriteMessage(ex.Message)&lt;BR /&gt;
                End Try&lt;BR /&gt;
            End Using&lt;BR /&gt;
&lt;BR /&gt;
        End Using&lt;BR /&gt;
        Return resultat&lt;BR /&gt;
    End Function&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
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.&lt;BR /&gt;
&lt;BR /&gt;
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...&lt;BR /&gt;
&lt;BR /&gt;
Thanks for your help if you have some !</description>
      <pubDate>Wed, 28 Nov 2007 16:46:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-area-from-hatch/m-p/2125608#M76244</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-11-28T16:46:28Z</dc:date>
    </item>
  </channel>
</rss>

