.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PromptSelectionResult Error

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
yessef
2921 Views, 7 Replies

PromptSelectionResult Error

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.

7 REPLIES 7
Message 2 of 8
hgasty1001
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 

Message 3 of 8
norman.yuan
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.

 

Message 4 of 8
yessef
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.

Message 5 of 8
hgasty1001
in reply to: yessef

Hi,

 

Can you post a sample drawing?

 

Gaston Nunez

Message 6 of 8
yessef
in reply to: yessef

Here it is in the attachments.

Thank you for taking the time.

Message 7 of 8
yessef
in reply to: yessef

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

Message 8 of 8
yessef
in reply to: yessef

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost