<?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 How to add a hatch pattern within rectangular boundaries in a block in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-add-a-hatch-pattern-within-rectangular-boundaries-in-a/m-p/3792740#M50807</link>
    <description>&lt;P&gt;Hi folks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am in the process of translating existing VBA code into its equivalent in VB.NET (developing VS Professional 2010 and testing in AutoCAD 2010)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem is that I have never done hatching in VB.NET before, and now I am required to hatch a rectangular area (defined by lines) within an AutoCAD block. I have absolutely no idea how to go about accomplishing this task.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To create my block, I am using a DBObjectCollection to store my lines, and then append them to the block definition, creating a reference to see what I just created.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I were to define a rectangular outline within this block, how can I possibly hatch it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any pointers? Suggestions? Thanks in advance...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 28 Feb 2013 17:55:50 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2013-02-28T17:55:50Z</dc:date>
    <item>
      <title>How to add a hatch pattern within rectangular boundaries in a block</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-add-a-hatch-pattern-within-rectangular-boundaries-in-a/m-p/3792740#M50807</link>
      <description>&lt;P&gt;Hi folks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am in the process of translating existing VBA code into its equivalent in VB.NET (developing VS Professional 2010 and testing in AutoCAD 2010)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem is that I have never done hatching in VB.NET before, and now I am required to hatch a rectangular area (defined by lines) within an AutoCAD block. I have absolutely no idea how to go about accomplishing this task.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To create my block, I am using a DBObjectCollection to store my lines, and then append them to the block definition, creating a reference to see what I just created.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I were to define a rectangular outline within this block, how can I possibly hatch it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any pointers? Suggestions? Thanks in advance...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Feb 2013 17:55:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-add-a-hatch-pattern-within-rectangular-boundaries-in-a/m-p/3792740#M50807</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-02-28T17:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a hatch pattern within rectangular boundaries in a block</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-add-a-hatch-pattern-within-rectangular-boundaries-in-a/m-p/3792903#M50808</link>
      <description>&lt;P&gt;Here is a code to crate hatch with lines&lt;/P&gt;&lt;P&gt;you have to select two opposite lines and create&lt;/P&gt;&lt;P&gt;polyline to bund the area then apply hatch&lt;/P&gt;&lt;PRE&gt;Public Sub HatchLines()

        Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument

        Dim docloc As DocumentLock = doc.LockDocument()

        Dim ed As Editor = doc.Editor

        Dim db As Database = doc.Database

        Dim tr As Transaction = db.TransactionManager.StartTransaction()

        Using docloc

            Using tr

                'ed.StartUserInteraction(Me)'&amp;lt;-- just in case you using this code from form button

                Dim peo As PromptEntityOptions = New PromptEntityOptions(vbCr &amp;amp; "Select first line: ")

                peo.SetRejectMessage(vbCr &amp;amp; "Select line only: ")

                peo.AddAllowedClass(GetType(Line), True)

                Dim pres As PromptEntityResult = ed.GetEntity(peo)

                If (pres.Status &amp;lt;&amp;gt; PromptStatus.OK) Then

                    Return

                End If

                Dim ent As Entity = CType(tr.GetObject(pres.ObjectId, OpenMode.ForRead), Entity)

                Dim line1 As Line = DirectCast(ent, Line)

                If line1 Is Nothing Then

                    Return

                End If

                peo.Message = vbCr &amp;amp; "Select second line: "

                pres = ed.GetEntity(peo)

                If (pres.Status &amp;lt;&amp;gt; PromptStatus.OK) Then

                    Return

                End If

                ent = CType(tr.GetObject(pres.ObjectId, OpenMode.ForRead), Entity)

                Dim line2 As Line = DirectCast(ent, Line)

                If line2 Is Nothing Then

                    Return

                End If

                Dim sp1 As Point3d = line1.StartPoint

                Dim ep1 As Point3d = line1.EndPoint

                Dim sp2 As Point3d = line2.StartPoint

                Dim ep2 As Point3d = line2.EndPoint

                'check for line directions
                If Math.Abs(line1.Angle - line2.Angle) &amp;gt;= Math.PI Then
                    'swap points if the second line has an opposite direction
                    Dim tmp As Point3d = sp1

                    sp1 = ep1

                    ep1 = tmp

                End If

                Dim btr As BlockTableRecord = CType(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)

                Dim pl As Polyline = New Polyline()

                pl.AddVertexAt(0, New Point2d(sp1.X, sp1.Y), 0, 0, 0)

                pl.AddVertexAt(1, New Point2d(ep1.X, ep1.Y), 0, 0, 0)

                pl.AddVertexAt(2, New Point2d(ep2.X, ep2.Y), 0, 0, 0)

                pl.AddVertexAt(3, New Point2d(sp2.X, sp2.Y), 0, 0, 0)

                pl.Closed = True

                btr.AppendEntity(pl)

                tr.AddNewlyCreatedDBObject(pl, True)

                Dim ids As ObjectIdCollection = New ObjectIdCollection

                ids.Add(pl.ObjectId)

                db.TransactionManager.QueueForGraphicsFlush()

                Dim hatch As Hatch = New Hatch()

                hatch.HatchStyle = HatchStyle.Normal

                hatch.PatternScale = 60.0 '&amp;lt;--change hatch scale to suit

                hatch.PatternAngle = 0.0

                hatch.SetHatchPattern(HatchPatternType.PreDefined, "ANSI37") '&amp;lt;--change pattern name to suit

                hatch.AppendLoop(HatchLoopTypes.Outermost, ids)

                hatch.Associative = False

                hatch.EvaluateHatch(False)

                btr.SetObjectIdsInFlux()

                btr.AppendEntity(hatch)

                tr.AddNewlyCreatedDBObject(hatch, True)

                pl.Erase()

                pl.Dispose()

                ed.Regen()

                tr.Commit()

            End Using

        End Using

    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;You then go expand this code to your needs&lt;/P&gt;</description>
      <pubDate>Thu, 28 Feb 2013 20:28:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-add-a-hatch-pattern-within-rectangular-boundaries-in-a/m-p/3792903#M50808</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2013-02-28T20:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a hatch pattern within rectangular boundaries in a block</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-add-a-hatch-pattern-within-rectangular-boundaries-in-a/m-p/3792905#M50809</link>
      <description>&lt;P&gt;This is very good... Thanks so much, Hallex, much appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Feb 2013 20:32:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-add-a-hatch-pattern-within-rectangular-boundaries-in-a/m-p/3792905#M50809</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-02-28T20:32:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a hatch pattern within rectangular boundaries in a block</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-add-a-hatch-pattern-within-rectangular-boundaries-in-a/m-p/3792936#M50810</link>
      <description>&lt;P&gt;Glad&amp;nbsp;to help&lt;/P&gt;&lt;P&gt;Happy vbneting,&lt;/P&gt;&lt;P&gt;Cheers &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Feb 2013 20:59:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-add-a-hatch-pattern-within-rectangular-boundaries-in-a/m-p/3792936#M50810</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2013-02-28T20:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a hatch pattern within rectangular boundaries in a block</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-add-a-hatch-pattern-within-rectangular-boundaries-in-a/m-p/12171483#M50811</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/523211"&gt;@Hallex&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your sample.&amp;nbsp;It is very helpful to me.&lt;BR /&gt;However, I have a question. Can you explain to me why you are using below API?&lt;/P&gt;&lt;PRE&gt;btr.SetObjectIdsInFlux()&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I can see that hatch is generated with or without that line... Can you tell me what is&amp;nbsp;`SetObjectIdsInFlux` used for?&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2023 08:14:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-add-a-hatch-pattern-within-rectangular-boundaries-in-a/m-p/12171483#M50811</guid>
      <dc:creator>smx_khang</dc:creator>
      <dc:date>2023-08-15T08:14:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a hatch pattern within rectangular boundaries in a block</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-add-a-hatch-pattern-within-rectangular-boundaries-in-a/m-p/12173222#M50812</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13714541"&gt;@smx_khang&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;perhaps :&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.autodesk.com/view/OARX/2022/ENU/?guid=OARX-ManagedRefGuide-Autodesk_AutoCAD_DatabaseServices_DBObject_SetObjectIdsInFlux" target="_blank"&gt;https://help.autodesk.com/view/OARX/2022/ENU/?guid=OARX-ManagedRefGuide-Autodesk_AutoCAD_DatabaseServices_DBObject_SetObjectIdsInFlux&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2023 21:31:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-add-a-hatch-pattern-within-rectangular-boundaries-in-a/m-p/12173222#M50812</guid>
      <dc:creator>kerry_w_brown</dc:creator>
      <dc:date>2023-08-15T21:31:22Z</dc:date>
    </item>
  </channel>
</rss>

