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:
Set xdata to all elements with its layer name
« previous
next »
Print
Pages: [
1
] |
Go Down
Author
Topic: Set xdata to all elements with its layer name (Read 1039 times)
0 Members and 1 Guest are viewing this topic.
diaa.caliph
Mosquito
Posts: 2
Set xdata to all elements with its layer name
«
on:
July 01, 2021, 10:18:40 PM »
i'm trying to set xdata for all elements in drawing with its layer name
the code gives error bad DXF group: (-1)
i'm not expert in autolisp i'm trying to get it done if anyone can figure it out
Code - Auto/Visual Lisp:
[Select]
(
defun
c:outline
(
/
i s str
)
(
regapp
"XXXX"
)
(
setq
s
(
ssget
"x"
)
)
(
repeat
(
setq
i
(
sslength
s
)
)
(
setq
str
(
cdr
(
assoc
8
(
entget
(
ssname
s
(
setq
i
(
1-
i
)
)
)
)
)
)
)
(
entmod
(
list
(
cons
-
1
(
ssname
s
(
setq
i
(
1-
i
)
)
)
)
'
(
-
3
(
"XXXX"
(
1000
. str
)
)
)
)
)
)
(
princ
)
)
EDIT (John): Added code tags.
«
Last Edit: July 01, 2021, 10:35:02 PM by John Kaul (Se7en)
»
Logged
CodeDing
Newt
Posts: 51
Re: Set xdata to all elements with its layer name
«
Reply #1 on:
July 01, 2021, 10:37:06 PM »
diaa.caliph,
Odd request if I say so myself, but it would go something like this:
Code - Auto/Visual Lisp:
[Select]
(
defun
c:OUTLINE
(
/
ss cnt eg lyr xd
)
(
regapp
"XXXX"
)
(
if
(
setq
ss
(
ssget
"_X"
)
)
(
repeat
(
setq
cnt
(
sslength
ss
)
)
(
setq
eg
(
entget
(
ssname
ss
(
setq
cnt
(
1-
cnt
)
)
)
'
(
"*"
)
)
)
(
setq
lyr
(
cdr
(
assoc
8
eg
)
)
)
(
if
(
setq
xd
(
assoc
-
3
eg
)
)
(
setq
xd
(
list
(
append
xd
(
list
(
list
"XXXX"
(
cons
1000
lyr
)
)
)
)
)
)
(
setq
xd
(
list
(
list
-
3
(
list
"XXXX"
(
cons
1000
lyr
)
)
)
)
)
)
;if
(
entmod
(
append
eg xd
)
)
)
;repeat
;else
(
prompt
"
\n
NO ENTITIES FOUND."
)
)
;if
(
prompt
"
\n
OUTLINE Complete."
)
(
princ
)
)
;defun
Hope that helps.
Best,
~DD
Logged
~DD
Senior CAD Tech & AI Specialist
Need AutoLisp help?
Try my custom GPT 'AutoLISP Ace'
diaa.caliph
Mosquito
Posts: 2
Re: Set xdata to all elements with its layer name
«
Reply #2 on:
July 01, 2021, 11:31:59 PM »
Superb CodeDing, that's exactly what needed, big thanks
Logged
Print
Pages: [
1
] |
Go Up
« previous
next »
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
Set xdata to all elements with its layer name