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:
Update Code to accept nested Xref
« previous
next »
Print
Pages: [
1
] |
Go Down
Author
Topic: Update Code to accept nested Xref (Read 1113 times)
0 Members and 1 Guest are viewing this topic.
HasanCAD
Swamp Rat
Posts: 1422
Update Code to accept nested Xref
«
on:
May 10, 2018, 06:43:49 AM »
HI all
I want to Change color and LWeight for layers of Xrefs which in Model only. It is working good. but one or more of xrefs has nested Xref.
So, How to do the same for nested Xrefs.
Code - Auto/Visual Lisp:
[Select]
(
if
(
Setq
ss
(
ssget
"_x"
(
list
(
cons
0
"INSERT"
)
(
cons
410
(
if
(
eq
1
(
getvar
'CVPORT
)
)
(
getvar
'CTAB
)
"Model"
)
)
)
)
)
(
repeat
(
setq
i
(
sslength
ss
)
)
(
setq
s
(
ssname
ss
(
setq
i
(
1-
i
)
)
)
)
(
setq
ent
(
entget
s
)
)
(
setq
xrn
(
cdr
(
assoc
2
ent
)
)
)
(
setq
xrn
(
strcat
xrn
"|*"
)
)
(
progn
(
vlax-for
i
(
vla-get-Layers
Doc
)
(
if
(
wcmatch
(
vla-get-Name
i
)
xrn
)
(
progn
(
vla-put-Color
i Clr
)
(
vla-put-lineweight
i acLnWt009
)
)
)
)
(
vla-Regen
Doc acActiveViewport
)
)
)
)
«
Last Edit: May 13, 2018, 04:31:49 AM by HasanCAD
»
Logged
Sorry for my English.
Donate to Theswamp
www.sergiwa.com
HasanCAD
Swamp Rat
Posts: 1422
Re: Update Code to accept nested Xref
«
Reply #1 on:
May 13, 2018, 11:22:39 AM »
This is what I ended to
comments will be valuable
Code - Auto/Visual Lisp:
[Select]
(
defun
c:XrefLayerColor
(
/
adoc ACTLAY CLR DOC ENAMES I LAYOUTS PLOT SS XR XREN XRN XRNB XRS XRSS
)
(
vl-load-com
)
(
defun
*error*
(
msg
)
(
vla-endundomark
doc
)
(
if
(
not
(
wcmatch
(
strcase
msg t
)
"*break,*cancel*,*exit*"
)
)
(
princ
(
strcat
"
\n
Error: "
msg
)
)
)
(
princ
)
)
(
setq
clr
252
)
(
setq
doc
(
vla-get-activedocument
(
vlax-get-acad-object
)
)
)
(
vla-startundomark
doc
)
(
if
(
Setq
ss
(
ssget
"_x"
(
list
(
cons
0
"INSERT"
)
(
cons
410
(
if
(
eq
1
(
getvar
'CVPORT
)
)
(
getvar
'CTAB
)
"Model"
)
)
)
)
)
(
repeat
(
setq
i
(
sslength
ss
)
)
(
setq
s
(
ssname
ss
(
setq
i
(
1-
i
)
)
)
)
(
setq
ent
(
entget
s
)
)
(
setq
xrnn
(
cdr
(
assoc
2
ent
)
)
)
(
setq
xrn
(
strcat
xrnn
"|*"
)
)
(
vlax-for
i
(
vla-get-Layers
Doc
)
(
if
(
wcmatch
(
vla-get-Name
i
)
xrn
)
(
progn
(
vla-put-Color
i Clr
)
(
vla-put-lineweight
i acLnWt009
)
)
)
)
(
if
(
setq
ent
(
tblobjname
"block"
xrnn
)
)
(
while
(
setq
ent
(
entnext
ent
)
)
(
if
(
and
(
eq
"INSERT"
(
cdr
(
assoc
0
(
entget
ent
)
)
)
)
(
setq
entnm
(
cdr
(
assoc
2
(
entget
ent
)
)
)
)
(
=
(
vla-get-IsXRef
(
vla-item
(
vla-get-blocks
doc
)
entnm
)
)
:vlax-true
)
)
(
progn
(
setq
xrn
(
strcat
entnm
"|*"
)
)
(
vlax-for
i
(
vla-get-Layers
Doc
)
(
if
(
wcmatch
(
vla-get-Name
i
)
xrn
)
(
progn
(
vla-put-Color
i Clr
)
(
vla-put-lineweight
i acLnWt009
)
)
)
)
)
)
)
)
)
)
(
vla-Regen
doc acActiveViewport
)
(
vla-endundomark
doc
)
(
princ
)
)
Logged
Sorry for my English.
Donate to Theswamp
www.sergiwa.com
Print
Pages: [
1
] |
Go Up
« previous
next »
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
Update Code to accept nested Xref