×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

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

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

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

(OP)
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

RE: Creating LiSP to isolate drawing layers w/ & w/out Xrefs

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 "" "")  

RE: Creating LiSP to isolate drawing layers w/ & w/out Xrefs

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 "" "")
 

RE: Creating LiSP to isolate drawing layers w/ & w/out Xrefs

(OP)
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

RE: Creating LiSP to isolate drawing layers w/ & w/out Xrefs

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,

www.afralisp.com is a good reference, and several other sites.


Good luck!

RE: Creating LiSP to isolate drawing layers w/ & w/out Xrefs

(OP)
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:

www.afralisp.net

David J. Ortega
3D BIM Coordinator
Brady Company/Los Angeles, Inc.
AutoCAD 2011 | AutoCAD Architecture 2011 | Revit Architecture 2011 | NavisWorks Manage 2011

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close