TheSwamp

CAD Forums => CAD General => Topic started by: cadman6735 on July 28, 2016, 11:31:48 AM

Title: vl-registry-write
Post by: cadman6735 on July 28, 2016, 11:31:48 AM
I was watching an AU video where the instructor edited his registry to point PSETUPIN to open his dialog box to a default specific folder of his choosing each and everytime.  I can't seem to get it to work.  here is the code I copied from a screen capture.  On my computer at home the code edited the registry but the dialog never defaulted to that location.  I am using AutoCAD 2002 at home, so thinking I need a newer version, I tried it here at work on a crap machine for testing stuff with AutoCAD 2015, I can't even get the registry to update, so I manually changed the Registry to my desired location but still no go, it does not default to this desired location.  I am very interesting in learning how to manipulate the registry and control my default dialog boxes.

Can someone explain to me and point me to some good examples and tutorials, etc...

Thanks

Code: [Select]
[/(vl-load-com)
(vl-registry-write (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Profile\\" (getvar "cprofile") "\\Dialogs\\PSETUPNavDlg") "FileNameMRU0" "C:\\Autodesk\\Publish_Template.dwt")
(vl-registry-write (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Profile\\" (getvar "cprofile") "\\Dialogs\\PSETUPNavDlg") "InitialDirectory" "C:\\Autodesk")code]
Title: Re: vl-registry-write
Post by: ChrisCarlson on July 28, 2016, 12:02:55 PM
Actually, I wouldn't mess with the registry. I think you need to restart AutoCAD for it to see the changes to the registry.

Look into "PlotToFilePath"

(setenv "PlotToFilePath" locationasstring)
Title: Re: vl-registry-write
Post by: ronjonp on July 28, 2016, 12:18:41 PM
Wouldn't your pagesetups be static? You could set filedia to 0 then run (vl-cmdf ".-psetupin" fulltemplatepath "*") to automagically import them.


Here'a a stripped down version of a routine I've used for year that you could modify.
Code - Auto/Visual Lisp: [Select]
  1. (defun c:page (/ path)
  2.   ;; Delete all pagesetups first
  3.     (vla-delete x)
  4.   )
  5.   ;; Import if file is found
  6.   (if (findfile (setq path "C:/Your/Path/YourTemplate.dwt"))
  7.     (progn (setvar 'filedia 0)
  8.       (vl-cmdf ".-psetupin" path "*")
  9.       (princ "\n <<<Pagesetups Imported>>>")
  10.       (setvar 'filedia 1)
  11.     )
  12.     (princ "\n <<<AAAAAGGGGGHHHH!!!!! .. Pagesetups NOT FOUND!>>>")
  13.   )
  14.   (princ)
  15. )
Title: Re: vl-registry-write
Post by: cadman6735 on July 28, 2016, 12:25:11 PM
Hi mater shake, I did restart my autocad, but it didn't update.  Thanks anyway.

I respect the notion of not messing with the registry, but the tools are there and I see some desired results, I am interested in learning and wanting to understand, not to be discouraged. 


Hi RonJon,  yes, I am already importing them,
I just saw a new trick that I feel I can expand upon and wanting to understand why the code is not working and hoping to find a new path of information by asking.



Title: Re: vl-registry-write
Post by: ronjonp on July 28, 2016, 12:32:07 PM
..
Hi RonJon,  yes, I am already importing them,
I just saw a new trick that I feel I can expand upon and wanting to understand why the code is not working and hoping to find a new path of information by asking.
I updated my post above to include some code.
Title: Re: vl-registry-write
Post by: cadman6735 on July 28, 2016, 12:39:43 PM
I have some code similar to yours, that I believe CAB helped me with years ago,  but when I place it in a sub folder and have my AutoLoad.lsp try to load it, it errors.  But when I place it in the main folder as my autolaod.lsp, not an issue...  I can't figure out why, and I hate having it outside of my macro folder, just seems so out of place.

Code: [Select]
(defun PageSetup_AutoLoad (/)
 
;=====================================================================================================
; Load Plot Page Setup from Template file                               
;=====================================================================================================

  (setq *path* "S:\\VDC Library\\AutoCAD\\User Interface\\Plotters\\Publish\\"
*file* "Publish_Template.dwg"
*pathfile* (strcat *path* *file*)
  )
 
  (if
    (findfile *pathfile*)
    (progn
     
      (command "._psetupin" *pathfile* "*")
      (while (wcmatch (getvar "cmdnames") "*PSETUPIN*") (command "_y"))
    )
  ) 
(princ)
)(PageSetup_AutoLoad)

Title: Re: vl-registry-write
Post by: ronjonp on July 28, 2016, 01:45:08 PM
Maybe you need to deal with trusted file locations (https://knowledge.autodesk.com/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-Core/files/GUID-2FB4611D-F141-48D5-9B6E-460EB59351AF-htm.html).
Title: Re: vl-registry-write
Post by: cadman6735 on July 28, 2016, 01:59:34 PM
I have my secure loaded turned off (setvar "SecureLoad" 0) and my autoload loads all my other macros but this one, so it's not that.  I also believe, because you said that, you have clued me into another issue I am having, so thanks


Anyway this is all off topic, I am interested in learning about the registry environment and why the code I supplied does not work.

Where I want to grow with this is to control default start locations for when dialog boxes open, they start somewhere and remember the last place they where at when opening, and I want to have some control over this.

Title: Re: vl-registry-write
Post by: ChrisCarlson on July 28, 2016, 02:01:18 PM

Take a gander over here

https://www.theswamp.org/index.php?topic=40962.0
Title: Re: vl-registry-write
Post by: ronjonp on July 28, 2016, 02:13:22 PM

Take a gander over here

https://www.theswamp.org/index.php?topic=40962.0 (https://www.theswamp.org/index.php?topic=40962.0)


FWIW HERE (https://www.theswamp.org/index.php?topic=5029.msg502985#msg502985) is the most recent version of that code.
Title: Re: vl-registry-write
Post by: ronjonp on July 28, 2016, 02:14:57 PM
I have my secure loaded turned off (setvar "SecureLoad" 0) and my autoload loads all my other macros but this one, so it's not that.  I also believe, because you said that, you have clued me into another issue I am having, so thanks
...
Anyway this is all off topic, I am interested in learning about the registry environment and why the code I supplied does not work.
Are you an admin on your computer? Perhaps you don't have write access to the registry.
Title: Re: vl-registry-write
Post by: dgorsman on July 28, 2016, 02:18:09 PM
I have my secure loaded turned off (setvar "SecureLoad" 0) and my autoload loads all my other macros but this one, so it's not that.  I also believe, because you said that, you have clued me into another issue I am having, so thanks
...
Anyway this is all off topic, I am interested in learning about the registry environment and why the code I supplied does not work.
Are you an admin on your computer? Perhaps you don't have write access to the registry.

Could also be UAC protecting the computer from the user.
Title: Re: vl-registry-write
Post by: cadman6735 on July 28, 2016, 02:40:55 PM
Thanks for the link to the code, Shake Master and RonJon, very helpful.  The code I supply is pathing the same as Ron's only difference I see is where I have "FileNameMRU0" and "InitialDirectory" where Ron seems to be only using "InitialDirectory" on most and "(Default)" "Initialdirectory" "FileNameMRU0" in conjunction with others.  So I may not be using it right in conjunction with each other.  I will experiment to see what I can learn.

RonJon, when you wrote that macro, where did you get the info to tell you what each registry name meant and how to use it?  example:  "InitialDirectory" "(Default)" "FileNameMRU0"

I am also wondering if I have admin rights to the registry myself, AutoCAD can't make the change via lisp, but I can manually change the registry.  But it still does not update my autoCAD after manual update, how will I know if I have rights to write to it.  It say I have full control but it is greyed out.

I have only experimented with PSETUPNavDlg so the code may not even be correct for the specific one.
Title: Re: vl-registry-write
Post by: ronjonp on July 28, 2016, 02:48:00 PM
..
RonJon, when you wrote that macro, where did you get the info to tell you what each registry name meant and how to use it?  example:  "InitialDirectory" "(Default)" "FileNameMRU0"
..
To be honest I don't really remember. I think it was just a bunch of searching the registry for keys that changed & wrote the lisp to modify the same keys.  :oops:
Title: Re: vl-registry-write
Post by: ronjonp on July 28, 2016, 03:03:13 PM
..
I have only experimented with PSETUPNavDlg so the code may not even be correct for the specific one.
In 2017, the key to modify is this:
Code - Auto/Visual Lisp: [Select]
  1. (vl-registry-write (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Profile\\" (getvar "cprofile") "\\Dialogs\\Select Page Setup From File") "InitialDirectory" "C:\\Autodesk\\")
I don't have a 'PSETUPNavDlg' key?
Title: Re: vl-registry-write
Post by: cadman6735 on July 28, 2016, 04:29:40 PM
Well, I am not sure if "Select Page Setup From File" was already there or if the macro created it, but see it too.
After running this macro, my dialog default changed to my documents so something happened but not "C:\\Autodesk\\"

RonJon, thanks for the help, I'll do some more research and figure it out, if I don't break my machine first.