How can I select object contains certain xdata header but not on certain layer

How can I select object contains certain xdata header but not on certain layer

Anonymous
Not applicable
805 Views
5 Replies
Message 1 of 6

How can I select object contains certain xdata header but not on certain layer

Anonymous
Not applicable

Hi Guys,

 

May I ask how can use selectionset to select objects with certain XData but not on certain layers.

layer name is in a coma seperated string like "layer1,layer2,layer3"

 

Is that achiveble? If not I can select object and then loop them remove the one on the layer list

 

Thanks

0 Likes
806 Views
5 Replies
Replies (5)
Message 2 of 6

_gile
Consultant
Consultant

Hi,

 

You can filter entities containing extended data for a specified application, not for data values.

 

Here's a little sample to select entities which aren't on Layer1, Layer2 or Layer3 and which contain xdata for an application named "APPNAME"

 

 

[CommandMethod("TEST")]
        public void Test()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            TypedValue[] filter = new TypedValue[4] {
                new TypedValue(-4, "<NOT"),
                new TypedValue(8, "Layer1,Layer2,Layer3"),
                new TypedValue(-4, "NOT>"),
                new TypedValue(1001, "APPNAME") };
            PromptSelectionResult psr = 
                ed.GetSelection(new SelectionFilter(filter));
            if (psr.Status == PromptStatus.OK)
                ed.WriteMessage("\nNumber of selected entities : {0}", psr.Value.Count);
            else
                ed.WriteMessage("\nNone selected entity.");
        }

 

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 6

_gile
Consultant
Consultant

If you're not comfortable with DXF codes, you can use the DxfCode enum while building the selection filter:

 

 

TypedValue[] filter = new TypedValue[4] {
                new TypedValue((int)DxfCode.Operator, "<NOT"),
                new TypedValue((int)DxfCode.LayerName, "Layer1,Layer2,Layer3"),
                new TypedValue((int)DxfCode.Operator, "NOT>"),
                new TypedValue((int)DxfCode.ExtendedDataRegAppName, "APPNAME") };

 

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 4 of 6

Anonymous
Not applicable

thanks for the reply

 

but I am using vb.net. do you have vb.net version ?

 

 

thanks

0 Likes
Message 5 of 6

Anonymous
Not applicable

I tried to define editor but didn't manage. do you know which reference I need to input ?

 

Thanks

 

Editor ed = Application.DocumentManager.MdiActiveDocument.Edit or;

 

 

0 Likes
Message 6 of 6

_gile
Consultant
Consultant

Hi,

 

Have a look at the Autodesk .NET Devleoper's Gides > Create and Edit AutoCAD Entities > Work with Selection Sets > Define Rules for Selection Filters > Filter for Extended Data.

 

http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer%27s%20Guide/index.html



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes