<?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 I choose a center point of a circle but draw it's center in (0,0,0) in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/i-choose-a-center-point-of-a-circle-but-draw-it-s-center-in-0-0/m-p/10225970#M16802</link>
    <description>&lt;P&gt;Good evening .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;trying to write a code , drawing a circle after picking the center point ,&lt;/P&gt;&lt;P&gt;I choose a center point of a circle but draw it's center in (0,0,0)&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using System;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;

[assembly: ExtensionApplication(typeof(GetPointTest2.test2))]

namespace GetPointTest2
{
public class test2:IExtensionApplication
{
[CommandMethod("test2")]
public void t2()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database dbs = doc.Database;
Editor editr = doc.Editor;
Transaction trans = dbs.TransactionManager.StartTransaction();
ObjectId modspc = dbs.CurrentSpaceId;
BlockTableRecord blkrec = trans.GetObject(modspc, OpenMode.ForWrite) as BlockTableRecord;
try
{
PromptPointOptions ppo = new PromptPointOptions("\n Pick a point ");
ppo.AllowArbitraryInput = false;
ppo.AllowNone = true;
PromptPointResult ppr1 = editr.GetPoint(ppo);
if (ppr1.Status!=PromptStatus.OK)
{
return;
}
ppo.BasePoint = ppr1.Value;
ppo.UseBasePoint = true;
PromptPointResult ppr2 = editr.GetPoint(ppo);
if (ppr2.Status!=PromptStatus.OK)
{
return;
}
Point3d cntr = new Point3d(ppo.BasePoint.X, ppo.BasePoint.Y, ppo.BasePoint.Z);
Vector3d vect = new Vector3d();
double rad = 10;
Circle circle = new Circle(cntr, vect, rad);
blkrec.AppendEntity(circle);
trans.AddNewlyCreatedDBObject(circle, true);
}
catch (Autodesk.AutoCAD.Runtime.Exception excep)
{
Application.ShowAlertDialog("" + excep );
}
trans.Commit();
}
void IExtensionApplication.Initialize()
{

}
void IExtensionApplication.Terminate()
{

}
}
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Apr 2021 19:20:19 GMT</pubDate>
    <dc:creator>almutaz_86</dc:creator>
    <dc:date>2021-04-09T19:20:19Z</dc:date>
    <item>
      <title>I choose a center point of a circle but draw it's center in (0,0,0)</title>
      <link>https://forums.autodesk.com/t5/net-forum/i-choose-a-center-point-of-a-circle-but-draw-it-s-center-in-0-0/m-p/10225970#M16802</link>
      <description>&lt;P&gt;Good evening .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;trying to write a code , drawing a circle after picking the center point ,&lt;/P&gt;&lt;P&gt;I choose a center point of a circle but draw it's center in (0,0,0)&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using System;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;

[assembly: ExtensionApplication(typeof(GetPointTest2.test2))]

namespace GetPointTest2
{
public class test2:IExtensionApplication
{
[CommandMethod("test2")]
public void t2()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database dbs = doc.Database;
Editor editr = doc.Editor;
Transaction trans = dbs.TransactionManager.StartTransaction();
ObjectId modspc = dbs.CurrentSpaceId;
BlockTableRecord blkrec = trans.GetObject(modspc, OpenMode.ForWrite) as BlockTableRecord;
try
{
PromptPointOptions ppo = new PromptPointOptions("\n Pick a point ");
ppo.AllowArbitraryInput = false;
ppo.AllowNone = true;
PromptPointResult ppr1 = editr.GetPoint(ppo);
if (ppr1.Status!=PromptStatus.OK)
{
return;
}
ppo.BasePoint = ppr1.Value;
ppo.UseBasePoint = true;
PromptPointResult ppr2 = editr.GetPoint(ppo);
if (ppr2.Status!=PromptStatus.OK)
{
return;
}
Point3d cntr = new Point3d(ppo.BasePoint.X, ppo.BasePoint.Y, ppo.BasePoint.Z);
Vector3d vect = new Vector3d();
double rad = 10;
Circle circle = new Circle(cntr, vect, rad);
blkrec.AppendEntity(circle);
trans.AddNewlyCreatedDBObject(circle, true);
}
catch (Autodesk.AutoCAD.Runtime.Exception excep)
{
Application.ShowAlertDialog("" + excep );
}
trans.Commit();
}
void IExtensionApplication.Initialize()
{

}
void IExtensionApplication.Terminate()
{

}
}
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Apr 2021 19:20:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/i-choose-a-center-point-of-a-circle-but-draw-it-s-center-in-0-0/m-p/10225970#M16802</guid>
      <dc:creator>almutaz_86</dc:creator>
      <dc:date>2021-04-09T19:20:19Z</dc:date>
    </item>
    <item>
      <title>Re: I choose a center point of a circle but draw it's center in (0,0,0)</title>
      <link>https://forums.autodesk.com/t5/net-forum/i-choose-a-center-point-of-a-circle-but-draw-it-s-center-in-0-0/m-p/10226254#M16803</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6418328"&gt;@almutaz_86&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;why you ask for 2 points&amp;nbsp;&lt;/P&gt;&lt;P&gt;try this&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;PromptPointOptions ppo = new PromptPointOptions("\n Pick a point ");
ppo.AllowArbitraryInput = false;
ppo.AllowNone = true;
PromptPointResult ppr1 = editr.GetPoint(ppo);
if (ppr1.Status!=PromptStatus.OK)
{
return;
}

Vector3d vect = new Vector3d();
double rad = 10;
Circle circle = new Circle(ppr1.Value, vect, rad);&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 09 Apr 2021 21:01:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/i-choose-a-center-point-of-a-circle-but-draw-it-s-center-in-0-0/m-p/10226254#M16803</guid>
      <dc:creator>essam-salah</dc:creator>
      <dc:date>2021-04-09T21:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: I choose a center point of a circle but draw it's center in (0,0,0)</title>
      <link>https://forums.autodesk.com/t5/net-forum/i-choose-a-center-point-of-a-circle-but-draw-it-s-center-in-0-0/m-p/10226312#M16804</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;There are many things in your code that are not very clean or even wrong:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;you must dispose of the transaction (the simplest way is to wrap it in a using statement)&lt;/LI&gt;
&lt;LI&gt;passing a new Vector3d() (i.e., a null vector (0, 0, 0)) to the Circle constructor is certainly the cause of your error&lt;/LI&gt;
&lt;LI&gt;you should not commit the transaction outside of the try block&lt;/LI&gt;
&lt;LI&gt;you should not write useless code (as for a second point)&lt;/LI&gt;
&lt;LI&gt;you should use a separated class to implement IExtensionApplication if you need this (unused here)&lt;/LI&gt;
&lt;/UL&gt;
&lt;LI-CODE lang="csharp"&gt;using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;

[assembly: CommandClass(typeof(GetPointTest2.Test2))]

namespace GetPointTest2
{
    public class Test2
    {
        [CommandMethod("TEST2")]
        public static void Test()
        {
            var doc = Application.DocumentManager.MdiActiveDocument;
            var db = doc.Database;
            var ed = doc.Editor;
            var ppr = ed.GetPoint("\n Pick a point ");
            if (ppr.Status != PromptStatus.OK)
                return;
            var center = ppr.Value;
            using (var tr = db.TransactionManager.StartTransaction())
            {
                var circle = new Circle(center, Vector3d.ZAxis, 10.0);
                circle.TransformBy(ed.CurrentUserCoordinateSystem);
                var space = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
                space.AppendEntity(circle);
                tr.AddNewlyCreatedDBObject(circle, true);
                tr.Commit();
            }
        }
    }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 09 Apr 2021 21:29:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/i-choose-a-center-point-of-a-circle-but-draw-it-s-center-in-0-0/m-p/10226312#M16804</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2021-04-09T21:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: I choose a center point of a circle but draw it's center in (0,0,0)</title>
      <link>https://forums.autodesk.com/t5/net-forum/i-choose-a-center-point-of-a-circle-but-draw-it-s-center-in-0-0/m-p/10226696#M16805</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;for your important notes, there is some codeblocks I was think its necessary&lt;/P&gt;&lt;P&gt;I'm still in first step of .net api&amp;nbsp; of AutoCAD&lt;/P&gt;&lt;P&gt;thank you again .&lt;/P&gt;</description>
      <pubDate>Sat, 10 Apr 2021 03:36:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/i-choose-a-center-point-of-a-circle-but-draw-it-s-center-in-0-0/m-p/10226696#M16805</guid>
      <dc:creator>almutaz_86</dc:creator>
      <dc:date>2021-04-10T03:36:31Z</dc:date>
    </item>
    <item>
      <title>Re: I choose a center point of a circle but draw it's center in (0,0,0)</title>
      <link>https://forums.autodesk.com/t5/net-forum/i-choose-a-center-point-of-a-circle-but-draw-it-s-center-in-0-0/m-p/10226717#M16806</link>
      <description>&lt;P&gt;&lt;FONT size="2"&gt;Thanks &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3650456"&gt;@essam-salah&lt;/a&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I tried your way, But its not working.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Apr 2021 04:01:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/i-choose-a-center-point-of-a-circle-but-draw-it-s-center-in-0-0/m-p/10226717#M16806</guid>
      <dc:creator>almutaz_86</dc:creator>
      <dc:date>2021-04-10T04:01:09Z</dc:date>
    </item>
  </channel>
</rss>

