TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: cmwade77 on May 02, 2022, 08:06:53 PM
-
I would like to filter out RAY,XLINE,*TEXT and XREFs, but not blocks from SSGET
I have tried:
(setq SS (ssget "_:L" '((-4 . "<NOT") (-4 . "<AND") (0 . "INSERT") (1 . "*") (-4 . "AND>") (0 . "RAY,XLINE,*TEXT") (-4 . "NOT>"))))
As well as few other variations and I can't seem to get it to work. I am sure that I am missing something obvious.
-
There isn't a direct filter for XREF's.
-
How about something like this?
Filter by a list of known blocks, so it won't select the ones that are xrefs.
'(0 . "INSERT")
2
(acet
-table
-name
-list (list "block" 4 16)) ; List of blocks excluding xref's )
)
2
)
)
)
))
-
There isn't a direct filter for XREF's.
You could put xref's on a custom layer and filter out said layer (8 . "layname")
(setq SS
(ssget "_:L" '
((-4 .
"<NOT") (-4 .
"<AND") (0 .
"INSERT") (1 .
"*") (-4 .
"AND>") (0 .
"RAY,XLINE,*TEXT") (8 .
"layername") (-4 .
"NOT>"))))
-
Thats a great idea.
This is basic.
(defun c:XRL (/ objs ent i)
(setq objs (ssget "_X" '((0 . "INSERT"))))
(repeat (setq i (sslength objs))
(setq ent (entget (ssname objs (setq i (1- i)))))
(if (= 4 (logand 4 (cdr (assoc 70 (tblsearch "BLOCK" (cdr (assoc 2 ent)))))))
(entmod (subst (cons 8 "LAYERNAME")(assoc 8 ent) ent))))
)
-
There isn't a direct filter for XREF's.
You could put xref's on a custom layer and filter out said layer (8 . "layname")
(setq SS
(ssget "_:L" '
((-4 .
"<NOT") (-4 .
"<AND") (0 .
"INSERT") (1 .
"*") (-4 .
"AND>") (0 .
"RAY,XLINE,*TEXT") (8 .
"layername") (-4 .
"NOT>"))))
While this would be a great idea, unfortunately, I am needing to work with drawings often created by other companies and they don't always do this and I want to try to avoid modifying their drawings.
-
How about something like this?
Filter by a list of known blocks, so it won't select the ones that are xrefs.
'(0 . "INSERT")
2
(acet
-table
-name
-list (list "block" 4 16)) ; List of blocks excluding xref's )
)
2
)
)
)
))
That could work, but I would also like to allow everything except xrefs, RAY, XLINE, *TEXT to be selected.
ETA: I just tried and all I get is a spinning wheel with this one.
-
xref have a property "path" blocks don't so you can check all entity's in selection set. If they have a path property remove it from the selection set with the following.
-
Maybe this:
)
)
r
)
'(-4 . "<AND")
'(0 . "INSERT")
'(-4 . "AND>")
'(-4 . "<NOT")
'(0 . "RAY,XLINE,*TEXT")
'(-4 . "NOT>")
'(-4 . "OR>")
)
)
-
Thanks to all of your posts, I have figured out two different ways to accomplish what I am trying to do.
First off, I want to clarify, that I want to prevent the selection of the xRefs, it seems some of the examples were trying to include them.
So, here are my methods:
Method 1:
Removes xRefs from selection set after finishing the section set.
(defun CW:SSRemoveXrefs (SS / idx en obj)
(vl-load-com)
(setq idx -1)
(repeat (sslength ss)
(setq en (ssname ss (setq idx (1+ idx)))
obj (vlax-ename->vla-object en)
)
(if (vlax-property-available-p obj 'Path)
(progn
(vla-highlight obj :vlax-false)
(ssdel en ss)
(setq idx (1- idx))
)
)
)
SS
)
This has the downside that it still looks like you are selecting xRefs, as you technically are and they are just being removed from the selection set, so I went with a different method.
Method 2
Filters xRefs from the selection set based on name:
(defun CW:SSRemoveXrefs (SS / idx en obj)
(vl-load-com)
(setq idx -1)
(repeat (sslength ss)
(setq en (ssname ss (setq idx (1+ idx)))
obj (vlax-ename->vla-object en)
)
(if (vlax-property-available-p obj 'Path)
(progn
(vla-highlight obj :vlax-false)
(ssdel en ss)
(setq idx (1- idx))
)
)
)
SS
)
(defun C:FD (/ SS xRefs)
(setq xRefs (CW:XREFList))
(if xRefs
(setq Filter (list
'(-4 . "<AND")
'(-4 . "<NOT")
'(0 . "RAY,XLINE,*TEXT")
'(-4 . "NOT>")
'(-4 . "<NOT")
(cons 2 xRefs)
'(-4 . "NOT>")
'(-4 . "AND>")
)
)
(setq Filter (list
'(-4 . "<NOT")
'(0 . "RAY,XLINE,*TEXT")
'(-4 . "NOT>")
)
)
)
(while (not SS)
(setq SS (ssget "_:L" Filter))
)
)
I tried to use some if statements to only use one (setq Filter but it would fail frequently, so this way worked.