.NET

Reply
Active Member
yessef
Posts: 8
Registered: ‎07-31-2013
Message 1 of 8 (475 Views)
Accepted Solution

PromptSelectionResult Error

475 Views, 7 Replies
07-31-2013 06:08 PM

Hi.

I have this code that selects entities from a layer based on its name. It works for all layers in my document except one. PromptSelectionResult always returns Error when it should return some objectIds.

here is the code :

 

Parcelle plle = GetParcelle(index);
ObjectIdCollection result = new ObjectIdCollection(); Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; Editor ed = doc.Editor; double tolerance = 1; TypedValue[] tvs = new TypedValue[1] { new TypedValue((int) DxfCode.LayerName, LayerName) }; SelectionFilter sf = new SelectionFilter(tvs); foreach (Point3d p in plle.Bornes3D) { Point3dCollection points = new Point3dCollection(); points.Add(new Point3d(p.X - tolerance, p.Y - tolerance, 0.0)); points.Add(new Point3d(p.X - tolerance, p.Y + tolerance, 0.0)); points.Add(new Point3d(p.X + tolerance, p.Y + tolerance, 0.0)); points.Add(new Point3d(p.X + tolerance, p.Y - tolerance, 0.0)); PromptSelectionResult psr = ed.SelectCrossingPolygon(points, sf); if (psr.Status == PromptStatus.OK) { ObjectId[] ids = psr.Value.GetObjectIds(); foreach (var id in ids) { if (CheckOldLimit(plle, id)) continue; result.Add(id); } } }

Any suggestions on what could be the problem ?. I think the problem is not in the code but in the layer properties.

Thanks.

Nevermind, I reinstalled Autocad and ObjectARX and it worked. Thanks for your time and sorry for the trouble.

Distinguished Mentor
gasty1001
Posts: 582
Registered: ‎04-11-2010
Message 2 of 8 (433 Views)

Re: PromptSelectionResult Error

08-01-2013 06:34 AM in reply to: yessef

Hi,

 

Are the entities full visible on screen?, crossing selection, and other graphics selection methods too, need the entities to be visible on screen.

 

Gaston Nunez 

*Expert Elite*
norman.yuan
Posts: 1,063
Registered: ‎04-27-2009
Message 3 of 8 (429 Views)

Re: PromptSelectionResult Error

08-01-2013 06:46 AM in reply to: yessef

Ediotr.SelectXXXX() method's return status would be Error if no entity is selected.

 

So, if you get PromptStatus.Error back after calling SelectXXX(), it means the selecting process does not find anything with the given selecting filter. In you case, you have filter on Layer name, you also have a filter of defined polygon.

 

When selecting by window/polygon, you MUST make sure the window/polygon in within visible screen area (current view), or the SelectXXX() would return error, which may be the course of your issue. Usually, before calling Ediotr.SelectWindow/Polygon or SelectCrossingWindow/Polygon(), it is better to zoom to a window that is just big enough to contain the selecting window/polygon.

 

So, you can verify it by zoom the view to make sure all the selecting polygon/window points are located in the visible area, and then run your code to see if you still get Error status back.

 

Active Member
yessef
Posts: 8
Registered: ‎07-31-2013
Message 4 of 8 (418 Views)

Re: PromptSelectionResult Error

08-01-2013 12:30 PM in reply to: yessef

Yes the entities are all visible. I do Zoom Extents before executing the code. The code executes for all layers except one, meaning that it selects entities on all other layers but not that one. What I suspect is that there is some problem with this particular layer of mine that makes it invisible to SelectCrossingPolygon. Anyway, thank you for your answers.

Distinguished Mentor
gasty1001
Posts: 582
Registered: ‎04-11-2010
Message 5 of 8 (413 Views)

Re: PromptSelectionResult Error

08-01-2013 01:11 PM in reply to: yessef

Hi,

 

Can you post a sample drawing?

 

Gaston Nunez

Active Member
yessef
Posts: 8
Registered: ‎07-31-2013
Message 6 of 8 (404 Views)

Re: PromptSelectionResult Error

08-01-2013 04:39 PM in reply to: yessef

Here it is in the attachments.

Thank you for taking the time.

Active Member
yessef
Posts: 8
Registered: ‎07-31-2013
Message 7 of 8 (402 Views)

Re: PromptSelectionResult Error

08-01-2013 04:41 PM in reply to: yessef

Oh, I forgot. the layer in question is named "Lima".

Active Member
yessef
Posts: 8
Registered: ‎07-31-2013
Message 8 of 8 (393 Views)

Re: PromptSelectionResult Error

08-01-2013 09:48 PM in reply to: yessef

Nevermind, I reinstalled Autocad and ObjectARX and it worked. Thanks for your time and sorry for the trouble.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.