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

Get all objects in a area

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
1283 Views, 3 Replies

Get all objects in a area

I want to erase all entities in a rectangular area, I tried to use the follow statement to get these objects in the area.

 

 PromptSelectionResult acSSPrompt = acDocEd.SelectWindow (new Point3d (-500, 400, 0), new Point3d (-10, -150, 0));

 

But the disadvantage  of SelectWindow() is that if the current window is not within this area, then the acSSPrompt will be null, so the program get nothing in that arae and it's won't erase the entities in that area, it's not match the actual situation

 

I also try to conver all objectIds in the current BlockTableRecord into Entity, but not every one has a Position property.

 

How can I solve this problem?
I hope someone can help me, very thanks.

3 REPLIES 3
Message 2 of 4
Ajilal.Vijayan
in reply to: Anonymous


@Anonymous wrote:

 

But the disadvantage  of SelectWindow() is that if the current window is not within this area, then the acSSPrompt will be null, so the program get nothing in that arae and it's won't erase the entities in that area, it's not match the actual situation


Then how about changing the current view of drawing to include the required area

 

acDoc.Editor.SetCurrentView(acView)
Message 3 of 4
Hallex
in reply to: Anonymous

You may want to use code like this,

change points , entity name and other items in

Selection filter:

  // code snop
string tab = (string)Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("CTAB");
              
                    TypedValue[] tvs = new TypedValue[] { 
              new TypedValue((int) DxfCode.Start, "TEXT"),
              new TypedValue(410, tab),
               new TypedValue((int) DxfCode.Operator, "<AND"),
              new TypedValue((int)  DxfCode.Operator, ">,>,*"), 
              new TypedValue((int) 10, minpt),   
              new TypedValue((int) DxfCode.Operator, "<,<,*"), 
              new TypedValue((int) 10, maxpt), 
              new TypedValue((int) DxfCode .Operator, "AND>")
            };
                    SelectionFilter sf = new SelectionFilter(tvs);

                    PromptSelectionResult psr = ed.SelectAll(sf);

                    if (psr.Status == PromptStatus.OK)
                    {
                        count = psr.Value.GetObjectIds().Length;
                        ed.WriteMessage("\nSelected:    " + count.ToString());

                    }
                    else
                    {
                        ed.WriteMessage("\nBad selection");
                        return;

                    }

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 4 of 4
Anonymous
in reply to: Ajilal.Vijayan

This is a easy way, just set the current view to zoom all, and then call SelectWindows method, so it won't get null.

Thanks.

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