<?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: Click Button to draw a Polyline in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/click-button-to-draw-a-polyline/m-p/2423033#M71926</link>
    <description>&lt;P&gt;&lt;BR /&gt;I build a class like this:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;public class LithorLayer&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;public void DisplayInModelSpace(Editor Ed)&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;Polyline PlLay;&lt;BR /&gt;&lt;BR /&gt;BlockTableRecord btr;&lt;BR /&gt;&lt;BR /&gt;BlockTable bt;&lt;BR /&gt;&lt;BR /&gt;Database Db;&lt;BR /&gt;&lt;BR /&gt;Transaction trans;&lt;BR /&gt;&lt;BR /&gt;Db = HostApplicationServices.WorkingDatabase;&lt;BR /&gt;&lt;BR /&gt;trans = Db.TransactionManager.StartTransaction();&lt;BR /&gt;&lt;BR /&gt;try&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;PlLay = new Polyline(5);&lt;BR /&gt;&lt;BR /&gt;PlLay.AddVertexAt(0, new Point2d(0, 0), 0, -1, -1);&lt;BR /&gt;&lt;BR /&gt;PlLay.AddVertexAt(1, new Point2d(1, 0), 0, -1, -1);&lt;BR /&gt;&lt;BR /&gt;PlLay.AddVertexAt(2, new Point2d(1, 1), 0, -1, -1);&lt;BR /&gt;&lt;BR /&gt;PlLay.AddVertexAt(3, new Point2d(0, 1), 0, -1, -1);&lt;BR /&gt;&lt;BR /&gt;PlLay.AddVertexAt(4, new Point2d(0, 0), 0, -1, -1);&lt;BR /&gt;&lt;BR /&gt;bt = (BlockTable)trans.GetObject(Db.BlockTableId, OpenMode.ForRead);&lt;BR /&gt;&lt;BR /&gt;btr = (BlockTableRecord)trans.GetObject(Db.CurrentSpaceId, OpenMode.ForWrite);&lt;BR /&gt;&lt;BR /&gt;btr.AppendEntity(PlLay);&lt;BR /&gt;&lt;BR /&gt;trans.AddNewlyCreatedDBObject(PlLay, true);&lt;BR /&gt;&lt;BR /&gt;trans.Commit();&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;catch&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;Ed.WriteMessage("Error\n");&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;finally&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;trans.Dispose();&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;and use it in command like this:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;public class tdcCommands&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;public tdcCommands()&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;[CommandMethod("Pll")]&lt;BR /&gt;&lt;BR /&gt;static public void Pll()&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;&lt;BR /&gt;&lt;BR /&gt;LithorLayer Lop;&lt;BR /&gt;&lt;BR /&gt;Lop = new LithorLayer();&lt;BR /&gt;&lt;BR /&gt;Lop.DisplayInModelSpace(ed);&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;It work!!!&lt;BR /&gt;&lt;BR /&gt;But when I use like:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;private void button1_Click(object sender, EventArgs e)&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;&lt;BR /&gt;&lt;BR /&gt;LithorLayer Lop;&lt;BR /&gt;&lt;BR /&gt;Lop = new LithorLayer();&lt;BR /&gt;&lt;BR /&gt;Lop.DisplayInModelSpace(ed);&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;with button1 is a command button on a palette.&lt;BR /&gt;&lt;BR /&gt;it doesn't work&lt;BR /&gt;&lt;BR /&gt;Help me!! Thanks so much&lt;BR /&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;

Edited by: ledungtdc on Feb 4, 2009 9:52 AM</description>
    <pubDate>Wed, 04 Feb 2009 02:37:35 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2009-02-04T02:37:35Z</dc:date>
    <item>
      <title>Click Button to draw a Polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/click-button-to-draw-a-polyline/m-p/2423031#M71924</link>
      <description>I'm coding to get all coordinates from a datagridview in palette, but it has some problems:&lt;BR /&gt;&lt;BR /&gt;If use sub to add polyline individual, it work correct, but when insert this sub into click even of button (button1_click) it can't work&lt;BR /&gt;&lt;BR /&gt;How to do it?&lt;BR /&gt;&lt;BR /&gt;thanks</description>
      <pubDate>Tue, 03 Feb 2009 08:57:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/click-button-to-draw-a-polyline/m-p/2423031#M71924</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-02-03T08:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: Click Button to draw a Polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/click-button-to-draw-a-polyline/m-p/2423032#M71925</link>
      <description>&lt;DIV id="jive-html-wrapper-div"&gt;
&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&amp;lt;quote&amp;gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;"If use sub to add polyline individual, it work correct"&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&amp;lt;/quote&amp;gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;How do you use the "sub", do you mean a subroutine &lt;BR /&gt;
decorated with CommandMethod attribute?&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;What does "it can't work" mean? Whay exception your &lt;BR /&gt;
code runs into?&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;Since you mentioned palette, is the said button on &lt;BR /&gt;
the palette? If so, it is very likely you need to lock the Document. &lt;BR /&gt;
&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;Finally, vague description and not showing relevant &lt;BR /&gt;
code&amp;nbsp;does not help to find answer to your question.&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;BR /&gt;
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"&amp;gt;&lt;BR /&gt;
  &lt;DIV&gt;"ledungtdc" wrote in message &lt;A&gt;&lt;BR /&gt;
  href="news:6116836@discussion.autodesk.com"&amp;gt;news:6116836@discussion.autodesk.com&lt;/A&gt;...&lt;/DIV&gt;I'm &lt;BR /&gt;
  coding to get all coordinates from a datagridview in palette, but it has some &lt;BR /&gt;
  problems:&lt;BR /&gt;&lt;BR /&gt;If use sub to add polyline individual, it work correct, but &lt;BR /&gt;
  when insert this sub into click even of button (button1_click) it can't &lt;BR /&gt;
  work&lt;BR /&gt;&lt;BR /&gt;How to do it?&lt;BR /&gt;&lt;BR /&gt;thanks&lt;/BLOCKQUOTE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 03 Feb 2009 13:51:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/click-button-to-draw-a-polyline/m-p/2423032#M71925</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-02-03T13:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: Click Button to draw a Polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/click-button-to-draw-a-polyline/m-p/2423033#M71926</link>
      <description>&lt;P&gt;&lt;BR /&gt;I build a class like this:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;public class LithorLayer&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;public void DisplayInModelSpace(Editor Ed)&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;Polyline PlLay;&lt;BR /&gt;&lt;BR /&gt;BlockTableRecord btr;&lt;BR /&gt;&lt;BR /&gt;BlockTable bt;&lt;BR /&gt;&lt;BR /&gt;Database Db;&lt;BR /&gt;&lt;BR /&gt;Transaction trans;&lt;BR /&gt;&lt;BR /&gt;Db = HostApplicationServices.WorkingDatabase;&lt;BR /&gt;&lt;BR /&gt;trans = Db.TransactionManager.StartTransaction();&lt;BR /&gt;&lt;BR /&gt;try&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;PlLay = new Polyline(5);&lt;BR /&gt;&lt;BR /&gt;PlLay.AddVertexAt(0, new Point2d(0, 0), 0, -1, -1);&lt;BR /&gt;&lt;BR /&gt;PlLay.AddVertexAt(1, new Point2d(1, 0), 0, -1, -1);&lt;BR /&gt;&lt;BR /&gt;PlLay.AddVertexAt(2, new Point2d(1, 1), 0, -1, -1);&lt;BR /&gt;&lt;BR /&gt;PlLay.AddVertexAt(3, new Point2d(0, 1), 0, -1, -1);&lt;BR /&gt;&lt;BR /&gt;PlLay.AddVertexAt(4, new Point2d(0, 0), 0, -1, -1);&lt;BR /&gt;&lt;BR /&gt;bt = (BlockTable)trans.GetObject(Db.BlockTableId, OpenMode.ForRead);&lt;BR /&gt;&lt;BR /&gt;btr = (BlockTableRecord)trans.GetObject(Db.CurrentSpaceId, OpenMode.ForWrite);&lt;BR /&gt;&lt;BR /&gt;btr.AppendEntity(PlLay);&lt;BR /&gt;&lt;BR /&gt;trans.AddNewlyCreatedDBObject(PlLay, true);&lt;BR /&gt;&lt;BR /&gt;trans.Commit();&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;catch&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;Ed.WriteMessage("Error\n");&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;finally&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;trans.Dispose();&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;and use it in command like this:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;public class tdcCommands&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;public tdcCommands()&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;[CommandMethod("Pll")]&lt;BR /&gt;&lt;BR /&gt;static public void Pll()&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;&lt;BR /&gt;&lt;BR /&gt;LithorLayer Lop;&lt;BR /&gt;&lt;BR /&gt;Lop = new LithorLayer();&lt;BR /&gt;&lt;BR /&gt;Lop.DisplayInModelSpace(ed);&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;It work!!!&lt;BR /&gt;&lt;BR /&gt;But when I use like:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;private void button1_Click(object sender, EventArgs e)&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;&lt;BR /&gt;&lt;BR /&gt;LithorLayer Lop;&lt;BR /&gt;&lt;BR /&gt;Lop = new LithorLayer();&lt;BR /&gt;&lt;BR /&gt;Lop.DisplayInModelSpace(ed);&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;with button1 is a command button on a palette.&lt;BR /&gt;&lt;BR /&gt;it doesn't work&lt;BR /&gt;&lt;BR /&gt;Help me!! Thanks so much&lt;BR /&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;

Edited by: ledungtdc on Feb 4, 2009 9:52 AM</description>
      <pubDate>Wed, 04 Feb 2009 02:37:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/click-button-to-draw-a-polyline/m-p/2423033#M71926</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-02-04T02:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: Click Button to draw a Polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/click-button-to-draw-a-polyline/m-p/2423034#M71927</link>
      <description>&lt;DIV id="jive-html-wrapper-div"&gt;
&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;As I expected in previous reply, you need to lock &lt;BR /&gt;
the document when modifying drawing database from modeless form/palette. If you &lt;BR /&gt;
do it from a modal form, it should work as you do from command line. Do not ask &lt;BR /&gt;
me why: that is how autodesk implements the drawing database transaction. &lt;BR /&gt;
&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;So, you need to change your code similar to &lt;BR /&gt;
this:&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;//Note, the argument doc, you can get it prior to &lt;BR /&gt;
calling this method&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;//from Application.DocumentManager.MdiDocument, as &lt;BR /&gt;
long as &lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;//it is a Document object. That is, you need to get &lt;BR /&gt;
a hold on a drawing &lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;//document, to which you intent to modify its &lt;BR /&gt;
database, and lock it&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;//during the database change, then release the &lt;BR /&gt;
lock.&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;public void MakeChangeToDrawingDatabase(Document &lt;BR /&gt;
doc)&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;{&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; using (DocumentLock &lt;BR /&gt;
lk=doc.LockDocument())&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //Add/Modify &lt;BR /&gt;
your polyline, or whatever entities here&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //you can use &lt;BR /&gt;
try...catch...finally, if you prefer, as your code shown&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //but "using" &lt;BR /&gt;
might be more suitable to wrap a transaction&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; using &lt;BR /&gt;
(Transaction &lt;BR /&gt;
tran=doc.Database.TransactionManager.StartTransaction())&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;
{&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; //code to add/modify&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;
}&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;}&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;BR /&gt;
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"&amp;gt;&lt;BR /&gt;
  &lt;DIV&gt;"ledungtdc" wrote in message &lt;A&gt;&lt;BR /&gt;
  href="news:6117704@discussion.autodesk.com"&amp;gt;news:6117704@discussion.autodesk.com&lt;/A&gt;...&lt;/DIV&gt;&lt;BR /&gt;
  &lt;P&gt;&lt;BR /&gt;I build a class like this:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;public class &lt;BR /&gt;
  LithorLayer&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;public void DisplayInModelSpace(Editor &lt;BR /&gt;
  Ed)&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;Polyline PlLay;&lt;BR /&gt;&lt;BR /&gt;BlockTableRecord &lt;BR /&gt;
  btr;&lt;BR /&gt;&lt;BR /&gt;BlockTable bt;&lt;BR /&gt;&lt;BR /&gt;Database Db;&lt;BR /&gt;&lt;BR /&gt;Transaction &lt;BR /&gt;
  trans;&lt;BR /&gt;&lt;BR /&gt;Db = HostApplicationServices.WorkingDatabase;&lt;BR /&gt;&lt;BR /&gt;trans = &lt;BR /&gt;
  Db.TransactionManager.StartTransaction();&lt;BR /&gt;&lt;BR /&gt;try&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;PlLay = &lt;BR /&gt;
  new Polyline(5);&lt;BR /&gt;&lt;BR /&gt;PlLay.AddVertexAt(0, new Point2d(0, 0), 0, -1, &lt;BR /&gt;
  -1);&lt;BR /&gt;&lt;BR /&gt;PlLay.AddVertexAt(1, new Point2d(1, 0), 0, -1, &lt;BR /&gt;
  -1);&lt;BR /&gt;&lt;BR /&gt;PlLay.AddVertexAt(2, new Point2d(1, 1), 0, -1, &lt;BR /&gt;
  -1);&lt;BR /&gt;&lt;BR /&gt;PlLay.AddVertexAt(3, new Point2d(0, 1), 0, -1, &lt;BR /&gt;
  -1);&lt;BR /&gt;&lt;BR /&gt;PlLay.AddVertexAt(4, new Point2d(0, 0), 0, -1, -1);&lt;BR /&gt;&lt;BR /&gt;bt = &lt;BR /&gt;
  (BlockTable)trans.GetObject(Db.BlockTableId, OpenMode.ForRead);&lt;BR /&gt;&lt;BR /&gt;btr = &lt;BR /&gt;
  (BlockTableRecord)trans.GetObject(Db.CurrentSpaceId, &lt;BR /&gt;
  OpenMode.ForWrite);&lt;BR /&gt;&lt;BR /&gt;btr.AppendEntity(PlLay);&lt;BR /&gt;&lt;BR /&gt;trans.AddNewlyCreatedDBObject(PlLay, &lt;BR /&gt;
  true);&lt;BR /&gt;&lt;BR /&gt;trans.Commit();&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;catch&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;Ed.WriteMessage("Error\n");&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;finally&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;trans.Dispose();&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;and &lt;BR /&gt;
  use it in command like this:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;public class &lt;BR /&gt;
  tdcCommands&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;public &lt;BR /&gt;
  tdcCommands()&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;[CommandMethod("Pll")]&lt;BR /&gt;&lt;BR /&gt;static &lt;BR /&gt;
  public void Pll()&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;Editor ed = &lt;BR /&gt;
  Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;&lt;BR /&gt;&lt;BR /&gt;LithorLayer &lt;BR /&gt;
  Lop;&lt;BR /&gt;&lt;BR /&gt;Lop = new &lt;BR /&gt;
  LithorLayer();&lt;BR /&gt;&lt;BR /&gt;Lop.DisplayInModelSpace(ed);&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;It &lt;BR /&gt;
  work!!!&lt;BR /&gt;&lt;BR /&gt;But when I use like:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;private void &lt;BR /&gt;
  button1_Click(object sender, EventArgs e)&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;Editor ed = &lt;BR /&gt;
  Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;&lt;BR /&gt;&lt;BR /&gt;LithorLayer &lt;BR /&gt;
  Lop;&lt;BR /&gt;&lt;BR /&gt;Lop = new &lt;BR /&gt;
  LithorLayer();&lt;BR /&gt;&lt;BR /&gt;Lop.DisplayInModelSpace(ed);&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;with &lt;BR /&gt;
  button1 is a command button on a palette.&lt;BR /&gt;&lt;BR /&gt;it doesn't work&lt;BR /&gt;&lt;BR /&gt;Help &lt;BR /&gt;
  me!! Thanks so much&lt;BR /&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Edited by: ledungtdc on Feb 4, 2009 &lt;BR /&gt;
  9:52 AM&lt;/BLOCKQUOTE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 04 Feb 2009 14:25:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/click-button-to-draw-a-polyline/m-p/2423034#M71927</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-02-04T14:25:00Z</dc:date>
    </item>
    <item>
      <title>Re: Click Button to draw a Polyline</title>
      <link>https://forums.autodesk.com/t5/net-forum/click-button-to-draw-a-polyline/m-p/2423035#M71928</link>
      <description>Thanks so much! It works</description>
      <pubDate>Thu, 05 Feb 2009 01:54:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/click-button-to-draw-a-polyline/m-p/2423035#M71928</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-02-05T01:54:25Z</dc:date>
    </item>
  </channel>
</rss>

