Author Topic: vl-registry-write  (Read 5398 times)

0 Members and 1 Guest are viewing this topic.

cadman6735

  • Guest
vl-registry-write
« 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]
« Last Edit: July 28, 2016, 11:47:42 AM by cadman6735 »

ChrisCarlson

  • Guest
Re: vl-registry-write
« Reply #1 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)

ronjonp

  • Needs a day job
  • Posts: 7529
Re: vl-registry-write
« Reply #2 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. )
« Last Edit: July 28, 2016, 12:31:26 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

cadman6735

  • Guest
Re: vl-registry-write
« Reply #3 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.




ronjonp

  • Needs a day job
  • Posts: 7529
Re: vl-registry-write
« Reply #4 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.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

cadman6735

  • Guest
Re: vl-registry-write
« Reply #5 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)


ronjonp

  • Needs a day job
  • Posts: 7529
Re: vl-registry-write
« Reply #6 on: July 28, 2016, 01:45:08 PM »
Maybe you need to deal with trusted file locations.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

cadman6735

  • Guest
Re: vl-registry-write
« Reply #7 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.


ChrisCarlson

  • Guest
Re: vl-registry-write
« Reply #8 on: July 28, 2016, 02:01:18 PM »

ronjonp

  • Needs a day job
  • Posts: 7529
Re: vl-registry-write
« Reply #9 on: July 28, 2016, 02:13:22 PM »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ronjonp

  • Needs a day job
  • Posts: 7529
Re: vl-registry-write
« Reply #10 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.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: vl-registry-write
« Reply #11 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.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

cadman6735

  • Guest
Re: vl-registry-write
« Reply #12 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.

ronjonp

  • Needs a day job
  • Posts: 7529
Re: vl-registry-write
« Reply #13 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:

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ronjonp

  • Needs a day job
  • Posts: 7529
Re: vl-registry-write
« Reply #14 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?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC