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);
Solved! Go to Solution.
Solved by Hallex. Go to Solution.
.. 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>")
};
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'~
Can't find what you're looking for? Ask the community or share your knowledge.