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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating LiSP to isolate drawing layers w/ & w/out Xrefs 1

Status
Not open for further replies.

dortega4226

Technical User
Jul 29, 2010
4
US
I've done some searching and tried to modify several versions of LiSP I've found, but non of them do exactly what I need... well, entirely what I need, just a variation of.
I'm not very familiar with LiSP, hence the troubles, and I've spent too many hours trying to figure this out all alone. Will someone please advise me of my best options and the process of figuring this out?
Okay, here we go:
I'm trying to turn on/off several layers that are drawing based plus others that are named the same but are Xref based.

I've attached a drawing containing all of my layers w/ a bound Xref representing another drawing containing more of the same layers.

The reason behind this:
I have broken my trade into 4 parts. Each part will Xref each of the other three parts. Although the layers from the other drawings use only some of my standard layers, I still want to maintain full control of those layers while they are being Xref'd using LiSP.

I created this LiSP using three other LiSP Routines I found across different sites, it works but it's really slow and choppy.

(defun c:alf ()
(setq LayList '(
"0"

"*|B-150U50-54";
"*|B-150Z150-54"
"*|B-###S*'"
"*|B-###T*"
"*|B-B*"
"*|B-CLheadwall"
"*|B-Cloud"
"*|B-DiagonalKicker"
"*|B-DimCoord"
"*|B-DimCoordBKG"
"*|B-Logo"
"*|B-SoffitSolid"
"*|B-StudDirection"
"*|B-StudSOLO"
"*|B-Symbol-*"
"*|BD-*"
"*|BDW-*"
"*|BH-*"
"*|BW-*"

"B-150U50-54";
"B-150Z150-54"
"B-###S*"
"B-###T*"
"B-B*"
"B-CLheadwall"
"B-Cloud"
"B-DiagonalKicker"
"B-DimCoord"
"B-DimCoordBKG"
"B-Logo"
"B-SoffitSolid"
"B-StudDirection"
"B-StudSOLO"
"B-Symbol-*"
"BD-*"
"BDW-*"
"BH-*"
"BW-*"));

(foreach x LayList
(setq LayName (strcat x))
(command "layer" "off" LayName "" "")
);

(princ)
;clean running

) ;end defun

What I mean is, each layer is being turned off but it's running a command for each layer, first Xref based and then drawing based, which takes forever due to the amount of layers.

If you require anything more just ask and I'll be more than happy to help you -Help me!

Thanks in advance for all of your hard work and help.

David J. Ortega
3D BIM Coordinator
Brady Company/Los Angeles, Inc.
AutoCAD 2011 | AutoCAD Architecture 2011 | Revit Architecture 2011 | NavisWorks Manage 2011
 
That doesn't seem like very many layers, I would have thought that would take a few seconds. Maybe the drawing is regenerating after each command, you could turn off regens as part of the routine.

two syntax comments;
-shouldn't have a semicolon after layer name "*|B-150U50-54";
and
the 2 lines:
(setq LayName (strcat x))
(command "layer" "off" LayName "" "")

can be simplified to
(command "layer" "off" x "" "")


Could you cut the list in half; for examplwe
**BH-*" would handle "BH-*" and "*|BH-*"?

..or would that affect other layers?


Another thought, you can feed the layer command a string of layers separated by commas, so maybe a variable like:

(setq LongLayername "0,*|B-150U50-54,*|B-150Z150-54,*|B-###S*',*|B-###T*,
*|B-B*,
*|B-CLheadwall,
*|B-Cloud"u,etc...")

Then you'd need just one command
(command "layer" "off" Longlayername "" "")
 
And one other option, a modification of issuing the layer command. Instead of:

(foreach x LayList
(setq LayName (strcat x))
(command "layer" "off" LayName "" "")
);

keep the layer command active with:

(command "layer")
(foreach x LayList
(command "off" x)
);
(command "" "")
 
These all sound like great tips. I'll be sure to try them first thin Monday morning. I have a question about using "*BH-*" over "*|BH-*", would I still be able to turn off the layers that are being Xref'd? If so, then I don't believe it'll have any bearing on any other layers.
Thanks for your help on this, I'll keep you posted.
If I wanted to learn LiSP and get a good understanding of how to use it to it's fullest potential, what might I read, use and do?

David J. Ortega
3D BIM Coordinator
Brady Company/Los Angeles, Inc.
AutoCAD 2011 | AutoCAD Architecture 2011 | Revit Architecture 2011 | NavisWorks Manage 2011
 
I believe the "*BH-*" will affect all layer names that include the "BH-" anywhere within it, so including the xref layers.

Learn lisp just like you are doing-
-review other code
-experiment writing your own
-visit & ask questions at forums-cadtutor, theswamp.org, Autodesk,

is a good reference, and several other sites.


Good luck!
 
CarlAK and anyother looking into learning how to write or edit AutoCAD LiSP the website given above in the wrong extension.

Here's the correct website:


David J. Ortega
3D BIM Coordinator
Brady Company/Los Angeles, Inc.
AutoCAD 2011 | AutoCAD Architecture 2011 | Revit Architecture 2011 | NavisWorks Manage 2011
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top