.NET

Reply
Distinguished Contributor
vince1327
Posts: 117
Registered: ‎11-02-2011
Message 11 of 14 (103 Views)

Re: Erase last object

03-21-2012 06:30 AM in reply to: gasty1001

Haha didn't even notice that. Now when i change it to ss[0], i get 

 

Error 1 Cannot implicitly convert type 'Autodesk.AutoCAD.DatabaseServices.DBObject' to 'Autodesk.AutoCAD.DatabaseServices.Entity'. An explicit conversion exists (are you missing a cast?) C:\Users\user\Dropbox\Programming\Cad\Cad\TheProgram\Drawing Commands\Copy of AREA.cs 28 27 Commands

 

 

if (ss.Count > 0)
{
ent = acTrans.GetObject(ss[0].ObjectId, OpenMode.ForWrite);
ent.Erase();
}
acTrans.Commit();

Distinguished Contributor
vince1327
Posts: 117
Registered: ‎11-02-2011
Message 12 of 14 (100 Views)

Re: Erase last object

03-21-2012 06:47 AM in reply to: vince1327

Scratch that, fixed it :smileywink:

 

public void EraseObj()
{
Document acDoc = Application.DocumentManager.MdiActiveDocument;
Database acCurDb = acDoc.Database;
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
{
PromptSelectionResult acSSPrompt;
acSSPrompt = ed.SelectLast();
Entity ent;
SelectionSet ss = acSSPrompt.Value;

if (ss.Count > 0)
{
ent = acTrans.GetObject(ss[0].ObjectId, OpenMode.ForWrite) as Entity;
ent.Erase();
}
acTrans.Commit();
}
}
}
}

 

Thanks a million for your help!

 

Valued Mentor
Posts: 376
Registered: ‎04-11-2010
Message 13 of 14 (98 Views)

Re: Erase last object

03-21-2012 07:02 AM in reply to: vince1327

Hi,

 

Glad to help you, sorry the mistake, i feel much comfortable with vb 'cause I'd like to see "End this", "End That"... instead of a lot of brackets at the end of a block of code.

 

Gaston Nunez

Distinguished Contributor
vince1327
Posts: 117
Registered: ‎11-02-2011
Message 14 of 14 (96 Views)

Re: Erase last object

03-21-2012 07:11 AM in reply to: gasty1001

No worries, thanks again!

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community