Thank you.
when I working in the code, I found I have problem to create a object as Curve2d. Could you what's wrong in my code? Thank you very much.
here is the code:
using System ;
using Autodesk.AutoCAD.Runtime ;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
[assembly: CommandClass(typeof(ClassLibrary.RSClass))]
namespace ClassLibrary
{
///
/// Summary description for RSClass.
///
public class RSClass
{
// Define Command "AsdkCmd1"
[CommandMethod("OffsetEnt")]
static public void test() // This method can have any name
{
// Put your command code here
Database db = HostApplicationServices.WorkingDatabase;
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
Transaction trans = db.TransactionManager.StartTransaction();
try
{
PromptEntityOptions prEnt = new PromptEntityOptions("Select a polyline:");
PromptEntityResult prEntRes = ed.GetEntity(prEnt);
if (prEntRes.Status != PromptStatus.OK )
{
return;
}
ObjectId id = prEntRes.ObjectId;
Entity opl = (Entity)trans.GetObject(id,OpenMode.ForWrite,true);
Curve2d cvPl = (Curve2d)opl; // <<<--- here is my problem.
OffsetCurve2d oOff = new OffsetCurve2d(cvPl, 2);
}
finally
{
}
}
}
}
Message was edited by: weslleywang
Windows 10 64 bit, AutoCAD (ACA, Map) 2023