Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

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

Anonymous

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

Anonymous
Not applicable

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

0 Likes
Reply
Accepted solutions (1)
582 Views
2 Replies
Replies (2)

_gile
Mentor
Mentor
Accepted solution

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

Anonymous
Not applicable
THANK YOU VERY MUCH Gilles, you made my day, very much appreciate
0 Likes