Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with lisp routine forfreezing of xref layers? 1

Status
Not open for further replies.

vbcad

Technical User
Jul 12, 2002
159
US
I have a lisp routine that freezes and thaws layers as needed for a particular drawing. this works the same as layer manager. what i need to do is freeze and thaw layers in an external referance. the layer designations are the same but how do i handle the layers being from different file names. ie (drawing1/a-door)or (drawing2/a-door)any help is aprreciated.
 
THE PROBLEM I HAVE IS WITH THE XREF LAYERS. I HAVE PASTED SOME CODE ON WHAT WORKS AND WHAT I AM TRYING TO DO.

(command "layer" "THAW" "A-FLOR-EVTR" "" "")
(command "layer" "FREEZE" "A-FLOR-EXJT" "" "")
(COMMAND "LAYER" "FREEZE" "XREFNAME/A-DOOR" "" ""))

THE ITEM IN RED IS THE VARIABLE PORTION OF THE LAYER DEPENDING ON THE FILE NAME OF THE XREF.
 
If you always know the xref name and the layer name, combine them like AutoCAD does with a vertical bar between:
"xrefname|layer name"
or to allow variable names, use 'strcat' such as
(setq LayName (strcat XrefVariable "|" LayerVariable))
 
is this the proper code for the xref line? The layer itself is not variable just the xref name.

(setq LayName (strcat XrefVariable "|" LayerVariable))
(command "layer" "THAW" "xrefvariable|A-CLNG-SKYL" "" "")
 
With 'strcat' you combine quoted and variable strings into one string. So if the XrefVariable is sasigned the xref name (a string), to get the entire layer name use;

(setq Layname (strcat XrefVariable "|A-CLNG-SKYL"))
(command "layer" "THAW" Layname "" "")
 
With 'strcat' you combine quoted and variable strings into one string. So if the XrefVariable is assigned the xref name (a string), to get the entire layer name use;

(setq Layname (strcat XrefVariable "|A-CLNG-SKYL"))
(command "layer" "THAW" Layname "" "")
 
THANKS. DO I HAVE TO SET EACH LAYER ON A SEPERATE LINE.FOR EXAMPLE.

(setq Layname (strcat XrefVariable "|A-CLNG-SKYL"))
(command "layer" "THAW" Layname "" "")
(setq Layname (strcat XrefVariable "|A-DOOR"))
(command "layer" "THAW" Layname "" "")

OR WILL IT HAVE TO BE LIKE THIS?
(setq Layname (strcat XrefVariable "|A-CLNG-SKYL"))
(command "layer" "THAW" Layname "" "")
(setq Layname2 (strcat XrefVariable "|A-DOOR"))
(command "layer" "THAW" Layname2 "" "")
 
Either way works. When you set a variable to a new value it overwrites the previous value.

There are shorter ways to code this. For example, to thaw a list of layers:

(setq LayList '("A-CLNG-SKYL" "A-CLNG-SKYL" "Lay3" "Lay4" etc...)
(foreach x LayList
(setq LayName (strcat XrefName "|" x))
(command "layer" "thaw" LayName "" "")
)
 
OK I HAVE TRIED TO MAKE THIS PARTIAL LIST WORK. IT GIVES ME THE MALFORMED LIST ON INPUT ERROR. I KNOW THERE IS A SHORTER WAY TO CODE THIS BUT I AM JUST TRYING TO GET IT TO WORK.

(DEFUN C:FIXF12 () (setq LayList '("A-DOOR" "A-CLNG-SKYL" "A-ANNO-CSWK" "A-AREA" "A-AREA-SQFT")
(foreach x LayList
(setq LayName (strcat XrefName "|" x))
(command "layer" "thaw" LayName "" "")
(command "layer" "FREEZE" "A-HIST" "" "")
(command "layer" "FREEZE" "A-HIST-2000" "" "")
(command "layer" "THAW" "G-TTLB" "" "")
(command "layer" "THAW" "G-TTLB-PLBK" "" "")
(command "layer" "THAW" "VIEWPORT" "" "")
(command "layer" "THAW" "XREF" "" "")
(command "layer" "THAW" "A-FURN" "" "")
(command "layer" "THAW" "A-FURN-SHTT" "" "")
(command "layer" "FREEZE" "A-FURN-T" "" "")
(command "layer" "SET" "A-FURN" "" ""))
 
You're missing a parenthesis after your Laylist line. Also I believe you want your "foreach to operat on just the 2 following lines. I also don't see where you've assigned the variable Xrefname. Here's the changes following my assumptions:

(DEFUN C:FIXF12 ()
(setq LayList '("A-DOOR" "A-CLNG-SKYL" "A-ANNO-CSWK" "A-AREA" "A-AREA-SQFT"))
(foreach x LayList
(setq LayName (strcat XrefName "|" x))
(command "layer" "thaw" LayName "" "")
);foreach
(command "layer" "FREEZE" "A-HIST" "" "")
(command "layer" "FREEZE" "A-HIST-2000" "" "")
(command "layer" "THAW" "G-TTLB" "" "")
(command "layer" "THAW" "G-TTLB-PLBK" "" "")
(command "layer" "THAW" "VIEWPORT" "" "")
(command "layer" "THAW" "XREF" "" "")
(command "layer" "THAW" "A-FURN" "" "")
(command "layer" "THAW" "A-FURN-SHTT" "" "")
(command "layer" "FREEZE" "A-FURN-T" "" "")
(command "layer" "SET" "A-FURN" "" "")
(princ);clean exit
);defun
 
HOW DO I SET THE XREF VARIABLE? IF IT IS SET WHERE IN THE CODE IS IT. I AM A LITTLE LOST WITH SETQ. I KEEP GETTING THE STRINGP NIL ERROR WHEN I RUN THE COMMAND.
 
You need to tell the routine what the xref name is, either by hard coding it, or asking the user to type it in, or asking the user to select it. Here's how you'd get it by user picking:

(setq XrefName (cdr (assoc 2 (entget (car (entsel "nPick xref: "))))))
 
thanks for the help. i was trying to get the routine to get the xref in the drawing with out picking it. i do not know if this is possible as Autocad needs to have the xref name to work with. Am i correct that Autocad needs the entity code and the name of the entity if it is hard coded?
 
All the routine needs is the xref name to be hard-coded. But the routine can detect an xref and include the name without hard-coding or user input. Will this routine be used on a drawing that has only one xref? If so, then the "auto detect xref name" can be made to work.
 
Yes they do only have one xref. how does the auto detect xref work?
 
here's the code, not well tested...it looks through the block table data, finds the first xref, assigns its name to "XrefName"

(tblnext "BLOCK" T);sets pointer to top of block table
(setq Loop T)
(while Loop
(setq Bdata (tblnext "BLOCK"));;steps through table
(if (assoc 1 Bdata);;an xref path
(setq XrefName (cdr (assoc 2 Bdata))
Loop nil
)
);if
);while
 
that section of code works good. i replaced the (setq XrefName (cdr (assoc 2 (entget (car (entsel "nPick xref: ")))))) with the new code. One question. what do the
);if
);while
statements do (if anything)?
 
Good to hear its working.

These are just the closing parentheses to the'if' and 'while' functions; the comments (following a semicolon) are to help follow the formatting of the code.
 
I have and update. in playing with the code an associate of mine tried something with the code and it works. He tried a wildcard symbol for the xref layer name and it works without having to query the block table. here is a potion of the code.

(setq LayList '(
"0"

"*|A-ANNO-GN";start of thawed xref layer list
"*|A-ANNO-SHTT"
"*|A-DOOR"
"*|A-DOOR-EXTE"
"*|A-EQPM-CORD"
"*|A-FLOR-CSWK"
"*|A-FLOR-CSWK-DESK"
"*|A-FLOR-CSWK-LOWR"
"*|A-FLOR-ELEV"
"*|A-FLOR-EVTR"
"*|A-FLOR-FCAB"
"*|A-FLOR-FDRN"
"*|A-FLOR-FNCE"
"*|A-FLOR-FRAS"
"*|A-FLOR-FSLP"
"*|A-FLOR-HRAL"
"*|A-FLOR-HRAL-CORR"
"*|A-FLOR-OPNG"
"*|A-FLOR-OVHD-EXTE"
"*|A-FLOR-PLAT"
"*|A-FLOR-PLBG"
"*|A-FLOR-RMPB"
"*|A-FLOR-RMPB-OR"
"*|A-FLOR-SHTT"
"*|A-FLOR-STRC"
"*|A-FLOR-STRS"
"*|A-FLOR-STRS-UPDN"
"*|A-FLOR-TPTN"
"*|A-FLOR-XSHT"
"*|A-FURN"
"*|A-FURN-PANL"
"*|A-GLAZ-EXTE"
"*|A-WALL"
"*|A-WALL-ACCP"
"*|A-WALL-ACLG"
"*|A-WALL-CLNG"
"*|A-WALL-COLS"
"*|A-WALL-EXTE"
"*|A-WALL-GLAZ"
"*|A-WALL-LOW"
"*|A-WALL-SLAB"
"*|A-WALL-STRC"
"*|C-SITE"
"*|C-SITE-WALK"
"*|P-ANNO"
"*|A-ROOF-DETL"
"*|A-ROOF-EDGE"
"*|A-ROOF-VALR"
"*|S-WALL"
"*|S-SLAB-ANNO"
"*|VIEWPORT"
"*|XREF"

"A-ANNO-GN";start of thawed layer list
"A-ANNO-SHTT"
"A-DOOR"
"A-DOOR-EXTE"
"A-EQPM-CORD"
"A-FLOR-CSWK"
"A-FLOR-CSWK-DESK"
"A-FLOR-CSWK-LOWR"
"A-FLOR-ELEV"
"A-FLOR-EVTR"
"A-FLOR-FCAB"
"A-FLOR-FDRN"
"A-FLOR-FNCE"
"A-FLOR-FRAS"
"A-FLOR-FSLP"
"A-FLOR-HRAL"
"A-FLOR-HRAL-CORR"
"A-FLOR-OPNG"
"A-FLOR-OVHD-EXTE"
"A-FLOR-PLAT"
"A-FLOR-PLBG"
"A-FLOR-RMNA"
"A-FLOR-RMNU"
"A-FLOR-RMPB"
"A-FLOR-RMPB-OR"
"A-FLOR-SHTT"
"A-FLOR-STRC"
"A-FLOR-STRS"
"A-FLOR-STRS-UPDN"
"A-FLOR-TPTN"
"A-FLOR-XSHT"
"A-FURN"
"A-FURN-PANL"
"A-GLAZ-EXTE"
"A-WALL"
"A-WALL-ACCP"
"A-WALL-ACLG"
"A-WALL-CLNG"
"A-WALL-COLS"
"A-WALL-EXTE"
"A-WALL-GLAZ"
"A-WALL-LOW"
"A-WALL-SLAB"
"A-WALL-STRC"
"C-SITE"
"C-SITE-WALK"
"G-ANNO-TTLB"
"G-TTLB"
"G-TTLB-PLBK"
"P-ANNO"
"A-ROOF-DETL"
"A-ROOF-EDGE"
"A-ROOF-VALR"
"S-WALL"
"S-SLAB-ANNO"
"VIEWPORT"
"XREF"));end of thawed layer list

(foreach x LayList
(setq LayName (strcat x))
(command "layer" "THAW" LayName "" "")
);foreach ;end of THAW section

(command "ltscale" "24")
(command "fillet" "R" "0" "")
(command "TILEMODE" "0" "" "")
(command "snapang" "0")

(command "layer" "SET" "A-WALL-SLAB" "PLOT" "NO" "VIEWPORT" "")

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top