Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Home
Help
Login
Register
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
Passing a list to SSGET Logical Operators
« previous
next »
Print
Pages: [
1
] |
Go Down
Author
Topic: Passing a list to SSGET Logical Operators (Read 1422 times)
0 Members and 1 Guest are viewing this topic.
Coltm16
Guest
Passing a list to SSGET Logical Operators
«
on:
February 03, 2017, 11:14:07 AM »
Is it possible to pass a list to an SSGET function with conditional operators, or something similar to accomplish the same thing? I've tried everything I can think of but it is not working. Example:
Code - Auto/Visual Lisp:
[Select]
(
setq
mylist
(
list
(
cons
8
"Layer1"
)
(
cons
8
"Layer2"
)
)
)
(
setq
ss
(
ssget
(
list
(
cons
-
4
"<OR"
)
mylist
(
cons
-
4
"OR>"
)
)
)
)
(
command
"_stretch"
ss
""
)
Thanks for any help.
«
Last Edit: February 03, 2017, 11:20:30 AM by Coltm16
»
Logged
ronjonp
Needs a day job
Posts: 7529
Re: Passing a list to SSGET Logical Operators
«
Reply #1 on:
February 03, 2017, 11:24:11 AM »
Code - Auto/Visual Lisp:
[Select]
(
ssget
'
(
(
8
.
"Layer1,Layer2"
)
)
)
Logged
Windows 11 x64 - AutoCAD /C3D 2023
Custom Build PC
Coltm16
Guest
Re: Passing a list to SSGET Logical Operators
«
Reply #2 on:
February 03, 2017, 12:03:54 PM »
Thanks, Have not tested it yet, but can it be:
Code - Auto/Visual Lisp:
[Select]
(
setq
mylistoflayers
(
list
"Layer1"
" Layer2"
)
(
ssget
'
(
(
8
. mylistoflayers
)
)
)
or Do i need to use
Code - Auto/Visual Lisp:
[Select]
(
ssget
(
list
(
cons
8
mylistoflayers
)
)
)
edit: or should I use strcat with each element of the list of layers?
Logged
ronjonp
Needs a day job
Posts: 7529
Re: Passing a list to SSGET Logical Operators
«
Reply #3 on:
February 03, 2017, 12:10:57 PM »
If you have a list of layer names, you could do something like this:
Code - Auto/Visual Lisp:
[Select]
(
ssget
(
list
(
cons
8
(
apply
'
strcat
(
mapcar
'
(
lambda
(
layname
)
(
strcat
layname
","
)
)
(
list
"Layer1"
" Layer2"
)
)
)
)
)
)
Also be aware you can use wild cards too:
Code - Auto/Visual Lisp:
[Select]
(
ssget
'
(
(
8
.
"Layer*"
)
)
)
Logged
Windows 11 x64 - AutoCAD /C3D 2023
Custom Build PC
Coltm16
Guest
Re: Passing a list to SSGET Logical Operators
«
Reply #4 on:
February 03, 2017, 12:33:53 PM »
Thanks! I am so close. However, my layerslist is coming out like ("layer1," "layer2,"....) Instead of one long string ("layer1,layer2,layer3....). Thank you for your help!
Code - Auto/Visual Lisp:
[Select]
(
defun
c:stretchfilter
(
/
ss i l x ent layerlist
)
(
Princ
"
\n
Select object(s) to include their layers in a stretch command."
)
(
if
(
setq
ss
(
ssget
":L"
)
)
(
progn
(
repeat
(
setq
i
(
sslength
ss
)
)
(
if
(
not
(
member
(
setq
l
(
cdr
(
assoc
8
(
entget
(
ssname
ss
(
setq
i
(
1-
i
)
)
)
)
)
)
)
x
)
)
(
setq
x
(
cons
l x
)
)
)
;endif
)
;endrepeat
(
setq
layerlist
(
mapcar
'
(
lambda
(
layname
)
(
strcat
layname
","
)
)
x
)
)
(
princ
(
strcat
"
\n
Only these layers will be included in the selection window: "
layerlist
)
)
(
princ
"
\n
Select objects to stretch by crossing-window or crossing-polygon..."
)
(
setq
ss
(
ssget
(
list
(
cons
-
4
"<OR"
)
(
cons
8
layerlist
)
(
cons
-
4
"OR>"
)
)
)
)
(
command
"_Stretch"
ss
""
)
)
)
;endif and progn
(
princ
)
)
;end func
Logged
Lee Mac
Seagull
Posts: 12914
London, England
WWW
Re: Passing a list to SSGET Logical Operators
«
Reply #5 on:
February 03, 2017, 12:37:10 PM »
Code - Auto/Visual Lisp:
[Select]
(
apply
'
strcat
layerlist
)
Logged
Lee Mac Programming
•
Twitter
•
Exchange App Store
Coltm16
Guest
Re: Passing a list to SSGET Logical Operators
«
Reply #6 on:
February 03, 2017, 12:44:12 PM »
Awesome, Thank You!
Logged
Print
Pages: [
1
] |
Go Up
« previous
next »
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
Passing a list to SSGET Logical Operators