Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Nested Xrefs

10 REPLIES 10
Reply
Message 1 of 11
paliitali
724 Views, 10 Replies

Nested Xrefs

Hi,

if i have a drawing Z with two mother xrefs X, Y; xref X has several xrefs nested with in it, and so does xref Y. My question is, would it be possible for a lisp to display a list of the mother Xrefs (X, Y) with the option to select one Xref and freeze all layers of this mother Xref with all its nested Xrefs without affecting the other mother Xref.

any help with this will be much appreciated.

Thank you
10 REPLIES 10
Message 2 of 11
t.willey
in reply to: paliitali

What you want can be done in a couple different ways. How do you envision it working? Meaning what steps do you want to happen to allow the routine.

How comfortable are you with writing lisp routines also?
Message 3 of 11
paliitali
in reply to: paliitali

Hi,

I can write some basic code, and i am more comfortable editing and adding some features to something existing, but i am willing to work with whatever help i can get.

i was thinking that after i type in this command, a dialog box will appear listing all mother xrefs -mother xrefs are any xrefs that were individually xrefed into the drawing- the dialog box can have a check box beside each listed xref, then i can check the box and press ok, or maybe i can click on the xref itself, like a button or a link - and then all layers of this xref will be frozen.

I am open to any suggestions or ideas on how to make this work, maybe there is an easier way, but if the way i envision it is possible, then that would be great.

Thanks again
Message 4 of 11
t.willey
in reply to: paliitali

What about the nested xrefs? This shouldn't be too hard to do.

Why don't you just unload the xref instead of freezing all the layers? I would think this is better, or easier to work with because you don't have to remember which layers should be frozen. When I use xrefs I freeze some layers, so that if I was to freeze them all within a command I would have to remember which ones I do want frozen, and freeze them again.
Message 5 of 11
paliitali
in reply to: paliitali

thats true, unloading the xref will work, but i am trying to make it dummy proof for everyoone else in the office, and i was also thinking that maybe later on i can incorporate layer color change and other features in this lisp. i am sure that a lisp like this will come in handy, so i am trying to figure out a way to build it up slowly...
Message 6 of 11
t.willey
in reply to: paliitali

What you can do then is break it up into smaller sub routines that can work well with other ideas. Make one to grab all xrefs. Then make one to distinguish between main xrefs, and nested xrefs (this sounds hard, but isn't if my tests hold up). Then you can just pass what is returned to the other routines you want to do.

Does this sound like something you could work with?
Message 7 of 11
paliitali
in reply to: paliitali

the part i cant seem to make happen, is having a dialog box appear with the mother xrefs listed in it. i can make a lisp that will ask me to select an xref, but i am not able to distinguish between mother xrefs and any nested xref. so if it is possible to get some help with the dialog box and how to list these mother xrefs with in, then that would be very helpfull.
Message 8 of 11
t.willey
in reply to: paliitali

If you are selecting on screen, then you would use 'nentsel' so that you can select nested objects. You can use this code as a model to go by. You select an object, then it shows an alert box that shows each level of objects. So if it's a line, within a block, within an xref, it will show you all three objects, and some properties. This should give you a good starting point.

[code]
(defun c:NList (/ Sel EntList Data tempType NListString LayName)

(setq NListString "")
(if (setq Sel (nentsel "\n Select object to list properties of it, and of partent entities if nested: "))
(progn
(if (> (length Sel) 2)
(setq EntList (append (list (car Sel)) (last Sel)))
(setq EntList (list (car Sel)))
)
(foreach ent EntList
(if (equal (type ent) 'ENAME)
(progn
(setq Data (entget Ent))
(setq NListString
(strcat
NListString
"\n Entity type: "
(setq tempType (cdr (assoc 0 Data)))
(cond
(
(and
(= tempType "INSERT")
(/=
(cdr
(assoc
1
(entget
(tblobjname
"block"
(cdr
(assoc 2 Data)
)
)
)
)
)
""
)
)
(strcat
" [ Xref - "
(cdr (assoc 2 Data))
" ]"
)
)
((= tempType "INSERT")
(strcat
" [ "
(cdr (assoc 2 Data))
" ]"
)
)
(T "")
)
"\n Layer: "
(setq LayName (cdr (assoc 8 Data)))
"\n Linetype: "
(if (assoc 6 Data)
(cdr (assoc 6 Data))
(strcat
"ByLayer [ "
(cdr
(assoc
6
(entget
(tblobjname "layer" LayName)
)
)
)
" ]"
)
)
"\n Color: "
(if (assoc 62 Data)
(itoa (cdr (assoc 62 Data)))
(strcat
"ByLayer [ "
(itoa
(cdr
(assoc
62
(entget
(tblobjname "layer" LayName)
)
)
)
)
" ]"
)
)
"\n"
)
)
)
)
)
(alert NListString)
)
)
(princ)
)
[/code]
Message 9 of 11
Anonymous
in reply to: paliitali

Could you incorporate the 'layer lineweight' setting of the object seleted
into the code - please?
Message 10 of 11
t.willey
in reply to: paliitali

[code]
(defun c:NList (/ Sel EntList Data tempType NListString LayName tempLw)

(setq NListString "")
(if (setq Sel (nentsel "\n Select object to list properties of it, and of partent entities if nested: "))
(progn
(if (> (length Sel) 2)
(setq EntList (append (list (car Sel)) (last Sel)))
(setq EntList (list (car Sel)))
)
(foreach ent EntList
(if (equal (type ent) 'ENAME)
(progn
(setq Data (entget Ent))
(setq NListString
(strcat
NListString
"\n Entity type: "
(setq tempType (cdr (assoc 0 Data)))
(cond
(
(and
(= tempType "INSERT")
(/=
(cdr
(assoc
1
(entget
(tblobjname
"block"
(cdr
(assoc 2 Data)
)
)
)
)
)
""
)
)
(strcat
" [ Xref - "
(cdr (assoc 2 Data))
" ]"
)
)
((= tempType "INSERT")
(strcat
" [ "
(cdr (assoc 2 Data))
" ]"
)
)
(T "")
)
"\n Layer: "
(setq LayName (cdr (assoc 8 Data)))
"\n Linetype: "
(if (assoc 6 Data)
(cdr (assoc 6 Data))
(strcat
"ByLayer [ "
(cdr
(assoc
6
(entget
(tblobjname "layer" LayName)
)
)
)
" ]"
)
)
"\n Color: "
(if (assoc 62 Data)
(itoa (cdr (assoc 62 Data)))
(strcat
"ByLayer [ "
(itoa
(cdr
(assoc
62
(entget
(tblobjname "layer" LayName)
)
)
)
)
" ]"
)
)
"\n Lineweight: "
(if (assoc 370 Data)
(progn
(setq tempLw (cdr (assoc 370 Data)))
(cond
((equal tempLw -3)
"Default"
)
((equal tempLw -2)
"ByBlock"
)
(t
(strcat (rtos (/ tempLw 100.) 2 2) " mm")
)
)
)
(progn
(setq tempLw
(cdr
(assoc
370
(entget
(tblobjname "layer" LayName)
)
)
)
)
(strcat
"ByLayer [ "
(if (equal tempLw -3)
"Default"
(strcat (rtos (/ tempLw 100.) 2 2) " mm")
)
" ]"
)
)
)
"\n"
)
)
)
)
)
(alert NListString)
)
)
(princ)
)
[/code]
Message 11 of 11
paliitali
in reply to: paliitali

Thanks, i will try to work with this.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost