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

selection filer typedvalue between X and between Y

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
kbarnettza
1681 Views, 5 Replies

selection filer typedvalue between X and between Y

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);

5 REPLIES 5
Message 2 of 6
kbarnettza
in reply to: kbarnettza

.. 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>")
};

 

Message 3 of 6
Hallex
in reply to: kbarnettza

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
kbarnettza
in reply to: Hallex

Dude! You ROCK! Thanks!

 

Message 5 of 6
Hallex
in reply to: kbarnettza

Glad to help Smiley Happy

 

Regards,

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 6 of 6
amitnkukanur
in reply to: Hallex

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

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