Author Topic: Changing the Plot style table search path quickly  (Read 3537 times)

0 Members and 1 Guest are viewing this topic.

ELOQUINTET

  • Guest
Changing the Plot style table search path quickly
« on: January 29, 2007, 12:12:18 PM »
My boss asked me if there is a way to quickly changed the Plot style table search path. We get files from architects and sometimes they include their pen settings. Autocad only lets you path one folder for plot styles so either we have to put the files into our folder or change the path which we are willing to do but are looking for a quicker method. I was looking on Autodesk website and found this bit of code which I believe does this but I'm just not sure what else I need to add to this. Can somebody help me out

Public ACADPref As AcadPreferencesFiles
Set ACADPref = ThisDrawing.Application.Preferences.Files
ACADPref.PrinterStyleSheetPath = "X:\NewPlotStyles"

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Changing the Plot style table search path quickly
« Reply #1 on: January 29, 2007, 12:25:58 PM »
That will do it, you just need to wrap it in a function to use on each machine.  Do you need help writing that?
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Changing the Plot style table search path quickly
« Reply #2 on: January 29, 2007, 12:30:56 PM »
You could wrap it in the acad startup area, or call it selectively.  Here are both options

Code: [Select]
Public Sub ResetPlotStyle()
Dim ACADPref As AcadPreferencesFiles
Set ACADPref = ThisDrawing.Application.Preferences.Files
ACADPref.PrinterStyleSheetPath = "X:\NewPlotStyles"
End Sub

or
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

ELOQUINTET

  • Guest
Re: Changing the Plot style table search path quickly
« Reply #3 on: January 29, 2007, 12:32:06 PM »
CmdrDuh I got the switch working as shown below but I also want a button to switch back. The part I'm not sure about is everyone has their plot styles in documents and settings username autodesk plot styles. How do I define the path when it will be different on each computer i.e. username?

Public Sub CustomPLotStyles()

ThisDrawing.Application.Preferences.Files.PrinterStyleSheetPath = "C:\Custom Plot Styles"

End Sub

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Changing the Plot style table search path quickly
« Reply #4 on: January 29, 2007, 12:39:58 PM »
Well that is a little bit harder, but still doable.  What path do you show now?  Is it in Doc and Settings?  Also, if so, what is your login name. (I'm fishing for an answer I think I know how to code, I just want to be sure before I give it to you and screw things up)
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

ELOQUINTET

  • Guest
Re: Changing the Plot style table search path quickly
« Reply #5 on: January 29, 2007, 12:46:04 PM »
My path is:

C:\Documents and Settings\danielk\Application Data\Autodesk\AutoCAD 2006\R16.2\enu\Plot Styles

and others would vary by login name

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Changing the Plot style table search path quickly
« Reply #6 on: January 29, 2007, 12:50:30 PM »
This works on my machine.  That being said, while debugging, I CRASHED AUTOCAD 3 TIMES because the folder didn't exist, and it got upset about this.  That being said, be forewarned.  Anyway, here is a module that does what you want
Code: [Select]
Public Sub CustomPLotStyles()
      Dim strUser As String, path As String
      strUser = UCase(Environ("USERNAME"))
      path = "C:\Documents and Settings\" & strUser & "\Application Data\Autodesk\AutoCAD 2007\R17.0\enu\Plot Styles"
      If ThisDrawing.Application.Preferences.Files.PrinterStyleSheetPath = "C:\Custom Plot Styles" Then
            ThisDrawing.Application.Preferences.Files.PrinterStyleSheetPath = path
      Else
            ThisDrawing.Application.Preferences.Files.PrinterStyleSheetPath = "C:\Custom Plot Styles"
      End If
End Sub
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Changing the Plot style table search path quickly
« Reply #7 on: January 29, 2007, 12:52:10 PM »
Edit to match your path, and it should work for you.  As for putting it in a button, I hate the CUI, but it can be done.  I would write a quick LSP to call and make the switch.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Changing the Plot style table search path quickly
« Reply #8 on: January 29, 2007, 12:53:31 PM »
My path is:

C:\Documents and Settings\danielk\Application Data\Autodesk\AutoCAD 2006\R16.2\enu\Plot Styles

and others would vary by login name
This was what I was looking for, your machine uses the USERNAME environment variable also, so this is easy to do
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

ELOQUINTET

  • Guest
Re: Changing the Plot style table search path quickly
« Reply #9 on: January 29, 2007, 01:01:04 PM »
so the code you posted above should work or are you coming up with something else. I see the if and else in there and am wondering what is going on in there. You said your autocad crashed 3 times and I'm wondering are you crating the folder here so it doesn't? It would be nice to not have to create the folder yes but I'm more concerned with the crashing bit.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Changing the Plot style table search path quickly
« Reply #10 on: January 29, 2007, 01:06:18 PM »
The code above does what you want, after you reset it to 2006.  (I see your on 06 from your path)
The IF checks to see what your path is, and toggles it to the other path.  I cant be sure the crashing was folder related, however, it happened at the very moment I tried to check the function.  I dont have a "X" drive mapped, so in the first example, I think that was what crashed it.  Then, since that is written to the registry, every time I tried to open AutoCAD, it looked for the X drive, and crashed.  To fix this, I just edited my registry to reset to my C drive, and autocad opened right away.

As for not creating the folder, if you put the folder on a "KNOWN" mapped drive that everyone has, it wouldn't crash.  Also, a user shouldn't run the code if they aren't using the folder local or otherwise.
« Last Edit: January 29, 2007, 01:07:20 PM by CmdrDuh »
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Changing the Plot style table search path quickly
« Reply #11 on: January 29, 2007, 02:00:35 PM »
So did it work for you?
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

ELOQUINTET

  • Guest
Re: Changing the Plot style table search path quickly
« Reply #12 on: January 29, 2007, 04:32:01 PM »
Tes sorry yes it worked. I've been busy today so haven't had time to check in here frequently. Thanks works like a dream  :wink: