Author Topic: where is the ctb file for a given plot tab stored?  (Read 3520 times)

0 Members and 1 Guest are viewing this topic.

curmudgeon

  • Newt
  • Posts: 194
where is the ctb file for a given plot tab stored?
« 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.
Never express yourself more clearly than you are able to think.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: where is the ctb file for a given plot tab stored?
« Reply #1 on: January 29, 2011, 11:46:48 AM »
Maybe this?

Code: [Select]
  (setq RetVal
         (vlax-safearray->list
           (vlax-variant-value
             (vla-getplotstyletablenames
               (vla-get-activelayout
                 (vla-get-activedocument
                   (vlax-get-acad-object))))))
  )
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: where is the ctb file for a given plot tab stored?
« Reply #2 on: January 29, 2011, 11:56:19 AM »
Oh that is just available plot styles. Let me look some more.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: where is the ctb file for a given plot tab stored?
« Reply #3 on: January 29, 2011, 11:59:28 AM »
This?

Code: [Select]
(vla-get-StyleSheet
  (vla-get-ActiveLayout
    (vla-get-ActiveDocument
      (vlax-get-acad-object)
    )
  )
)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: where is the ctb file for a given plot tab stored?
« Reply #4 on: January 29, 2011, 12:03:46 PM »
Ah, that's it.
 He wants to loop through all layouts and set the plot style. (I think  8-))
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: where is the ctb file for a given plot tab stored?
« Reply #5 on: January 29, 2011, 12:05:18 PM »
He wants to loop through all layouts and set the plot style. (I think  8-))

Was thinking the same  :-)

This might also be useful:

Code: [Select]
(vla-get-PrinterStyleSheetPath
  (vla-get-files
    (vla-get-Preferences
      (vlax-get-acad-object)
    )
  )
)

To be used in conjunction with vl-directory-files ...

curmudgeon

  • Newt
  • Posts: 194
Re: where is the ctb file for a given plot tab stored?
« Reply #6 on: January 29, 2011, 12:08:45 PM »
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
Never express yourself more clearly than you are able to think.

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: where is the ctb file for a given plot tab stored?
« Reply #7 on: January 29, 2011, 12:41:18 PM »
Couldn't resist having a bit of fun with this one:

Code: [Select]
(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

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: where is the ctb file for a given plot tab stored?
« Reply #8 on: January 29, 2011, 12:55:52 PM »
Nice start Lee.
You need to detect the drawing style type (ctb or stb) before you offer the pick list.

I use stb  8-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: where is the ctb file for a given plot tab stored?
« Reply #9 on: January 29, 2011, 12:57:36 PM »
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?

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: where is the ctb file for a given plot tab stored?
« Reply #10 on: January 29, 2011, 01:12:23 PM »
This is what I was thinking:

Code: [Select]
(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...  :|

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: where is the ctb file for a given plot tab stored?
« Reply #11 on: January 29, 2011, 01:52:10 PM »
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
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: where is the ctb file for a given plot tab stored?
« Reply #12 on: January 29, 2011, 02:21:22 PM »
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!  :-)