.NET

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

PromptSelectionResult Error

380 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.

Valued Mentor
gasty1001
Posts: 448
Registered: ‎04-11-2010
Message 2 of 8 (338 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: 961
Registered: ‎04-27-2009
Message 3 of 8 (334 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 (323 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.

Valued Mentor
gasty1001
Posts: 448
Registered: ‎04-11-2010
Message 5 of 8 (318 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 (309 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 (307 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 (298 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.

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
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 to get help installing your software.

Ask the Community