Results 1 to 10 of 10

Thread: Modify DWGPREFIX?

  1. #1
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    Denver, Colorado
    Posts
    1,515
    Login to Give a bone
    0

    Default Modify DWGPREFIX?

    In a lisp I'm writing, I'd like to reference a directory that's in a similar, but different, directory; i.e., if dwgprefix is "c:\temp\piping", I'd like it to be "c:\temp\misc". "c:\temp\" might change over time, but the relative location of "piping" and "misc" would always be the same. How would I go about doing that?

    Many thanks in advance!

    -stu
    Last edited by stusic; 2012-02-08 at 08:08 PM. Reason: clarification

  2. #2
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Modify DWGPREFIX?

    If hard-coding the directories is not an issue, then consider this simple example:

    Code:
    (defun _GetPath (path / bad)
      (vl-load-com)
      ;; Example: (_GetPath "c:\\temp\\piping")
      (if (vl-string-search (setq bad "piping") path)
        (vl-string-subst "misc" bad path)))
    HTH
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

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

    Default Re: Modify DWGPREFIX?

    Try: "..\misc"
    A single period references the current directory, two periods reference the parent directory.

    Try adding an xref to a drawing with relitive pathing. If in the same directory it would be ".\file.dwg" or in your case "..\misc\file.dwg.

  4. #4
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    Denver, Colorado
    Posts
    1,515
    Login to Give a bone
    0

    Default Re: Modify DWGPREFIX?

    Well, not exactly hard-coded. I'm using the dwgprefix to get the current file location, which is what needs modification. I need to copy the file from "c:\temp" to the "misc" folder, which is the relative location of the dwgprefix (which will be in the "piping" directory).

    I was starting with this (the destination filepath is just quotes, cause I didn't know how to get my variable):
    Code:
    (vl-file-copy "c:\\temp\\dext.xls" "" T)
    Any advice?

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

    Default Re: Modify DWGPREFIX?

    Try:
    Code:
     (vl-file-copy ".\\dext.xls" "..\\misc\\dext.xls" T)
    or:
    Code:
     (vl-file-copy (strcat(getvar "dwgprefix")".\\dext.xls") "..\\misc\\dext.xls" T)

  6. #6
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    Denver, Colorado
    Posts
    1,515
    Login to Give a bone
    0

    Default Re: Modify DWGPREFIX?

    Okay, per Tom's code, I modified it slightly to move it straight from the temp directory to the misc directory:
    Code:
    (vl-file-copy "c:\\temp\\dext.xls" (strcat(getvar "dwgprefix")"..\\misc\\dext.xls" T))
    That works great, but I'm running into other problems now, so I'm going to start a new thread.

    Thanks for your help all!

  7. #7
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    Denver, Colorado
    Posts
    1,515
    Login to Give a bone
    0

    Default Re: Modify DWGPREFIX?

    Simple fix for my other thread, but I do have one more question regarding all this moving files, etc...

    I'd like to use the DWGNAME to rename my excel file, but not get the extension as well. I imagine I'd convert the variable to a string, then remove the last four characters (".dwg"), but I'm not sure that'd be the best way (nor how to exactly go about doing that).

    Last bit of help I'll ask for (about this aprticular issue, anyways )

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

    Default Re: Modify DWGPREFIX?

    Quote Originally Posted by stusic View Post
    Simple fix for my other thread, but I do have one more question regarding all this moving files, etc...

    I'd like to use the DWGNAME to rename my excel file, but not get the extension as well. I imagine I'd convert the variable to a string, then remove the last four characters (".dwg"), but I'm not sure that'd be the best way (nor how to exactly go about doing that).

    Last bit of help I'll ask for (about this aprticular issue, anyways )
    For years I've renamed point files extentions to CSV so I could easily open them with Excel and sort to get elevation range or find all the points of a certin type. As far as I know there isn't anything you can do with a DWG if you rename the extention. What are you trying to do?

  9. #9
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Modify DWGPREFIX?

    Quote Originally Posted by stusic View Post
    I'd like to use the DWGNAME to rename my excel file, but not get the extension as well. I imagine I'd convert the variable to a string, then remove the last four characters (".dwg"), but I'm not sure that'd be the best way (nor how to exactly go about doing that).
    ???

    Code:
    (vl-filename-base (getvar 'dwgname))
    Last edited by RenderMan; 2012-02-09 at 07:01 PM.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  10. #10
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    Denver, Colorado
    Posts
    1,515
    Login to Give a bone
    0

    Default Re: Modify DWGPREFIX?

    Well, I wanted to change the "dext.xls" to the same name as my dwg file (as returned from dwgname), but with ".xls" instead of ".dwg". But I figured it out ("dn" being the dwgname variable). However, I didn't know about "vl-filename-base", which is sooooo much easier... This is what I did:

    Code:
    (setq xls (vl-string-subst ".xls" ".dwg" dn))
    Thanks again so much everyone!

Similar Threads

  1. extract drive letter from dwgprefix
    By dilek in forum AutoCAD Customization
    Replies: 3
    Last Post: 2013-04-22, 12:46 PM
  2. 2012: Sorting on exported set by dwgprefix not by dwgnum
    By dprzewozny928995 in forum Revit - Plotting/Printing/Exporting
    Replies: 0
    Last Post: 2012-11-28, 03:02 PM
  3. Modify Floors > Modify Sub Elements
    By diesellam in forum Revit Architecture - General
    Replies: 3
    Last Post: 2010-02-23, 01:53 PM
  4. Plot to use DWGPREFIX as default folder
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 1
    Last Post: 2006-05-14, 01:59 PM
  5. Remove drive letter from dwgprefix using Diesel
    By jrichardson in forum AutoCAD Customization
    Replies: 3
    Last Post: 2006-02-23, 08:12 PM

Posting Permissions

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