1 Attachment(s)
Setting Plot Style Table in Lisp
Afternoon -
I need to build into my lisp a way to set the appropriate plot style table and make it active.
I've searched through the forums here and no one really gave an answer, so please do not post links to other posts!
I've tried the following list with nothing working.....
(vla-RefreshPlotDeviceInfo objLayout)
(vla-Put-StyleSheet objLayout "MyStyle.stb")
ThisDrawing.ActiveLayout.StyleSheet = "MyStyle.stb"
(vl-load-com)
(vla-put-PrinterStyleSheetPath (vla-get-Files (vla-get-Preferences (vlax-get-acad-object))) "MyStyle.stb")
I've attached a pic of the tool itself from the options dialog box but I need a way of doing this from the command line for the lisp routine.
Any suggestions?
RE: Setting Plot Style Table in Lisp
So are you trying to set "default" STB file (for use with R14 and previous drawings - as your photo shows), or are you trying to set the current STB file for a particular layout?
IF the former...
Code:
(setq o (vla-get-Output (vla-get-Preferences (vlax-get-acad-object))))
(vla-put-PlotPolicy o 0)
(vla-put-DefaultPlotStyleTable o "monochrome.stb")
IF the latter.....
See this post for an example of setting the "stylesheet" for multiple layouts in multiple drawings.
If you just want to operate on the current layout, then here is a lisp example:
Code:
(vla-put-StyleSheet
(vla-get-ActiveLayout
(vla-get-ActiveDocument (vlax-get-acad-object))
)
"monochrome.stb"
)
RE: Setting Plot Style Table in Lisp
I am getting the following error on both routines.....
"Automation Error. Invalid input"
What's that?
RE: Setting Plot Style Table in Lisp
Nope but I just added it in and I got the same error for the second routine and basically the same error for the first routine except it says "invalid argument" instead of "input".
Any Ideas?
RE: Setting Plot Style Table in Lisp
Quote:
Originally Posted by fletch97
Nope but I just added it in and I got the same error for the second routine and basically the same error for the first routine except it says "invalid argument" instead of "input".
Any Ideas?
If you did a staight copy and paste of RK's code, does monochrome.stb exist?
Or if you changed it, can Autocad find the one you are trying to set?
Just a guess, though.
HTH
RE: Setting Plot Style Table in Lisp
I changed the name to ours, which is there.....not sure why RK's routine won't work?
Command: (setq o (vla-get-Output (vla-get-Preferences (vlax-get-acad-object))))
#<VLA-OBJECT IAcadPreferencesOutput2 0b1d7b18>
Command: (vla-put-PlotPolicy o 0)
nil
Command: (vla-put-DefaultPlotStyleTable o "hmc-std.stb")
*Cancel*
Command:
Command:
Command: Automation Error. Invalid Argument
RE: Setting Plot Style Table in Lisp
Quote:
Originally Posted by fletch97
I changed the name to ours, which is there.....not sure why RK's routine won't work?
Command: (setq o (vla-get-Output (vla-get-Preferences (vlax-get-acad-object))))
#<VLA-OBJECT IAcadPreferencesOutput2 0b1d7b18>
Command: (vla-put-PlotPolicy o 0)
nil
Command: (vla-put-DefaultPlotStyleTable o "hmc-std.stb")
*Cancel*
Command:
Command:
Command: Automation Error. Invalid Argument
You are using R14?
If so, I don't have it to test it; maybe someone else will chime in.
I did test the second one in 2006, and it returned a similar error message when the file wasn't found, but worked correctly when it was. This would lead me to believe that maybe there is something amiss with the file name specified.
RE: Setting Plot Style Table in Lisp
I am running ADT 2006
The file is there because I can see it as an option in the dialog box for the options menu as well as in the layer manager. So how can I get this to set it from the command line?
Take a look at my first attachment on my first post.....you can see my stb file there.
RE: Setting Plot Style Table in Lisp
Quote:
Originally Posted by fletch97
I am running ADT 2006
The file is there because I can see it as an option in the dialog box for the options menu as well as in the layer manager. So how can I get this to set it from the command line?
Take a look at my first attachment on my first post.....you can see my stb file there.
OK.
I think you need to use RK's second example instead of the first. I couldn't make the first one work in 2006, either, and It may be because of a change between versions. Maybe RK will verify later.
Have you tried the second example? Here is what I did:
I wrapped the code in a defun called test and loaded it.
Code:
(defun c:test ()
(vla-put-StyleSheet
(vla-get-ActiveLayout
(vla-get-ActiveDocument (vlax-get-acad-object))
)
"Black.ctb" ;;<--we still use CTB, yours would be hmc-std.stb
)
)
Then I went to a layout and changed the plot style to something else, then executed test at the command line. Then I went back into the layout manager to verify that it changed it to Black.ctb.
It works here. (2006) Maybe someone that uses STBs will verify it for STBs.