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

selectionfilter select object by layer, layer name contains #, selectionresult got error

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Anonymous
556 Views, 2 Replies

selectionfilter select object by layer, layer name contains #, selectionresult got error

use the following code to select objects on layer, layername contains #, selectionresult ERROR

 

TypedValue[] tvs = new TypedValue[]
{
new TypedValue((int)DxfCode.Operator, "<and"),
new TypedValue((int)DxfCode.LayerName,  layerName  ),
 
new TypedValue((int)DxfCode.Operator, "and>")
};
SelectionFilter filter = new SelectionFilter(tvs);
ObjectId[] objIds;
PromptSelectionResult psr = doc.Editor.SelectAll(filter);

 

please anyone can help

 

Thank you

2 REPLIES 2
Message 2 of 3
_gile
in reply to: Anonymous

Hi,

Selection filters use wildcard patterns and # is wildcard charater.

You have to prefix the # with a reverse quote (`#) in the filter pattern.

layerName.Replace("#", "`#")

PS : using special characters in layer names, block names, ... is not a good practice.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 3
Anonymous
in reply to: _gile

THANK YOU VERY MUCH Gilles, you made my day, very much appreciate

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report