Jump to content

Greying out user options in Plot Dialogue Box


NBC

Recommended Posts

Is it possible to 'grey out' i.e. lockdown all options within the Plot Dialogue Box except for the Page Setup Name, and the Number of Copies ?

 

My aim is to lockdown all options except 2: user can change the Page Setup Name, and number of copies only.

 

Is this possible, and if so, any ideas how to go about it ?

plot_dialogue_box.PNG

Edited by NBC
oops ! forgot to add picture
Link to comment
Share on other sites

You have quite an obsession with Page Setups NBC :P

 

Did the reactor not do the job to prevent people not using page setups?

 

I'm with Dave here though, create your own dialog (or ask someone to do it for you :) ) and perhaps redefine the plot command to your program.

Link to comment
Share on other sites

Years ago, I created a plotting menu and placed it on everyones machine. The button call the plotting lisp routines that I have made to control the output (pen settings, plotter configurations, papersize, etc...). Since then, everyone in the company just clicks the button they want, and the print is done. No dialog boxes to step through just to get a quick plot. Now, many of them have forgotten how to plot without them, and even forgot the command plot. :lol:

 

Just adding a thought to the discussion...

 

PlotMenu.JPG

Link to comment
Share on other sites

sorry Lee, I'm quite OCD about getting people to use AutoCAD correctly, so when they don't via my persuasion, I have to come up with other ways to make them.

The reactor opened their eyes to PageSetups yes, but the users are just creating any old pagesetup and giving it a name, and then modifying all the settings in the plot dialogue box.

If I said, it is annoying me, it would be an understatement.

 

I would love to be able to create my own dialogue box, but alas my knowledge of how to do so, is this >--

Link to comment
Share on other sites

sorry Lee, I'm quite OCD about getting people to use AutoCAD correctly, so when they don't via my persuasion, I have to come up with other ways to make them.

The reactor opened their eyes to PageSetups yes, but the users are just creating any old pagesetup and giving it a name, and then modifying all the settings in the plot dialogue box.

If I said, it is annoying me, it would be an understatement.

 

I would love to be able to create my own dialogue box, but alas my knowledge of how to do so, is this >--

 

The way I envisage it would be to create a dialog box utilising a drop-down list (popup_list) listing all the available page setups, and an edit box for the number of copies. Then just Plot and Cancel buttons - very simplistic, and offers no room to budge.

 

You could then perhaps redefine the plot command to use your program - of course, users could revert to the old plot command using (.plot), but they may not know this...

 

Or, there is Chluc's option...

Link to comment
Share on other sites

Ok, I've tried to create a dialogue box, but my knowledge of dcl and lsp is extremely limited.

The coding I've done so far is attached.

 

One thing I am struggling on is populating the popup_list from the available PageSetupNames. Bear in mind, that whilst I would like to choose from a specific list of pagesetups, I am not naive in that I know that users may create their own.

 

Am I heading in the right direction with this?

Any help is greatly appreciated.

plotbox.dcl

plotbox.lsp

Link to comment
Share on other sites

Hope you don't mind. here's something to run with

 

(defun C:test (/ *error* dcl getpagesetupname)
 
;;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤;;
    
 (defun *error* (msg)
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
        (princ (strcat "\n** Error: " msg " **"))
   )
   (princ)
 )

;;----------------------------------------------------------------;;

 ;;;--- Grab list from available PageSetups
 ;; Thanks to JTBWorld, mod by Lee Mac
 (defun getPageSetupName ( layout / laydict psn )
   (setq pages (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_LAYOUT"))))
   (if (and (setq laydict (dictsearch pages layout))
            (setq psn (member '(100 . "AcDbPlotSettings") laydict))
            (= (caadr psn) 1))
     (cdadr psn)
   )
 )

;;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤;;
 
 ;;(start_list "pagesetups") remove ;; to start list
 ;;(mapcar 'add_list pages) remove ;; to start list
 ;;(end_list) remove ;; to start list

;;----------------------------------------------------------------;;
 (setq dcl (load_dialog "plotbox.dcl"))
 (if (not (new_dialog "main" dcl))
   (progn
     (prompt "\nDCL file cannot be found! *Exit*")
     (exit)
   )
 )
;;----------------------------------------------------------------;;
 (action_tile "accept" "(done_dialog)")
 (action_tile "cancel" "(done_dialog)")
;;----------------------------------------------------------------;;
 (start_dialog)
 (unload_dialog dcl)
 
;;----------------------------------------------------------------;;
 (princ)
)

 

dcl_settings : default_dcl_settings { audit_level = 3; }
main
: dialog {
label = "Customised Plotting" ;
 : row {
   : boxed_column {
   label = "PageSetupName";
     : popup_list {
     label = "Choose a PageSetup";
     key = "pagesetups";
     value = "0" ;
     }
   }
 }
 : boxed_column {
   : edit_box {
   label = "No. of Copies to plot" ;
   key = "values" ;
   edit_width = 6 ;
   }
 }
 : row {
   : paragraph {
     : text_part {
     label = "Designed and Created";
     }
     : text_part {
     label = "by Jon A";
     }
   }
   : row {
   ok_cancel;
   }
 }
}

Link to comment
Share on other sites

sorry Lee, I'm quite OCD about getting people to use AutoCAD correctly, so when they don't via my persuasion, I have to come up with other ways to make them.

 

This is a management problem, not a technology problem...

 

Our design leader says "this is the way to do it, and if you can't or won't follow the standards, we'll find someone who can"

Should be pretty easy to get people to follow along in today's economy.... :wink:

Link to comment
Share on other sites

This is a management problem, not a technology problem...

 

I couldn't agree more; but I have tried all options, apart from technological ones.

I see things like the above as big things, my bosses do not, any other ideas as how to approach it ?

Link to comment
Share on other sites

This is a management problem, not a technology problem...

 

Our design leader says "this is the way to do it, and if you can't or won't follow the standards, we'll find someone who can"

Should be pretty easy to get people to follow along in today's economy.... :wink:

 

Bravo!

 

Luckily, the owners of my company understand the need for standards, and were very persuasive of many of the changes I have implemented over the years. We did have a few renegades that felt they conld do as they pleased, because "they new a better way" or had a "better layer name" they wanted to use.

 

I couldn't agree more; but I have tried all options, apart from technological ones.

I see things like the above as big things, my bosses do not, any other ideas as how to approach it ?

 

The trick with writing code, to better an organization, is to know the variables you are dealing with, and that they remain constant. Perhaps pointing this out to the head weenies, along with proposed plans to either save the company money, increase productivity, generate a better product, etc... make help your point(s) gain enforcement.

 

In other words, force the hand that holds the mouse! :twisted: (Look out, here comes the CAD police!)

Link to comment
Share on other sites

Hey NBC,

 

Had a bit of time, so thought I'd write it for you:

 

(command "_.undefine" "plot")

(defun c:Plot ( / *error* Dcl_write Popup C DC DCFNAME DOC FL L MSG OFILE PL PTR SAVEPATH TMP )
 (vl-load-com)
 ;; © Lee Mac 2010

 (defun *error* ( msg )
   
   (and ofile (close ofile))
   (and dc (unload_dialog dc))
   
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ)
 )
 
 (defun dcl_write ( fname / ofile )
   ;; © Lee Mac 2010
   
   (if (not (findfile fname))

     (if (setq ofile (open fname "w"))
       (progn
         (foreach str

           '("spc : spacer { width = 0.1; height = 0.1; fixed_width = true; fixed_height = true; }"

             "myplot : dialog { label = \"Plot\";"
             "  spacer;"
             "  : row { spacer;"
             "    : column { spc; : text { label = \"Page Setup:\"; } spc; }"
             "    : popup_list { width = 30; fixed_width = true; key = \"config\"; } spacer;"
             "    : edit_box   { edit_width = 5; fixed_width = true; key = \"copy\"; label = \"Copies:\"; }"
             "    spacer;"
             "  }"
             "  spacer; ok_cancel;"
             "}")

           (write-line str ofile)
         )
         (setq ofile (close ofile))
         t
       )
     )
     t
   )
 )

 (defun Popup ( title flags msg / WSHShell result )
   ;; © Lee Mac 2010
   
   (setq WSHShell (vlax-create-object "WScript.Shell"))
   (setq result   (vlax-invoke WSHShell 'Popup msg 0 title flags))
   (vlax-release-object WSHShell)

   result
 )

 (setq SavePath

   (cond
     
     ( (setq tmp (getvar 'ROAMABLEROOTPREFIX))

       (or (eq "\\" (substr tmp (strlen tmp)))
           (setq tmp (strcat tmp "\\")))

       (strcat tmp "Support\\")
     )
     ( (setq tmp (findfile "ACAD.pat"))

       (setq tmp (vl-filename-directory tmp))

       (or (eq "\\" (substr tmp (strlen tmp)))
           (setq tmp (strcat tmp "\\")))

       tmp
     )
     (t
       (popup "Warning" 16 "DCL Save Path not Valid")

       (exit)
     )
   )
 )

 (setq dcfname (strcat SavePath "LMAC_MyPlot.dcl"))

 (cond
   (
     (progn
       (vlax-for p
         (vla-get-PlotConfigurations
           (setq doc
             (vla-get-ActiveDocument
               (vlax-get-acad-object)
             )
           )
         )
         (setq l (cons (vla-get-name p) l))
       )
       (not (setq l (reverse l)))
     )

     (princ "\n** No Page Setups Found in Drawing **")
     (popup "Information" 64 "No Page Setups Found in Drawing")
   )     
   (
     (not (dcl_write dcfname))

     (princ "\n** DCL File Could not be Written **")
     (popup "Warning" 16 "DCL File Could not be Written")
   )
   (
     (<= (setq dc (load_dialog dcfname)) 0)

     (princ "\n** DCL File Could not be Found **")
     (popup "Warning" 16 "DCL File Could not be Found")
   )
   (
     (not (new_dialog "myplot" dc))

     (princ "\n** Plot Dialog Could not be Loaded **")
     (popup "Warning" 16 "Plot Dialog Could not be Loaded")
   )
   (t
     (start_list "config")
     (mapcar (function add_list) (setq l (acad_strlsort l)))
     (end_list)

     (setq ptr (set_tile "config" "0") c (atoi (set_tile "copy" "1")))

     (action_tile "config" "(setq ptr $value)")

     (action_tile "copy"
       (vl-prin1-to-string
         (quote
           (progn
             (setq c
               (cond
                 (
                   (or (not (eq 'INT (type (read $value))))
                       (< (atoi $value) 1))                      

                   (alert "Number of Copies must be a Positive Integer")
                   (mode_tile "copy" 2)

                   c
                 )
                 ( (atoi $value) )
               )
             )
           )
         )
       )
     )

     (if (= 1 (progn (setq fl (start_dialog) dc (unload_dialog dc)) fl))

       (if
         (vl-catch-all-error-p
           (setq msg
             (vl-catch-all-apply 'LM:PutPageSetup
               (list doc (getvar 'CTAB) (nth (atoi ptr) l))
             )
           )
         )
         (princ (strcat "\n** Error Applying Pagesetup -> " (vl-catch-all-error-message msg) " **"))

         (if
           (progn (vla-refreshplotdeviceinfo (LM:Itemp (vla-get-layouts doc) (getvar 'CTAB)))
             (eq :vlax-false
               (vla-plottodevice
                 (progn
                   (vla-put-NumberofCopies (setq pl (vla-get-plot doc)) c) pl
                 )
               )
             )
           )
           (princ "\n** Error Plotting Drawing **")
         )
       )
       (princ "\n*Cancel*")
     )
   )
 )

 (princ)
)

;;-------------------=={ Put PageSetup }==--------------------;;
;;                                                            ;;
;;  Assigns a specified PageSetup to a specified layout       ;;
;;------------------------------------------------------------;;
;;  Author: Lee McDonnell, 2010                               ;;
;;                                                            ;;
;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;
;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;
;;------------------------------------------------------------;;
;;  Arguments:                                                ;;
;;  doc    - a VLA Document Object                            ;;
;;  layout - the name of the layout to assign the setup       ;;
;;  config - the name of the plot config to assign            ;;
;;------------------------------------------------------------;;

(defun LM:PutPageSetup ( doc layout config )
 ;; © Lee Mac 2010
 (and
   (setq layout (LM:itemp (vla-get-layouts doc) layout))
   (setq config (LM:itemp (vla-get-plotconfigurations doc) config))
   (not (vla-copyfrom layout config))
 )
)

;;-----------------------=={ Itemp }==------------------------;;
;;                                                            ;;
;;  Retrieves the item with index 'item' if present in the    ;;
;;  specified collection, else nil                            ;;
;;------------------------------------------------------------;;
;;  Author: Lee McDonnell, 2010                               ;;
;;                                                            ;;
;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;
;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;
;;------------------------------------------------------------;;
;;  Arguments:                                                ;;
;;  coll - the VLA Collection Object                          ;;
;;  item - the index of the item to be retrieved              ;;
;;------------------------------------------------------------;;
;;  Returns:  the VLA Object at the specified index, else nil ;;
;;------------------------------------------------------------;;

(defun LM:Itemp ( coll item )
 ;; © Lee Mac 2010
 (if
   (not
     (vl-catch-all-error-p
       (setq item
         (vl-catch-all-apply
           (function vla-item) (list coll item)
         )
       )
     )
   )
   item
 )
)

Will undefine the existing plot command and act in its place. To get the normal plot command back, just use the redefine command. :)

 

Lee

Edited by Lee Mac
Link to comment
Share on other sites

....To get the normal plot command back, just use the redefine command.

 

Lee

 

I suspect most users will just type in .plot to get the built in plot command back.

Link to comment
Share on other sites

I suspect most users will just type in .plot to get the built in plot command back.

 

... You could then perhaps redefine the plot command to use your program - of course, users could revert to the old plot command using (.plot), but they may not know this...

 

True ^^ :)

Link to comment
Share on other sites

That's great Lee, many thanks for your time and effort.

My next question would be, how do I integrate my previous PageSetup request (the plotreactor one) with the one in this thread?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...