See the top rated post in this thread. Click here

Results 1 to 8 of 8

Thread: Basic Lisp help copying files to a new folder

  1. #1
    Member
    Join Date
    2017-03
    Posts
    5
    Login to Give a bone
    0

    Default Basic Lisp help copying files to a new folder

    I am starting to automate our processes and am starting simple. We have a dynamic block that goes in virtually all our drawings. It's a simple prelim-to-final stamp required by client. The master dynamic block stays in the support folder and the normal procedure is to copy the master to the project folder the rename it with the job # as the prefix. So for example XXX-blockname.dwg gets renamed 1084-blockname.dwg. I am attempting to add this function to a toolbar button and derive the project# in some way, possibly from the sheet set, like reading a field. I started with this code I found, just to copy the file, but all I get is a nil return and no file created in the destination folder. Any assistance or better solution would be appreciated.

    (vl-file-copy "C:/XXX-BLOCK.dwg" "C:/Project Files/18-1084 EW1090, Bristle Rd, 31177, Calvin D3/CIV3D/1084-BLOCK.dwg")

  2. #2
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL
    Posts
    2,881
    Login to Give a bone
    0

    Default Re: Basic Lisp help copying files to a new folder

    It probably has to do with those commas. You could shell out and use xcopy which has 10 times the options. It would work with any folder names File Explorer would accept.

    Cannot say for sure as I'd never use a folder name like that.
    Tom Beauford P.S.M. - Civil 2018 on Windows 10 Enterprise
    Design Analysis - Leon County Public Works/Engineering
    2280 Miccosukee Rd. Tallahassee, FL 32308-5310
    Ph# (850)606-1516 Home Page

  3. #3
    Certified AUGI Addict rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Houston
    Posts
    9,432
    Login to Give a bone
    1

    Default Re: Basic Lisp help copying files to a new folder

    I just tried your code and it works here.
    I replicated your folder names (except that I had the starting file in C:\CADSTUFF and not in the root of C:\)

    Last edited by rkmcswain; 2018-08-08 at 08:13 PM. Reason: add screenshot
    R.K. McSwain | CAD Panacea |

  4. #4
    Member
    Join Date
    2017-03
    Posts
    5
    Login to Give a bone
    0

    Default Re: Basic Lisp help copying files to a new folder

    Quote Originally Posted by Tom Beauford View Post
    It probably has to do with those commas. You could shell out and use xcopy which has 10 times the options. It would work with any folder names File Explorer would accept.

    Cannot say for sure as I'd never use a folder name like that.
    I agree, but the folder structure is controlled by others. I did figure out the original problem, so I can get it to simply copy the file. The paths I showed were dummies and it was a typo. So the next step is to get it to derive the destination folder based on an open CAD file or some other process, and derive the project# as the prefix. The project #'s are typically the 4-digit prefix to all the CAD files and is the most consistent way to derive it from.

    - - - Updated - - -

    I found a typo in my real pathing, so that part I did manage to solve, now working on deriving the project folder & #

    - - - Updated - - -

    UPDATE

    Found a typo - fixed issue #1. So now I can copy the file from the support path into the project folder BUT to do so I have to type in the path and the project#. The goal is to derive the project folder and the project #. Is ther some way to make this macro button read the sheet set manager like calling a field to derive the project folder and #?

  5. #5
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL
    Posts
    2,881
    Login to Give a bone
    2

    Default Re: Basic Lisp help copying files to a new folder

    Code:
    (getvar "DWGPREFIX")
    gets you the drawing's folder.
    Code:
    (getvar "DWGNAME")
    gets you the drawing's name.
    Code:
    (substr(getvar "DWGNAME") 1 4)
    gets you the first four characters of the drawing's name.
    In case there may be more than four characters for the project# you may want to use wcmatch to look for a character that isn't a number and "substr" to it.
    Tom Beauford P.S.M. - Civil 2018 on Windows 10 Enterprise
    Design Analysis - Leon County Public Works/Engineering
    2280 Miccosukee Rd. Tallahassee, FL 32308-5310
    Ph# (850)606-1516 Home Page

  6. #6
    Member
    Join Date
    2017-03
    Posts
    5
    Login to Give a bone
    0

    Default Re: Basic Lisp help copying files to a new folder

    Not sure I have enough lisp savvy to put this all together, but thank you for the code. I'll give it a shot sometime today hopefully.

  7. #7
    Member
    Join Date
    2017-03
    Posts
    5
    Login to Give a bone
    1

    Default Re: Basic Lisp help copying files to a new folder

    Finalliy got it working.
    (vl-file-copy "<source path>" (strcat (getvar 'dwgprefix) (substr (getvar 'dwgname) 1 4) "-ODOT-BLOCK.dwg"))

  8. #8
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL
    Posts
    2,881
    Login to Give a bone
    0

    Default Re: Basic Lisp help copying files to a new folder

    Congratulations, now you're hooked like the rest of us!
    Tom Beauford P.S.M. - Civil 2018 on Windows 10 Enterprise
    Design Analysis - Leon County Public Works/Engineering
    2280 Miccosukee Rd. Tallahassee, FL 32308-5310
    Ph# (850)606-1516 Home Page

Similar Threads

  1. Replies: 1
    Last Post: 2015-07-15, 06:38 PM
  2. Please help me with a basic lisp routine!!
    By carlosadielvilla386292 in forum AutoLISP
    Replies: 7
    Last Post: 2013-06-03, 08:10 PM
  3. Very Basic LISP Help
    By scotts195810 in forum AutoLISP
    Replies: 10
    Last Post: 2012-01-08, 04:11 AM
  4. basic lisp programming
    By pkreusch in forum AutoLISP
    Replies: 5
    Last Post: 2009-07-30, 07:55 PM
  5. New to LISP - need basic help
    By chgolombek in forum AutoLISP
    Replies: 3
    Last Post: 2007-11-21, 12:51 PM

Tags for this Thread

Posting Permissions

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