selection filer typedvalue between X and between Y

selection filer typedvalue between X and between Y

Anonymous
Not applicable
1,992 Views
5 Replies
Message 1 of 6

selection filer typedvalue between X and between Y

Anonymous
Not applicable

AutoCAD 2012

C#

Windows 7

 

I need a selection filter to find text objects within a rectangular area using dxf operators (do not want to use Editor.SelectWindow).

 

Whats wrong with the following code attempt?

It causes Fatal Error!

Thx.. Kevn..

 

 

TypedValue[] tv2 = new TypedValue[15];


tv2.SetValue(new TypedValue((int)DxfCode.Start, "TEXT"), 0);

 

tv2.SetValue(new TypedValue((int)DxfCode.Operator, "<and"), 1);
tv2.SetValue(new TypedValue((int)DxfCode.Operator, "<and"), 2);
tv2.SetValue(new TypedValue((int)DxfCode.Operator, ">"), 3);
tv2.SetValue(new TypedValue((int)DxfCode.XCoordinate,
Match1[0].GeometricExtents.MinPoint.X - 20), 4);
tv2.SetValue(new TypedValue((int)DxfCode.Operator, "<"), 5);
tv2.SetValue(new TypedValue((int)DxfCode.XCoordinate,
Match1[0].GeometricExtents.MaxPoint.X + 20), 6);
tv2.SetValue(new TypedValue((int)DxfCode.Operator, "and>"), 7);

tv2.SetValue(new TypedValue((int)DxfCode.Operator, "<and"), 8);
tv2.SetValue(new TypedValue((int)DxfCode.Operator, ">"), 9);
tv2.SetValue(new TypedValue((int)DxfCode.YCoordinate,
Match1[0].GeometricExtents.MinPoint.Y + 109), 10);
tv2.SetValue(new TypedValue((int)DxfCode.Operator, "<"), 11);
tv2.SetValue(new TypedValue((int)DxfCode.YCoordinate,
Match1[0].GeometricExtents.MaxPoint.Y + 131), 12);
tv2.SetValue(new TypedValue((int)DxfCode.Operator, "and>"), 13);
tv2.SetValue(new TypedValue((int)DxfCode.Operator, "and>"), 14);

 

SelectionFilter sf2 = new SelectionFilter(tv2);
PromptSelectionResult psr2 = AcadDoc1.Editor.SelectAll(sf2);

0 Likes
Accepted solutions (1)
1,993 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable

.. this also did not work ... fatal error ...

 

TypedValue[] tv2 =
new TypedValue[]
{
new TypedValue((int)DxfCode.Operator, "<and"),

new TypedValue((int)DxfCode.Operator, "<and"),
new TypedValue((int)DxfCode.Start, "TEXT"),
new TypedValue((int)DxfCode.Operator, ">"),
new TypedValue((int)DxfCode.XCoordinate, Match1[0].GeometricExtents.MinPoint.X - 20),
new TypedValue((int)DxfCode.Operator, "and>"),

new TypedValue((int)DxfCode.Operator, "<and"),
new TypedValue((int)DxfCode.Start, "TEXT"),
new TypedValue((int)DxfCode.Operator, "<"),
new TypedValue((int)DxfCode.XCoordinate, Match1[0].GeometricExtents.MaxPoint.X + 20),
new TypedValue((int)DxfCode.Operator, "and>"),

new TypedValue((int)DxfCode.Operator, "<and"),
new TypedValue((int)DxfCode.Start, "TEXT"),
new TypedValue((int)DxfCode.Operator, ">"),
new TypedValue((int)DxfCode.YCoordinate, Match1[0].GeometricExtents.MinPoint.Y + 109),
new TypedValue((int)DxfCode.Operator, "and>"),

new TypedValue((int)DxfCode.Operator, "<and"),
new TypedValue((int)DxfCode.Start, "TEXT"),
new TypedValue((int)DxfCode.Operator, "<"),
new TypedValue((int)DxfCode.YCoordinate, Match1[0].GeometricExtents.MaxPoint.Y + 131),
new TypedValue((int)DxfCode.Operator, "and>"),

new TypedValue((int)DxfCode.Operator, "and>")
};

 

0 Likes
Message 3 of 6

Hallex
Advisor
Advisor
Accepted solution

See if this working for you,

I used Polyline instead of "unknown Match[0]" on my machine:

                    Extents3d ext = pline.GeometricExtents;
                    double xmin = ext.MinPoint.X - 20;
                    double ymin = ext.MinPoint.Y + 109;
                    double xmax = ext.MaxPoint.X + 20;
                    double ymax = ext.MaxPoint.Y + 131;
                    Point3d minpt = new Point3d(xmin, ymin, pline.Elevation).TransformBy(Matrix3d.Identity);
                    Point3d maxpt = new Point3d(xmax, ymax, pline.Elevation).TransformBy(Matrix3d.Identity);  
                    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;

                    }
                   
                    tr.Commit();
                }

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 4 of 6

Anonymous
Not applicable

Dude! You ROCK! Thanks!

 

0 Likes
Message 5 of 6

Hallex
Advisor
Advisor

Glad to help Smiley Happy

 

Regards,

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
0 Likes
Message 6 of 6

amitnkukanur
Collaborator
Collaborator
Hi Hallex,

I have two confusions

1) I am using COM objects, in this case will this logic work.
2) On what basis is Pline initialised.

Please reply.

rgds
Amit
Senior Software Engineer
0 Likes