James,
I can get the lisp to load, but can't seem to get it to run. Also can I repeat the code if I have multiple plot styles I want to replace (i.e. style_01 with black, style_02 with Screened50, etc...)
Your help is greatly appreciated!
-Scott
Remove the "?" in VLIDE, there was a mystery question mark once i pasted into VLIDE.
It does not show here.
- I modified it for my needs.
(defun NormaltoFS (/)
(setq layers (vla-get-layers
(vla-get-ActiveDocument (vlax-get-acad-object))
)
)
(vlax-for l layers
(progn
(if (= (vlax-get-property l 'PlotStyleName) "Normal")
(vlax-put-property l 'PlotStyleName "Full Saturation")
)
)
)
)
Not sure if you guys are still alive but...
What if I wanted to exclude a few layers from this routine:
(defun c:WPS (/)
(setq layers (vla-get-layers
(vla-get-ActiveDocument (vlax-get-acad-object))
)
)
(vlax-for l layers
(progn
(if (= (vlax-get-property l 'PlotStyleName) "Normal")
(vlax-put-property l 'PlotStyleName "Medium")
)
)
)
)
@Anonymous wrote:Not sure if you guys are still alive but...
What if I wanted to exclude a few layers from this routine:
(defun c:WPS (/) (setq layers (vla-get-layers (vla-get-ActiveDocument (vlax-get-acad-object)) ) ) (vlax-for l layers (progn (if (and (= (vlax-get-property l 'PlotStyleName) "Normal") (not (member (strcase (vla-get-name l)) '("EXCLUDEDLAYER1" "EXCLUDEDLAYER2")))) (vlax-put-property l 'PlotStyleName "Medium") ) ) ) )
HTH
I've tried changing "Normal" with "None" and "Medium" with my plotstyle name, but it doesn't work...
I would like to make a routine that defines a specific plot style in the model if the current plotstyle is "None"
What a need to modify?
TIA
(defun c:WPS (/) (setq layers (vla-get-layers (vla-get-ActiveDocument (vlax-get-acad-object)) ) ) (vlax-for l layers (progn (if (and (= (vlax-get-property l 'PlotStyleName) "None") (not (member (strcase (vla-get-name l)) '("EXCLUDEDLAYER1" "EXCLUDEDLAYER2")))) (vlax-put-property l 'PlotStyleName "Ringo 1-50") ) ) ) )
@gustavobernardi wrote:
I've tried changing "Normal" with "None" and "Medium" with my plotstyle name, but it doesn't work...
I would like to make a routine that defines a specific plot style in the model if the current plotstyle is "None"
What a need to modify?
If the plot stylename "None" "Medium" and "Ringo 1-50" exists, there is no reason why the snippet would not work.
Try setting the current plot stylename to "Ringo 1-50" before running the code, easiest way is with.
..
(command "-plotsyle" "_Current" "Ringo 1-50")
..
HTH
Humm, interesting... Now I see. My problem is that I am trying with CTB ant this functions is for STB.
Is there any way to do that with CTB?
If you only want to set the CTB for the Model (or any other) layout, you need to use the Layout object.
The code below will give you the CTB for the current layout in the drawing.
If the value is an empty string "" then it is set to 'None'.
(setq CurDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
(vla-get-StyleSheet (vla-get-ActiveLayout CurDoc))
Use this to directly get the value for the StyleSheet property for any layout without worrying if it's the current one or not
(vla-get-StyleSheet (vla-item (vla-get-Layouts CurDoc) "NameOfLayout")) ;;; example (vla-get-StyleSheet (vla-item (vla-get-Layouts CurDoc) "Model"))
To set the CTB use 'put' instead of 'set' like the code below.
Make sure the CTB name provided exists otherwise you will get an error.
(vla-put-StyleSheet (vla-item (vla-get-Layouts CurDoc) "Model") "acad.ctb") ;;; or even better with error trapping (vl-catch-all-apply 'vla-put-StyleSheet (list (vla-item (vla-get-Layouts CurDoc) "Model") "acad.ctb"))
To get a list of available plot styles (CTB & STB) use the GetPlotStyleTableNames on any of the layout objects.
This can be used to check if the CTB exists prior to trying to set the StyleSheet property.
(vlax-safearray->list (vlax-variant-value (vla-GetPlotStyleTableNames (vla-get-ActiveLayout CurDoc))))
Fantastic. Here is the final Code:
(defun c:set-ps()
(vl-load-com)
(setq CurDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
(setq installed_ps(vlax-safearray->list (vlax-variant-value (vla-GetPlotStyleTableNames (vla-get-ActiveLayout CurDoc)))));;get the plotstyles
(if (= (vl-position "Ringo 1-50.ctb" installed_ps)nil)(c:penasringo));;verify if the plotstyle exist, if not - install
(setq cur_ps(vla-get-StyleSheet (vla-item (vla-get-Layouts CurDoc) "Model")));;get the actual plotstyle
(if (= cur_ps "")(vl-catch-all-apply 'vla-put-StyleSheet (list (vla-item (vla-get-Layouts CurDoc) "Model") "Ringo 1-50.ctb")));;if the user don't choose put the plotstyle
)
Thank you!