Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Constant/Global Variables in acaddoc.lsp

  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 Constant/Global Variables in acaddoc.lsp

    I'd like to add a few lisp variables to my acaddoc.lsp file, but I'm not sure it'd work. For instance, if I set a variable to (getvar "dwgname") in acaddoc and make it a global variable, would it update the variable to reflect the new dwgname when I open another drawing? My goal is to make a field that has a diesel expression using this variable for our title blocks, but it won't work if it's holding the filename from the first drawing...

    Thanks

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

    Default Re: Constant/Global Variables in acaddoc.lsp

    If you're using a field why the need to set a variable? Do it all in the field and it will even update if you change the drawing name.

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

    Default Re: Constant/Global Variables in acaddoc.lsp

    Well, I suppose dwgname was a bad example. Sorry about that.

    What I want to do is isolate the name of the folder three folders up from where the drawing resides (the project number) and set that as a variable (i.e., "c:\projects\254789\units\piping\pipingdiagram01.dwg" would be "254789"), then use that variable in a field in the title block. But if it doesn't update when another project drawing is open, then it'd update the title block with the wrong project number.

    Also, I realize it wouldn't be a diesel expression (my original idea on how to go about it), but a lisp variable.

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

    Default Re: Constant/Global Variables in acaddoc.lsp

    Unless you propagate the variable using the vl-propagate function, the "global" variable is only for the drawing it was set. You would be able to have the same variable across multiple open drawings with different values per drawing.
    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

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

    Default Re: Constant/Global Variables in acaddoc.lsp

    Quote Originally Posted by Opie View Post
    Unless you propagate the variable using the vl-propagate function, the "global" variable is only for the drawing it was set. You would be able to have the same variable across multiple open drawings with different values per drawing.
    I've heard that propagate may the way to go, but I don't know VL or how to use that function. Is it something easy to use for a non-vlisp hacker?

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

    Default Re: Constant/Global Variables in acaddoc.lsp

    From my understanding of your request, I don't think that is what you would want to do. I am assuming you are making this global variable automatic based on the drawing. If you open up another drawing that is not part of the project and propagate the variable, you may get unexpected results.
    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

  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: Constant/Global Variables in acaddoc.lsp

    Quote Originally Posted by Opie View Post
    From my understanding of your request, I don't think that is what you would want to do. I am assuming you are making this global variable automatic based on the drawing. If you open up another drawing that is not part of the project and propagate the variable, you may get unexpected results.
    Yeah, I'm trying to avoid the unexpected results

    I was originally thinking a diesel expression may work, which would update like it's supposed to, but I don't know that it can do the in-depth digging like lisp can that I need to get the folder name.

  8. #8
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,805
    Login to Give a bone
    0

    Default Re: Constant/Global Variables in acaddoc.lsp

    Quote Originally Posted by stusic View Post
    Yeah, I'm trying to avoid the unexpected results

    I was originally thinking a diesel expression may work, which would update like it's supposed to, but I don't know that it can do the in-depth digging like lisp can that I need to get the folder name.
    I don't suppose your example of a path/filename is the real thing...?...meaning that the part leading up to the project # is a constant length?

    If by chance it is, something like this should work.
    $(substr, $(getvar,dwgprefix)$(getvar,dwgname), 14, 6)
    Last edited by rkmcswain; 2012-07-12 at 11:28 PM. Reason: edit code
    R.K. McSwain | CAD Panacea |

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

    Default Re: Constant/Global Variables in acaddoc.lsp

    For when file paths are not a constant length:

    Quote Originally Posted by RenderMan View Post
    Welcome to AUGI!

    Give this a try:
    Code:
    (vl-load-com)
    (defun _FilePath->List (filePath / i folder folders)
      (setq filePath (vl-string-translate "\\" "/" filePath))
      (while (setq i (vl-string-search "/" filePath))
         (setq folders (cons (setq folder (substr filePath 1 i)) folders))
         (setq filePath (substr filePath (+ 2 i)))
         )
      (reverse folders)
      )
    Example:
    Code:
    _$ (_FilePath->List "G:\\745 The name of the Project\\74534\\drawings\\")
    ("G:" "745 The name of the Project" "74534" "drawings")
    _$
    "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: Constant/Global Variables in acaddoc.lsp

    Quote Originally Posted by rkmcswain View Post
    I don't suppose your example of a path/filename is the real thing...?...meaning that the part leading up to the project # is a constant length?
    Ah, not that lucky this time. The folder changes often (but from the project name to the drawing it stays the same). Thanks tho'!

Page 1 of 2 12 LastLast

Similar Threads

  1. listing global variables
    By bowtle in forum AutoLISP
    Replies: 6
    Last Post: 2009-07-09, 05:08 AM
  2. ACADDOC.LSP - System Variables?
    By stykface in forum CAD Standards
    Replies: 8
    Last Post: 2009-05-20, 06:39 AM
  3. Document Level Global variables in Revit API
    By aireq303 in forum Dot Net API
    Replies: 1
    Last Post: 2009-01-19, 11:56 PM
  4. Global Variables
    By ccowgill in forum AutoLISP
    Replies: 10
    Last Post: 2008-11-24, 07:23 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
  •