TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: danny on March 17, 2006, 02:44:55 AM

Title: update ACAD registry in current session
Post by: danny on March 17, 2006, 02:44:55 AM
Need help finding the variable to update ACAD Registry, read search paths.
I would like to change a search path in a current drawing file, but need to have ACAD re-read that changed path w/o closing and restarting the session.
I've been confused for a while now.  Ihope you guys can help.
Mahalo,
Title: Re: update ACAD registry in current session
Post by: kpblc on March 17, 2006, 03:43:49 AM
Search paths you can read using (getenv "ACAD").
(setenv "ACAD") determines all Support Files Search Paths for you current profile of AutoCAD.
If you want to change these settings, you have to return it to their start status (values), i think
Title: Re: update ACAD registry in current session
Post by: Kerry on March 17, 2006, 04:18:06 AM
Yep, sort of ;

As simple as this ...

Code: [Select]
(setq PathToAdd ";L:;L:\\_VLISP;L:\\_VLISP\\KDUB_SUPPORT"
      NewSupportPath   (strcat (getenv "ACAD") PathToAdd)
)

(setenv "ACAD" NewSupportPath)

;;; Check to make sure ..
(getenv "ACAD")
Title: Re: update ACAD registry in current session
Post by: Kerry on March 17, 2006, 04:42:17 AM
afterthought :

You may want to experiment with

(setenv "ACAD" "")

to clear the path and automatically restote the settings from the ACAD UnnamedProfile.

The NewPath string could be concatenated in front of the current pathString.
Title: Re: update ACAD registry in current session
Post by: ronjonp on March 17, 2006, 08:34:57 AM
This is what I use:

Code: [Select]
(vl-load-com)
(defun addpaths (/ files expaths newpath)
  (setq files (vla-get-files (vla-get-preferences (vlax-get-acad-object)))
expaths (vla-get-supportpath files)
  )
  (setq newpath (strcat
  expaths
  ";"
  "C:\\Path1"
  ";"
  "C:\\Path2"
  ";"
  "C:\\Path3"
  ";"
  "C:\\Path4"
  ";"
          "C:\\Path5"
      )
    )
  (vla-put-supportpath files newpath)
(princ)
)
Title: Re: update ACAD registry in current session
Post by: danny on March 18, 2006, 10:23:25 PM
ok i've tried three ways.  maybe you can take a look at these...can't get them to work
Code: [Select]
(defun c:ctb (/ files expaths newpath)
  (vl-load-com)
    (setq files   (vla-get-files (vla-get-preferences (vlax-get-acad-object)))
  expaths (vla-get-supportpath files)
    )
    (setq newpath
   (strcat
     expaths
             ";"
     "M:paths"
   )
    )
    (vla-put-printerstylesheetpath files newpath)
    (princ)
  )

and
Code: [Select]
(defun c:ctb ()
(vl-load-com)
(setq prefs(vla-get-preferences (vlax-get-acad-object))
      filePrefs (vla-get-files prefs)
)
(vla-put-printerstylesheetpath filePrefs "M:path")
(vla-refreshplotdeviceinfo
  (vla-get-activelayout
   (vla-get-activedocument
     (vlax-get-acad-object))))
(princ)
)

and
Code: [Select]
(defun c:CTB ()
(setenv "PrinterStyleSheetDir" "M:\\_Cad Support\\AutoCAD 2004\\Autodesk\\Autodesk Architectural Desktop 2004\\R16.0\\enu\\AHL_CTB")
(princ)
)

I've been out for a while, forgive me...
Title: Re: update ACAD registry in current session
Post by: ronjonp on March 19, 2006, 01:10:06 AM
Paste this into your command line:
(vla-get-printerstylesheetpath (vla-get-files (vla-get-preferences (vlax-get-acad-object))))

If it shows a path...this should work:
(vla-put-printerstylesheetpath (vla-get-files (vla-get-preferences (vlax-get-acad-object)))"M:\\")

Ron
Title: Re: update ACAD registry in current session
Post by: Chuck Gabriel on March 19, 2006, 10:59:56 AM
Despite what the Object Model docs seem to imply, PrinterStyleSheetPath cannot contain multiple paths (as of 2004), so I wouldn't expect your first example to work as intended.

Your second example works fine for me if I substitute an actual path on my system in place of "M:path."  Is M:path a lisp variable?  If so, the problem is that you placed it in quotes.

I tried this in AutoCAD 2000i and 2004.  What version of AutoCAD are you using?
Title: Re: update ACAD registry in current session
Post by: danny on March 19, 2006, 06:15:38 PM
Quote
If it shows a path...this should work:
(vla-put-printerstylesheetpath (vla-get-files (vla-get-preferences (vlax-get-acad-object)))"M:\\")
This changed the search path but AutoCAD is not reading it.
How would I be able to get ACAD to re-read the substituted path in the current drawing?
AutoCAD reads support paths when you open the program, but will not read substituted or added paths in a current session.
 
Title: Re: update ACAD registry in current session
Post by: Chuck Gabriel on March 19, 2006, 08:05:13 PM
...
AutoCAD reads support paths when you open the program, but will not read substituted or added paths in a current session.
 

I know I'm starting to sound like a broken record, but that was not the case in the testing I did.  One thing I did notice which may be giving you some misleading results is that AutoCAD searches the specified folder AND all of its subfolders recursively, and returns a list of ALL of the ctb files it finds.
Title: Re: update ACAD registry in current session
Post by: danny on March 19, 2006, 10:36:32 PM
Sorry Chuck,
Its just not working for me.
Code: [Select]
(defun c:ctb ()
(vl-load-com)
(setq prefs(vla-get-preferences (vlax-get-acad-object))
      filePrefs (vla-get-files prefs)
)
(vla-put-printerstylesheetpath filePrefs "C:\\AutoCAD 2004\\Plot Styles")
(vla-refreshplotdeviceinfo
  (vla-get-activelayout
   (vla-get-activedocument
     (vlax-get-acad-object))))
(princ)
)
this changes the ctb path but doesn't set it current.  The ctb will show in the plot dialog box, but their not being read.
When I change the path manually under
Code: [Select]
options
files
printer support file path
plot style table search path
this will change the path but it won't be read untill you hit
apply
so what i'm trying to find is the code or function for
apply
and insert that into the lsp routine.

ronjonp,
do you remember this thread
http://www.theswamp.org/index.php?topic=1210.0
Title: Re: update ACAD registry in current session
Post by: Kerry on March 19, 2006, 10:54:14 PM
I can't post code , but I have a recollection of having to save/export the profile after the change, swapping profiles, then restoring the the original.

as I say this is a recollection, and may not solve the issue.
If you can't find some code to swap profiles, I recall that Jimmy Bergmark at www.jtbworld.com has some routines worth looking at.

added:
yep ; start here http://www.jtbworld.com/lisp.htm
Title: Re: update ACAD registry in current session
Post by: Chuck Gabriel on March 20, 2006, 12:25:13 PM
Sorry Chuck,
Its just not working for me.

I'm sorry we aren't making any progress on this.  I think this is one of those instances where face to face communication would grease the wheels tremendously.  What a great idea!  You can just fly me over (no need for a return ticket), and we'll get this thing solved. :-)
Title: Re: update ACAD registry in current session
Post by: danny on March 20, 2006, 01:26:17 PM
Quote
What a great idea!  You can just fly me over (no need for a return ticket)
the cost of living here is so high..and the pay is very low.
your better off just visiting..
a 1,000 sf condo, mid end, is currently starting @ $500,000 - $600,000.  Starting
Title: Re: update ACAD registry in current session
Post by: Chuck Gabriel on March 20, 2006, 01:37:35 PM
a 1,000 sf condo, mid end, is currently starting @ $500,000 - $600,000.  Starting

Like I said, I'm sure we can handle this via the forums. ;-)
Title: Re: update ACAD registry in current session
Post by: snownut2 on July 31, 2013, 07:53:42 AM
I know this is an old thread, I am looking to change model & paperspace background colors witht he same type of function, no luck...

Bruce
Title: Re: update ACAD registry in current session
Post by: Lee Mac on July 31, 2013, 08:36:37 AM
I know this is an old thread, I am looking to change model & paperspace background colors witht he same type of function, no luck...

Use the ActiveX graphicswinmodelbackgrndcolor & graphicswinlayoutbackgrndcolor properties derived from the Application.Preferences.Display object, e.g.:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:bcolor ( / disp )
  2.     (vla-put-graphicswinmodelbackgrndcolor  disp (LM:rgb->ole 100 0 0))
  3.     (vla-put-graphicswinlayoutbackgrndcolor disp (LM:rgb->ole 0 100 0))
  4.     (princ)
  5. )
  6.  
  7. ;; RGB -> OLE  -  Lee Mac
  8. ;; Args: r,g,b - [int] Red, Green, Blue values
  9.  
  10. (defun LM:RGB->OLE ( r g b )
  11.     (+  (fix r)
  12.         (lsh (fix g) 08)
  13.         (lsh (fix b) 16)
  14.     )
  15. )
  16.  

RGB->OLE function from here (http://bit.ly/13uXhO8).