TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: curmudgeon on January 29, 2011, 11:38:33 AM
-
where is the ctb file for a given plot tab stored?
I forget to check my plot styles, and I plot pages that are wrong only because of pen weights.
this is a personnel problem, and I will fire me later when I have the time.
but it occurs to me that I should be able to reset ALL these ctb-tab associations in lisp,
and then maybe instead of beating myself up, I could take me out for a beer.
assistance would be really appreciated.
but last resort, after failing to find previous discussions ( and easy answers )
I guess I can always take the autocad plot dialog box apart, and see what it does when a ctb file gets changed.
it's just that those dialog boxes will likely be nested 12 levels deep, or across as the case may be.
thanks.
-
Maybe this?
(setq RetVal
(vlax-safearray->list
(vlax-variant-value
(vla-getplotstyletablenames
(vla-get-activelayout
(vla-get-activedocument
(vlax-get-acad-object))))))
)
-
Oh that is just available plot styles. Let me look some more.
-
This?
(vla-get-StyleSheet
(vla-get-ActiveLayout
(vla-get-ActiveDocument
(vlax-get-acad-object)
)
)
)
-
Ah, that's it.
He wants to loop through all layouts and set the plot style. (I think 8-))
-
He wants to loop through all layouts and set the plot style. (I think 8-))
Was thinking the same :-)
This might also be useful:
(vla-get-PrinterStyleSheetPath
(vla-get-files
(vla-get-Preferences
(vlax-get-acad-object)
)
)
)
To be used in conjunction with vl-directory-files ...
-
yes, loop through, reset all of them in one file to some standard.
I thought as much. I need to study the vl commands you pointed me to.
thank you very much.
roy
-
Couldn't resist having a bit of fun with this one:
(defun c:SetStyleSheet ( / ss err ) (vl-load-com)
;; © Lee Mac 2011
(if
(and
(setq ss
(vl-directory-files
(vla-get-PrinterStyleSheetPath
(vla-get-files
(vla-get-Preferences (vlax-get-acad-object))
)
)
"*.ctb" 1
)
)
(setq ss (car (LM:ListBox "Select CTB File" ss nil)))
)
(vlax-for la (vla-get-Layouts (vla-get-ActiveDocument (vlax-get-acad-object)))
(if
(vl-catch-all-error-p
(setq err
(vl-catch-all-apply 'vla-put-StyleSheet (list la ss))
)
)
(princ
(strcat
"\n** Error: Layout: " (vla-get-name la)
"\tReason: " (vl-catch-all-error-message err) " **"
)
)
)
)
)
(princ)
)
;;-----------------------=={ List Box }==---------------------;;
;; ;;
;; Displays a List Box allowing the user to make a selection ;;
;; from the supplied data. ;;
;;------------------------------------------------------------;;
;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;;
;;------------------------------------------------------------;;
;; Arguments: ;;
;; title - List Box Dialog title ;;
;; data - List of Strings to display in the List Box ;;
;; multiple - Boolean flag to determine whether the user ;;
;; may select multiple items (T=Allow Multiple) ;;
;;------------------------------------------------------------;;
;; Returns: List of selected items, else nil. ;;
;;------------------------------------------------------------;;
(defun LM:ListBox ( title data multiple / file tmp dch return )
;; © Lee Mac 2011
(cond
(
(not
(and (setq file (open (setq tmp (vl-filename-mktemp nil nil ".dcl")) "w"))
(write-line
(strcat "listbox : dialog { label = \"" title
"\"; spacer; : list_box { key = \"list\"; multiple_select = "
(if multiple "true" "false") "; } spacer; ok_cancel;}"
)
file
)
(not (close file)) (< 0 (setq dch (load_dialog tmp))) (new_dialog "listbox" dch)
)
)
)
(
t
(start_list "list")
(mapcar 'add_list data) (end_list)
(setq return (set_tile "list" "0"))
(action_tile "list" "(setq return $value)")
(setq return
(if (= 1 (start_dialog))
(mapcar '(lambda ( x ) (nth x data)) (read (strcat "(" return ")")))
)
)
)
)
(if (< 0 dch) (unload_dialog dch))
(if (setq tmp (findfile tmp)) (vl-file-delete tmp))
return
)
Lee
-
Nice start Lee.
You need to detect the drawing style type (ctb or stb) before you offer the pick list.
I use stb 8-)
-
Nice start Lee.
You need to detect the drawing style type (ctb or stb) before you offer the pick list.
I use stb 8-)
Thanks Alan -
Good call on the Style type - am I right in thinking it is the PSTYLEMODE Sys Var I should be looking at?
-
This is what I was thinking:
(defun c:SetStyleSheet ( / ss err ) (vl-load-com)
;; © Lee Mac 2011
(if
(and
(setq ss
(vl-directory-files
(vla-get-PrinterStyleSheetPath
(vla-get-files
(vla-get-Preferences (vlax-get-acad-object))
)
)
(if (zerop (getvar 'PSTYLEMODE)) "*.stb" "*.ctb") 1
)
)
(setq ss (car (LM:ListBox "Select Stylesheet" ss nil)))
)
(vlax-for la (vla-get-Layouts (vla-get-ActiveDocument (vlax-get-acad-object)))
(if
(vl-catch-all-error-p
(setq err
(vl-catch-all-apply 'vla-put-StyleSheet (list la ss))
)
)
(princ
(strcat
"\n** Error: Layout: " (vla-get-name la)
"\tReason: " (vl-catch-all-error-message err) " **"
)
)
(princ (strcat "\n--> " ss " applied to layout " (vla-get-name la)))
)
)
)
(princ)
)
;;-----------------------=={ List Box }==---------------------;;
;; ;;
;; Displays a List Box allowing the user to make a selection ;;
;; from the supplied data. ;;
;;------------------------------------------------------------;;
;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;;
;;------------------------------------------------------------;;
;; Arguments: ;;
;; title - List Box Dialog title ;;
;; data - List of Strings to display in the List Box ;;
;; multiple - Boolean flag to determine whether the user ;;
;; may select multiple items (T=Allow Multiple) ;;
;;------------------------------------------------------------;;
;; Returns: List of selected items, else nil. ;;
;;------------------------------------------------------------;;
(defun LM:ListBox ( title data multiple / file tmp dch return )
;; © Lee Mac 2011
(cond
(
(not
(and (setq file (open (setq tmp (vl-filename-mktemp nil nil ".dcl")) "w"))
(write-line
(strcat "listbox : dialog { label = \"" title
"\"; spacer; : list_box { key = \"list\"; multiple_select = "
(if multiple "true" "false") "; } spacer; ok_cancel;}"
)
file
)
(not (close file)) (< 0 (setq dch (load_dialog tmp))) (new_dialog "listbox" dch)
)
)
)
(
t
(start_list "list")
(mapcar 'add_list data) (end_list)
(setq return (set_tile "list" "0"))
(action_tile "list" "(setq return $value)")
(setq return
(if (= 1 (start_dialog))
(mapcar '(lambda ( x ) (nth x data)) (read (strcat "(" return ")")))
)
)
)
)
(if (< 0 dch) (unload_dialog dch))
(if (setq tmp (findfile tmp)) (vl-file-delete tmp))
return
)
But I'm not sure if the assignment of an stb to a layout is the same as that of a ctb... :|
-
That worked for me. :-)
I use this because I want to control the entire page set up.
http://www.theswamp.org/index.php?topic=8855.0
-
That worked for me. :-)
Excellent :-)
I use this because I want to control the entire page set up.
http://www.theswamp.org/index.php?topic=8855.0
Nice work Alan! :-)