<?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 Re: Unable  create Hacth after to Windown Form in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/unable-create-hatch-after-to-windows-form/m-p/11756928#M9953</link>
    <description>&lt;P&gt;It's seem that has an error when i add DoccumentLock&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="traiduong014969_0-1676476293734.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1176937iC9FAF83934A70FEC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="traiduong014969_0-1676476293734.png" alt="traiduong014969_0-1676476293734.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Feb 2023 15:53:35 GMT</pubDate>
    <dc:creator>traiduong014969</dc:creator>
    <dc:date>2023-02-15T15:53:35Z</dc:date>
    <item>
      <title>Unable  create Hatch after to Windows Form</title>
      <link>https://forums.autodesk.com/t5/net-forum/unable-create-hatch-after-to-windows-form/m-p/11756612#M9949</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Hi all,&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;I Started work with Windonw Form. After create Hatch for a object. I begine make a form to seclect Hatch. However when i test code that has appear a message as picture below:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="traiduong014969_0-1676469860893.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1176879i5B1D396AF91955E1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="traiduong014969_0-1676469860893.png" alt="traiduong014969_0-1676469860893.png" /&gt;&lt;/span&gt; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-moderator edit: corrected spelling errors in title.&lt;/P&gt;
&lt;P&gt;So everyone can tell me how to fix that ?&lt;/P&gt;
&lt;P&gt;Thank you !&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt; public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void B2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void B3_Click(object sender, EventArgs e)
        {
            Document doc = AcAp.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            string mh = B1.SelectedItem.ToString();



            try
            {
                using (Transaction trans = db.TransactionManager.StartTransaction())
                {
                    BlockTable bt = trans.GetObject(doc.Database.BlockTableId, OpenMode.ForRead) as BlockTable;
                    BlockTableRecord btr = trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;

                    Polyline pl = new Polyline();
                    pl.SetDatabaseDefaults();
                    pl.AddVertexAt(0, new Point2d(2.0, 4.0), 0, 0, 0);
                    pl.AddVertexAt(1, new Point2d(4.0, 2.0), 0, 0, 0);
                    pl.AddVertexAt(2, new Point2d(6.0, 4.0), 0, 0, 0);
                    pl.Closed = true;
                    pl.ColorIndex = 6;

                    // Add the polyline to the database
                    ObjectId plineId = btr.AppendEntity(pl);
                    trans.AddNewlyCreatedDBObject(pl, true);

                    // Create the hatch object
                    Hatch ht = new Hatch();
                    ht.SetHatchPattern(HatchPatternType.PreDefined, "mh");
                    ht.ColorIndex = 54;
                    ht.BackgroundColor = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 4);

                    // Add the hatch to the database
                    btr.AppendEntity(ht);
                    trans.AddNewlyCreatedDBObject(ht, true);

                    // Set the hatch boundary
                    ht.Associative = true;
                    ht.AppendLoop(HatchLoopTypes.Default, new ObjectIdCollection() { plineId });
                    ht.EvaluateHatch(true);

                    // Add dimention
                    AlignedDimension al = new AlignedDimension();
                    AlignedDimension al1 = new AlignedDimension();
                    AlignedDimension al2 = new AlignedDimension();

                    al.XLine1Point = new Point3d(2, 4, 0);
                    al.XLine2Point = new Point3d(4, 2, 0);
                    al.Dimscale = 0.5;
                    al.DimensionStyle = db.Dimstyle;

                    al1.XLine1Point = new Point3d(4, 2, 0);
                    al1.XLine2Point = new Point3d(6, 4, 0);
                    al1.Dimscale = 0.5;
                    al1.DimensionStyle = db.Dimstyle;

                    al2.XLine1Point = new Point3d(2, 4, 0);
                    al2.XLine2Point = new Point3d(6, 4, 0);
                    al2.Dimscale = 0.5;
                    al2.DimensionStyle = db.Dimstyle;


                    // Add the new object to Model space and the transaction
                    btr.AppendEntity(al);
                    trans.AddNewlyCreatedDBObject(al, true);

                    btr.AppendEntity(al1);
                    trans.AddNewlyCreatedDBObject(al1, true);

                    btr.AppendEntity(al2);
                    trans.AddNewlyCreatedDBObject(al2, true);
                    trans.Commit();
                }
            }
            catch (Autodesk.AutoCAD.Runtime.Exception ex)
            {
                AcAp.ShowAlertDialog("not create hatch from poplyline " + ex.Message);
            }
        }

        private void B1_SelectedIndexChanged(object sender, EventArgs e)
        {
            
        }
    }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 16:26:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/unable-create-hatch-after-to-windows-form/m-p/11756612#M9949</guid>
      <dc:creator>traiduong014969</dc:creator>
      <dc:date>2023-02-15T16:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: Unable  create Hacth after to Windown Form</title>
      <link>https://forums.autodesk.com/t5/net-forum/unable-create-hatch-after-to-windows-form/m-p/11756718#M9950</link>
      <description>&lt;P&gt;It would be helpful if you posted your code in its entirety. How are you launching your dialog? Modal? Modeless? Without seeing the rest of your code I have to just guess. At first glance the problem appears to be that you are not locking your document.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Using DocumentLock docLock = doc.LockDocument {
   Using Transaction trans = db.TransactionManager.StartTransaction {

   }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 14:42:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/unable-create-hatch-after-to-windows-form/m-p/11756718#M9950</guid>
      <dc:creator>hippe013</dc:creator>
      <dc:date>2023-02-15T14:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: Unable  create Hacth after to Windown Form</title>
      <link>https://forums.autodesk.com/t5/net-forum/unable-create-hatch-after-to-windows-form/m-p/11756737#M9951</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I think you are needing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;a LockDocument() method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And change&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;// Add the polyline to the database
                   btr.AppendEntity(pl);
                    trans.AddNewlyCreatedDBObject(pl, true);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And&amp;nbsp; can you see this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/net/draw-polyline-with-hatch-getting-error-einvalidinput/m-p/9632916" target="_blank"&gt;https://forums.autodesk.com/t5/net/draw-polyline-with-hatch-getting-error-einvalidinput/m-p/9632916&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 14:47:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/unable-create-hatch-after-to-windows-form/m-p/11756737#M9951</guid>
      <dc:creator>hosneyalaa</dc:creator>
      <dc:date>2023-02-15T14:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: Unable  create Hacth after to Windown Form</title>
      <link>https://forums.autodesk.com/t5/net-forum/unable-create-hatch-after-to-windows-form/m-p/11756755#M9952</link>
      <description>&lt;P&gt;When i replace Text "mh" by "ANSI31" or specific name. Code woking, but i replace by a variable. It will appear a error.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="traiduong014969_0-1676472642615.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1176910iDA7DD928940D230C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="traiduong014969_0-1676472642615.png" alt="traiduong014969_0-1676472642615.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 14:53:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/unable-create-hatch-after-to-windows-form/m-p/11756755#M9952</guid>
      <dc:creator>traiduong014969</dc:creator>
      <dc:date>2023-02-15T14:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: Unable  create Hacth after to Windown Form</title>
      <link>https://forums.autodesk.com/t5/net-forum/unable-create-hatch-after-to-windows-form/m-p/11756928#M9953</link>
      <description>&lt;P&gt;It's seem that has an error when i add DoccumentLock&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="traiduong014969_0-1676476293734.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1176937iC9FAF83934A70FEC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="traiduong014969_0-1676476293734.png" alt="traiduong014969_0-1676476293734.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 15:53:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/unable-create-hatch-after-to-windows-form/m-p/11756928#M9953</guid>
      <dc:creator>traiduong014969</dc:creator>
      <dc:date>2023-02-15T15:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: Unable  create Hatch after to Windows Form</title>
      <link>https://forums.autodesk.com/t5/net-forum/unable-create-hatch-after-to-windows-form/m-p/11757047#M9954</link>
      <description>"not create hatch from poplyline " should be "Hatch not created from polyline". Polyline only has 1 "p".</description>
      <pubDate>Wed, 15 Feb 2023 16:29:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/unable-create-hatch-after-to-windows-form/m-p/11757047#M9954</guid>
      <dc:creator>Ed__Jobe</dc:creator>
      <dc:date>2023-02-15T16:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: Unable  create Hacth after to Windown Form</title>
      <link>https://forums.autodesk.com/t5/net-forum/unable-create-hatch-after-to-windows-form/m-p/11757074#M9955</link>
      <description>&lt;P&gt;What It is in the error message&lt;/P&gt;&lt;P&gt;add DoccumentLock&amp;nbsp;&lt;/P&gt;&lt;P&gt;As &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1633394"&gt;@hippe013&lt;/a&gt;&amp;nbsp; write&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 16:36:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/unable-create-hatch-after-to-windows-form/m-p/11757074#M9955</guid>
      <dc:creator>hosneyalaa</dc:creator>
      <dc:date>2023-02-15T16:36:12Z</dc:date>
    </item>
    <item>
      <title>Re: Unable  create Hatch after to Windows Form</title>
      <link>https://forums.autodesk.com/t5/net-forum/unable-create-hatch-after-to-windows-form/m-p/11757106#M9956</link>
      <description>&lt;P&gt;This mistake is add apostrophes into "mh"&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;ht.SetHatchPattern(HatchPatternType.PreDefined, "mh");&lt;/LI-CODE&gt;&lt;P&gt;code after fixed&lt;/P&gt;&lt;LI-CODE lang="general"&gt;ht.SetHatchPattern(HatchPatternType.PreDefined, mh);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 16:43:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/unable-create-hatch-after-to-windows-form/m-p/11757106#M9956</guid>
      <dc:creator>traiduong014969</dc:creator>
      <dc:date>2023-02-15T16:43:52Z</dc:date>
    </item>
  </channel>
</rss>

