<?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: Getting the coordinate of the lastly appended(added) point object in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/getting-the-coordinate-of-the-lastly-appended-added-point-object/m-p/3442021#M55805</link>
    <description>&lt;P&gt;I encountered with another problem.&lt;/P&gt;&lt;P&gt;If I use "ObjectAppended" event, I cannot get the coordinates value as a return value.&lt;/P&gt;&lt;P&gt;I need the coordinate value in order to manipulate some other variables.&lt;/P&gt;&lt;P&gt;How can I approach this problem?&lt;/P&gt;</description>
    <pubDate>Thu, 03 May 2012 06:52:09 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2012-05-03T06:52:09Z</dc:date>
    <item>
      <title>Getting the coordinate of the lastly appended(added) point object</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-the-coordinate-of-the-lastly-appended-added-point-object/m-p/3441979#M55804</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to get the coordinate of the lastly appended(added) point object.&lt;/P&gt;&lt;P&gt;It seems like I need to use "ObjectAppended" event.&lt;/P&gt;&lt;P&gt;However, when the event is triggred, it looks like the sender object is "Database" (not Point object).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How could I retrieve the point object therefore the coordinates of the point using "Database" (sender object)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(explaination with C# code would be much more thanksful)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jake.&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2012 05:02:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-the-coordinate-of-the-lastly-appended-added-point-object/m-p/3441979#M55804</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-03T05:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the coordinate of the lastly appended(added) point object</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-the-coordinate-of-the-lastly-appended-added-point-object/m-p/3442021#M55805</link>
      <description>&lt;P&gt;I encountered with another problem.&lt;/P&gt;&lt;P&gt;If I use "ObjectAppended" event, I cannot get the coordinates value as a return value.&lt;/P&gt;&lt;P&gt;I need the coordinate value in order to manipulate some other variables.&lt;/P&gt;&lt;P&gt;How can I approach this problem?&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2012 06:52:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-the-coordinate-of-the-lastly-appended-added-point-object/m-p/3442021#M55805</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-03T06:52:09Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the coordinate of the lastly appended(added) point object</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-the-coordinate-of-the-lastly-appended-added-point-object/m-p/3442159#M55806</link>
      <description>&lt;P&gt;Here is a sample code, change to your suit&lt;/P&gt;&lt;PRE&gt;        [CommandMethod("huh")]
        public void AddPointEvents()
        {
            // Get the current document and database, and start a transaction
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            DBPoint dpoint = null;
            db.ObjectAppended += new ObjectEventHandler(db_ObjectAppended);
            Editor ed=doc.Editor;
          
                try
                {
                      using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                    // Open the current space for write
                    BlockTableRecord btr;
                    btr = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;
                    Point3d pt;
                    PromptPointResult pres;
                    pres= ed.GetPoint("\nPick a point: ");
                    if (pres.Status != PromptStatus.OK) return;
                   
                    // Create a point
                      //  pres = ed.GetPoint("\nPick a point: ");
                     pt = pres.Value;
                     dpoint = new DBPoint();
                     dpoint.Position = pt;//&amp;lt;-- position changed separatelly to call db.ObjectAppended event
                     
                    // Add the new point to the block table record and the transaction
                    btr.AppendEntity(dpoint);
                    tr.AddNewlyCreatedDBObject(dpoint, true);
                    
                    // Save the new object to the database
                    tr.Commit();
                    db.ObjectAppended -= new ObjectEventHandler(db_ObjectAppended);
                }
                }
                catch (System.Exception ex)
                {
                    ed.WriteMessage(ex.Message+"\n" + ex.StackTrace);
                }
                finally
                {
                    
                }
                                  
            }
    
        public  void db_ObjectAppended(object sender, ObjectEventArgs e)
        {
            // Get the current document and database, and start a StartOpenCloseTransaction
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            using (Transaction tr = db.TransactionManager.StartOpenCloseTransaction())
            {
                try
                {
                    DBObject dbo = e.DBObject;
                    DBPoint dpoint = dbo as DBPoint;
                    Point3d ins = dpoint.Position;

                    Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage
                        ("\nCoordinates:\tX = {0}; Y = {1}; Z = {2}", ins.X, ins.Y, ins.Z);
                }
                catch (System.Exception ex)
                {
                    Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage
                        (ex.Message + "\n" + ex.StackTrace);
                }
                tr.Commit();
            }
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#993300" face="arial,helvetica,sans-serif"&gt;~'J'~&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2012 10:06:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-the-coordinate-of-the-lastly-appended-added-point-object/m-p/3442159#M55806</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2012-05-03T10:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the coordinate of the lastly appended(added) point object</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-the-coordinate-of-the-lastly-appended-added-point-object/m-p/3443477#M55807</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it may not work for your task, it's not really what you asked for, but it may also be what you may search for and so just to be mentioned:&lt;/P&gt;&lt;P&gt;Sysvar LASTPOINT (&lt;A target="_self" href="http://docs.autodesk.com/ACD/2011/ENU/filesACR/WS1a9193826455f5ffa23ce210c4a30acaf-4f7d.htm"&gt;&amp;gt;&amp;gt;&amp;gt;details&amp;lt;&amp;lt;&amp;lt;&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- alfred -&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2012 20:29:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-the-coordinate-of-the-lastly-appended-added-point-object/m-p/3443477#M55807</guid>
      <dc:creator>Alfred.NESWADBA</dc:creator>
      <dc:date>2012-05-03T20:29:21Z</dc:date>
    </item>
  </channel>
</rss>

