.NET

Reply
Valued Contributor
Ertqwa
Posts: 98
Registered: ‎10-03-2011
Message 1 of 6 (378 Views)
Accepted Solution

Adding objects to the PICKFIRST set.

378 Views, 5 Replies
07-01-2012 03:34 AM

Hello Forum,

 

I add an entity to the PICKFIRST selection set as follows.

 

Editor.SetImpliedSelection(new ObjectId[] { oiTarget });
entTarget.Highlight(); // Entity.

 

After this, I can type the CAD command "erase", and the selected entity is erased. However, if I press the DELETE key the entity is not erased (nothing happens). Why is that?

 

If I select something on screen with my cursor, the DELETE will erase it.

 

Thank you for you time.


Ertqwa wrote:

....

Eventhough AutoCAD still has the focus, if the cursor is outside the drawing area, DELETE key doesn't erase. Same as with my code.

Didn't notice it until now. Not sure if this is an AutoCAD problem, but maybe more of a windows-topic.

 

Thank you.


Base AutoCAD commands act exactly the same way. 

Draw an object,

Move cursor to the ribbon/toolbar area,

Type in SELECT,

Last, the object you drew is selected,

Enter,

Press delete key, nothing will happen.

 

The reason is, I believe, due to the need to track what the mouse is doing outside of the drawing canvas, so the drawing no longer has focus.

Distinguished Contributor
Artvegas
Posts: 104
Registered: ‎04-21-2011
Message 2 of 6 (369 Views)

Re: Adding objects to the PICKFIRST set.

07-01-2012 08:57 AM in reply to: Ertqwa

I tried the following command in both AutoCAD 2012 and 2013 and I had no problem with either ERASE or the DEL key. I didn't need to call Entity.Highlight() for the entities to be highlighted either. Has it got to do with some other part of your code?

 

[CommandMethod("MyCommand")]
static public void MyCommand()
{
	Document doc = Application.DocumentManager.MdiActiveDocument;
	Editor ed = doc.Editor;

	PromptEntityResult per = ed.GetEntity("\nSelect entity: ");
	if (per.Status != PromptStatus.OK) return;

	ObjectId id = per.ObjectId;

	ed.SetImpliedSelection(new ObjectId[] { id });
}

 Art

Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 3 of 6 (356 Views)

Re: Adding objects to the PICKFIRST set.

07-01-2012 08:47 PM in reply to: Artvegas

You need to define your command method with the CommandFlags.Redraw flag in order to set the pickfirst selection.

Valued Contributor
Ertqwa
Posts: 98
Registered: ‎10-03-2011
Message 4 of 6 (343 Views)

Re: Adding objects to the PICKFIRST set.

07-02-2012 10:35 AM in reply to: Artvegas

Hello,

 

you are right, I do not need to use highlight. Nice one.

 

You're code works, unless I do the following:

- Draw a rectangle.

- Move the cursor onto a toolbar (outside the drawing area).

- Active your command by typing the command name.

- Select the entity by typing "last" (so I don't have to move the cursor).

- Pressing the DELETE key: entity doesn't get delete.

- As soon as I move the mouse back into the drawing area, the DELETE key works again.

 

Eventhough AutoCAD still has the focus, if the cursor is outside the drawing area, DELETE key doesn't erase. Same as with my code.

Didn't notice it until now. Not sure if this is an AutoCAD problem, but maybe more of a windows-topic.

 

Thank you.

Valued Contributor
Ertqwa
Posts: 98
Registered: ‎10-03-2011
Message 5 of 6 (341 Views)

Re: Adding objects to the PICKFIRST set.

07-02-2012 10:51 AM in reply to: DiningPhilosopher

Hello.

 

Redraw:

When the pickfirst set or grip set are retrieved, they are not cleared within AutoCAD.
Command can retrieve the pickfirst set and the grip set by using the ads_ssgetfirst function.
Command can retrieve the pickfirst set via ads_ssget("I.").
Command can set both the pickfirst and grip sets using the ads_sssetfirst function. Objects in these sets are redrawn with the proper grip handles and highlighting upon completion of the command. 

Seems like I should use it, but without it the command works exactly the same. It doesn't solve the problem.
Thank you for your response.

*Expert Elite*
Jeff_M
Posts: 4,368
Registered: ‎07-22-2003
Message 6 of 6 (318 Views)

Re: Adding objects to the PICKFIRST set.

07-03-2012 07:54 AM in reply to: Ertqwa

Ertqwa wrote:

....

Eventhough AutoCAD still has the focus, if the cursor is outside the drawing area, DELETE key doesn't erase. Same as with my code.

Didn't notice it until now. Not sure if this is an AutoCAD problem, but maybe more of a windows-topic.

 

Thank you.


Base AutoCAD commands act exactly the same way. 

Draw an object,

Move cursor to the ribbon/toolbar area,

Type in SELECT,

Last, the object you drew is selected,

Enter,

Press delete key, nothing will happen.

 

The reason is, I believe, due to the need to track what the mouse is doing outside of the drawing canvas, so the drawing no longer has focus.

Jeff_M, also a frequent Swamper
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.