See the top rated post in this thread. Click here

Results 1 to 7 of 7

Thread: My reliable Insert Layers LISP needs help

  1. #1
    Member
    Join Date
    2018-03
    Posts
    4
    Login to Give a bone
    0

    Default My reliable Insert Layers LISP needs help

    Team,

    I have a LISP I was given on these forums way back in 2009 or so that would insert layers into a drawing from a template.

    But now in my new position it doesn't want to work in our network infrastructure...

    The original code is

    ;ILAYER - INSERTS DEFAULT LAYERS INTO A DRAWING
    (defun C:iLayer ( / template random)
    (setq template "\\xxx-server\data\user_redirects\myname\Documents\4 xxx CAD Library\Templates\Layers\Layers.dwt")
    (setq random (strcat (vl-filename-mktemp) ".dws"))
    (vl-file-copy template random)
    (command "._Insert" (strcat "*" random) (list 0 0 0) "1.0" "0.0" )
    )

    Any time I run it I receive errors like this:

    Command:
    Command: ILAYER
    ._Insert Enter block name or [?]: *C:\Users\myname\AppData\Local\Temp\$VL~~001.dws
    "$VL~~001.dws": Can't find file in search path:
    \\xxx-server\data\user_redirects\myname\Documents\ (current directory)
    \\xxx-server\data\user_redirects\myname\Documents\Z CAD Support Files\
    \\xxx-server\data\user_redirects\myname\Documents\4 xxx CAD Library\Templates\Layers\
    \\xxx-server\data\user_redirects\myname\Documents\Z CAD Support Files\Lisps\
    \\xxx-server\data\user_redirects\myname\Documents\4 CTCI CAD Library\
    C:\Users\myname\AppData\Local\Temp\
    C:\Users\myname\AppData\Roaming\Autodesk\AutoCAD 2021\R24.0\enu\support\
    C:\Program Files\Autodesk\AutoCAD 2021\support\
    C:\Program Files\Autodesk\AutoCAD 2021\support\en-US\
    C:\Program Files\Autodesk\AutoCAD 2021\fonts\
    C:\Program Files\Autodesk\AutoCAD 2021\Express\
    C:\Program Files\Autodesk\AutoCAD 2021\support\color\
    C:\Program Files (x86)\Autodesk\ApplicationPlugins\Autodesk AppManager 2020-2021.bundle\Contents\Windows\
    C:\Program Files (x86)\Autodesk\ApplicationPlugins\Autodesk AppManager 2020-2021.bundle\Contents\Windows\2021\
    C:\Program Files (x86)\Autodesk\ApplicationPlugins\Autodesk FeaturedApps 2020-2021.bundle\Contents\Resources\
    C:\Program Files (x86)\Autodesk\ApplicationPlugins\Autodesk FeaturedApps 2020-2021.bundle\Contents\Windows\2021\Win64\
    C:\Program Files (x86)\Autodesk\ApplicationPlugins\Autodesk QRCodes 2020-2021.bundle\Contents\Windows\2021\win64\
    C:\Program Files (x86)\Autodesk\ApplicationPlugins\Autodesk QRCodes 2020-2021.bundle\Contents\Resources\
    C:\Program Files\Autodesk\AutoCAD 2021\drv\
    C:\Program Files\Autodesk\AutoCAD 2021\
    *Invalid*
    ; error: Function cancelled
    Command:

    Any ideas?

    Thx,

    Red

  2. #2
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    555
    Login to Give a bone
    1

    Default Re: My reliable Insert Layers LISP needs help

    try (setq template "\\\\xxx-server\\data\\user_redirects\\myname\\Documents\\4 xxx CAD Library\\Templates\\Layers\\Layers.dwt") spaces in directory name can do some funny things.

  3. #3
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    555
    Login to Give a bone
    1

    Default Re: My reliable Insert Layers LISP needs help

    Also as you have paths set why not just (command "-insert" "layers.dwt" ............ no need to copy

  4. #4
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,658
    Login to Give a bone
    1

    Default Re: My reliable Insert Layers LISP needs help

    FYI: If any of the layers already exist in the drawing importing a template will not update the layer properties like importing and restoring a Layer State would.

  5. #5
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,096
    Login to Give a bone
    1

    Default Re: My reliable Insert Layers LISP needs help

    Quote Originally Posted by BIG-AL View Post
    try (setq template "\\\\xxx-server\\data\\user_redirects\\myname\\Documents\\4 xxx CAD Library\\Templates\\Layers\\Layers.dwt") spaces in directory name can do some funny things.
    I'm not sure it was the spaces, but more so with the single backslashes. AutoLISP requires backslashes to be escaped in strings. The escape character just so happens to be a backslash. To get a single backslash in a string, one would need to double all backslashes in their code.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  6. #6
    Member
    Join Date
    2018-03
    Posts
    4
    Login to Give a bone
    0

    Default Re: My reliable Insert Layers LISP needs help

    Quote Originally Posted by BIG-AL View Post
    try (setq template "\\\\xxx-server\\data\\user_redirects\\myname\\Documents\\4 xxx CAD Library\\Templates\\Layers\\Layers.dwt") spaces in directory name can do some funny things.
    Thanks I updated to try that with no luck

    - - - Updated - - -

    Quote Originally Posted by Tom Beauford View Post
    FYI: If any of the layers already exist in the drawing importing a template will not update the layer properties like importing and restoring a Layer State would.
    Thanks Tom good point to remember, but these are files from others we are updating and have to add our layers to them before we start our work.

    - - - Updated - - -

    Quote Originally Posted by Opie View Post
    I'm not sure it was the spaces, but more so with the single backslashes. AutoLISP requires backslashes to be escaped in strings. The escape character just so happens to be a backslash. To get a single backslash in a string, one would need to double all backslashes in their code.
    Opie, I believe you actually helped me set up this LISP way back.

    - - - Updated - - -

    Hold it!

    I followed Big Al's update and then had a PEBCAK issue... seems to be working now!

    Thank you all once again for saving my butt!

  7. #7
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,658
    Login to Give a bone
    0

    Default Re: My reliable Insert Layers LISP needs help

    Quote Originally Posted by GFournier301 View Post
    Thanks Tom good point to remember, but these are files from others we are updating and have to add our layers to them before we start our work.

    - - - Updated - - -
    You would have to save the layer state from the template removing the layers you don't want first, then bringing them in to the current drawing and making sure the layer settings are correct with lisp is a snap.
    layerstate-import (AutoLISP)
    https://help.autodesk.com/view/ACD/2...1-2CEA0C21EA1B

    Never mind don't do that! Been a while but you need to use the dialog box for importing layer states to have the option to not turn off layers not included in the layer state.
    Last edited by Tom Beauford; 2021-03-01 at 04:41 PM. Reason: Oops!

Similar Threads

  1. Can ramp be reliable for construction?
    By Alvin_Alejandro in forum Revit Architecture - General
    Replies: 7
    Last Post: 2012-07-05, 03:30 AM
  2. Replies: 7
    Last Post: 2008-12-22, 07:51 PM
  3. Provide a More Reliable Drawing Recovery Tool
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 5
    Last Post: 2008-01-10, 08:07 PM
  4. Reliable hatch patterns
    By Wagurto in forum Revit Architecture - General
    Replies: 1
    Last Post: 2004-08-05, 06:55 PM
  5. How reliable are recovery files?
    By david1803 in forum Revit Architecture - General
    Replies: 3
    Last Post: 2003-10-30, 02:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •