Results 1 to 6 of 6

Thread: %username% in toolpalettepath Button Macro

  1. #1
    Member
    Join Date
    2006-04
    Location
    Michigan
    Posts
    22
    Login to Give a bone
    0

    Default %username% in toolpalettepath Button Macro

    I'm trying to change the tool palette file location system variable with a button macro. I need to include the %username% variable so that I can roll this out to my whole user base via a partial CUI. I'm using this button to get around the problems with networked tool palettes. I have one button for switching to network / shared palettes and one button for local palettes.

    Local Button Macro Syntax:
    ^C^C*_toolpalettepath "C:/Documents and Settings/%username%/Application Data/Autodesk/ADT 2006/enu/Support/WorkspaceCatalog (Imperial)/Palettes"

    This macro is not working...any thoughts? Maybe LISP would be better suited to this...

    Thank
    Jas

  2. #2
    I could stop if I wanted to Ogre's Avatar
    Join Date
    2005-06
    Location
    In the end, Cauliflower is just albino Broccoli
    Posts
    288
    Login to Give a bone
    0

    Default Re: %username% in toolpalettepath Button Macro

    Quote Originally Posted by CCDWAE
    I'm trying to change the tool palette file location system variable with a button macro. I need to include the %username% variable so that I can roll this out to my whole user base via a partial CUI. I'm using this button to get around the problems with networked tool palettes. I have one button for switching to network / shared palettes and one button for local palettes.

    Local Button Macro Syntax:
    ^C^C*_toolpalettepath "C:/Documents and Settings/%username%/Application Data/Autodesk/ADT 2006/enu/Support/WorkspaceCatalog (Imperial)/Palettes"

    This macro is not working...any thoughts? Maybe LISP would be better suited to this...

    Thank
    Jas
    Truthfully, I would work around this by making a folder on the C:\ drive called Custom and a folder called Tool Palettes underneath it, then point the *TOOLPALETTEPATH to that location...That keeps all "Windows" user specific files to one location...

    Now, if you have multiple users use the same machine, maybe that way will not work...If you absolutely have to have it like that, I would use a LISP function...I am not good with Macros, so I have to default to LISP...I am not sure, but the system variable LOCALROOTPREFIX is in AutoCAD and leads you right to the ...\enu\ folder in the documents & settings folder...

    Code:
    (defun c:TPLOCAL ( / cmdecho)
        (setq cmdecho (getvar "CMDECHO"))
        (setvar "CMDEACHO" 0)
        (command "*_TOOLPALETTEPATH"
            (strcat (getvar "LOCALROOTPREFIX") "Support/WorkspaceCatalog (Imperial)/Palettes")
        );command
        (setvar "CMDECHO" cmdecho)
        (princ)
    );defun
    I hope this helps you...

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

    Lightbulb Re: %username% in toolpalettepath Button Macro

    Quote Originally Posted by CCDWAE
    ^C^C*_toolpalettepath "C:/Documents and Settings/%username%/Application Data/Autodesk/ADT 2006/enu/Support/WorkspaceCatalog (Imperial)/Palettes"

    This macro is not working...any thoughts? Maybe LISP would be better suited to this...
    Neither the command interpreter nor the lisp interpreter know how to expand Windows environment variables.

    You will have to use something like this:

    Code:
    (strcat (getvar "RoamableRootPrefix") "Support\\WorkspaceCatalog (Imperial)\\Palettes")
    ...to get your string.

    Here is a list of some other useful things you can retreive in lisp:

    (getenv "temp") ; Returns the Windows %temp% directory.
    (getvar "LOCALROOTPREFIX")
    (vl-registry-read (strcat "HKEY_LOCAL_MACHINE\\" (vlax-product-key)) "ACADLOCATION") ; Gets the product install directory
    (getenv "userprofile") ; Returns the Windows user profile directory

    HTH
    Last edited by rkmcswain; 2006-12-29 at 02:20 PM.
    R.K. McSwain | CAD Panacea |

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

    Default Re: %username% in toolpalettepath Button Macro

    Quote Originally Posted by Ogre
    ... but the system variable LOCALROOTPREFIX is in AutoCAD and leads you right to the ...\enu\ folder in the documents & settings folder...
    Ogre, I don't think the OP wants "localrootprefix". By default, the toolpalettes are stored in C:\Documents and Settings\username\Application Data\....., not in C:\Documents and Settings\randym\Local Settings\Application Data...

    "RomeableRootPrefix" will return the correct path.
    R.K. McSwain | CAD Panacea |

  5. #5
    I could stop if I wanted to Ogre's Avatar
    Join Date
    2005-06
    Location
    In the end, Cauliflower is just albino Broccoli
    Posts
    288
    Login to Give a bone
    0

    Default Re: %username% in toolpalettepath Button Macro

    Quote Originally Posted by rkmcswain
    Ogre, I don't think the OP wants "localrootprefix". By default, the toolpalettes are stored in C:\Documents and Settings\username\Application Data\....., not in C:\Documents and Settings\randym\Local Settings\Application Data...

    "RomeableRootPrefix" will return the correct path.
    Thanks RK...I did not realize...Thanks for the help...

  6. #6
    Member
    Join Date
    2006-04
    Location
    Michigan
    Posts
    22
    Login to Give a bone
    0

    Default Re: %username% in toolpalettepath Button Macro

    Thanks a ton guys. I found my solution.

    Functioning button Macro Code:

    (command "*_TOOLPALETTEPATH" (strcat (getvar "RoamableRootPrefix") "Support/WorkspaceCatalog (Imperial)/Palettes"))

    Now one final hurtle. Does anyone know how to set the tool palette view options via code?

    When I change the system variable it resets the palette view options back to default. I have setup my tool palettes to be best viewed as a list with the icon made as small as possible.

    Thanks again for all the help.
    Jas

Similar Threads

  1. macro print button
    By sigmaman88 in forum AutoLISP
    Replies: 1
    Last Post: 2010-06-14, 05:29 AM
  2. Button macro
    By thomas.stright in forum AutoLISP
    Replies: 1
    Last Post: 2009-09-23, 01:45 PM
  3. Inventor macro button
    By gerrard.hickson in forum VBA/COM Interop
    Replies: 7
    Last Post: 2009-03-22, 11:00 PM
  4. Button Macro Help
    By ahefner in forum AutoLISP
    Replies: 5
    Last Post: 2007-07-17, 05:10 PM
  5. VBA button macro won't run
    By CADKitty in forum VBA/COM Interop
    Replies: 10
    Last Post: 2006-05-25, 07:47 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
  •