Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Good evening .
trying to write a code , drawing a circle after picking the center point ,
I choose a center point of a circle but draw it's center in (0,0,0)
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()
{
}
}
}
thanks 🙂
Solved! Go to Solution.