Author Topic: Adding a personal ToolPalette...  (Read 537 times)

0 Members and 1 Guest are viewing this topic.

framednlv

  • Newt
  • Posts: 40
Adding a personal ToolPalette...
« on: November 04, 2020, 03:21:03 PM »
Just thought someone might like this.  It will add a personal Tool Pallet folder and tool pallet.

Code: [Select]
;;;setup personal tool palette
(defun c:mytp ()
  (setq MY_FOLDER$
(strcat (getenv "UserProfile")
"\\Documents\\My Autocad Support"
)
  )
  (if (null (vl-file-directory-p MY_FOLDER$))
    (vl-mkdir MY_FOLDER$)
  )
  (setq MY_FOLDER$
(strcat (getenv "UserProfile")
"\\Documents\\My Autocad Support\\ToolPalette_"
(getvar 'loginname)
)
  )
  (if (null (vl-file-directory-p MY_FOLDER$))
    (vl-mkdir MY_FOLDER$)
  )
  (setq MY_TP$ (strcat (getenv "UserProfile")
       "\\Documents\\My Autocad Support\\ToolPalette_"
       (getvar 'loginname)
       "\\"
       (getvar 'loginname)
       ".atc"
       )
  )
  (if (null (findfile MY_TP$))
    (Progn
      (setq NewPalett$
     (strcat
       "<Palette FileRevision=\"24.0.0\" Revision=\"24.0.1\" option=\"0\"><ItemID idValue=\"{972F5139-08E5-4EDB-80F6-6290271782C3}\"/><Properties><ItemName>"
       (getvar 'loginname)
       "</ItemName><Images option=\"0\"/><Time createdUniversalDateTime=\"1978-01-01T00:00:00\" modifiedUniversalDateTime=\"1978-01-01T00:00:00\"/></Properties><CustomData><Translation status=\"1\"/></CustomData><Tools/></Palette>"
     )
      )
      (setq fname (open MY_TP$ "w"))
      (write-line NewPalett$ fname)
      (close fname)
    ) ;IF
  ) ;progn
  (setq OrigTP$ (getvar "*_toolpalettepath"))
  (setq mtp$ (strcat (getenv "UserProfile")
     "\\Documents\\My Autocad Support\\ToolPalette_"
     (getvar 'loginname)
     )
  )
  (setq ntp$ (strcat mtp$ ";" OrigTP$))
  (setvar "*_TOOLPALETTEPATH" ntp$)
  (princ)
)
« Last Edit: November 04, 2020, 03:25:05 PM by framednlv »

framednlv

  • Newt
  • Posts: 40
Re: Adding a personal ToolPalette...
« Reply #1 on: May 05, 2021, 05:05:07 PM »
Code: [Select]
(defun RE_MYTP (/ pattern RemoveTP$ BothTP CurrentTP PersonalTP)
(defun RemoveMYTP ()
(setq pattern (strcat (getenv "UserProfile") "\\Documents\\My Autocad Support\\"(getvar "loginname")"_Palettes;"))
(setq RemoveTP$ (vl-string-subst "" pattern CurrentTP ))
(setvar "*_TOOLPALETTEPATH" RemoveTP$)
)


(defun AddMYTP ()
(if (null (vl-file-directory-p (strcat (getenv "UserProfile") "\\Documents\\My Autocad Support\\"(getvar "loginname")"_Palettes")))
(vl-mkdir (strcat (getenv "UserProfile") "\\Documents\\My Autocad Support\\"(getvar "loginname")"_Palettes")))
(setvar "*_TOOLPALETTEPATH" (strcat (getenv "UserProfile") "\\Documents\\My Autocad Support\\"(getvar "loginname")"_Palettes"))
(command "DELAY" 500)
(setq BothTP (strcat (getenv "UserProfile") "\\Documents\\My Autocad Support\\"(getvar "loginname")"_Palettes;" CurrentTP))
(setvar "*_TOOLPALETTEPATH" BothTP)
)

(setq CurrentTP (getvar "*_TOOLPALETTEPATH"))
(setq PersonalTP (strcat (getenv "UserProfile") "\\Documents\\My Autocad Support\\"(getvar "loginname")"_Palettes*"))
(if (wcmatch CurrentTP PersonalTP)
(RemoveMYTP);;Go to removeTP
(AddMYTP);;Go to AddTP
);end if
);end defun