Author Topic: Need help  (Read 5876 times)

0 Members and 1 Guest are viewing this topic.

hudster

  • Gator
  • Posts: 2848
Need help
« on: February 26, 2004, 05:59:14 AM »
This is part of a small plot routing I've written for my company, so everyone in my company can plot any size drawing easily from a pull down menu. In total there are 27 different plot styles we use.

Code: [Select]
^C^Ctilemode;0;filedia;0;(load "delplot.lsp);(del_plot_config_list);.-psetupin;plot_configurations.dwg;architects_A1;-plot;no;;architects_a1;;no;no;yes;filedia;1;

Now how do I go about writing this to a lisp routine so I can shorten this command to
Code: [Select]
^C^C(load "Architect_A1.lsp);Architect_a1;

Also I have very very very limited skills in writing lisps, so this is my first big project.
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Need help
« Reply #1 on: February 26, 2004, 06:43:30 AM »
This _will_ need some testing.
Code: [Select]

(defun c:Architect_A1 (/ switch fn)
  (if (= (load "delplot.lsp" "file not found") "file not found")
(exit) ; exit program if load failed
(progn (del_plot_config_list) ; else run this command
  (setq switch 1)
  )
)
  (if switch
(if (setq fn (findfile "plot_configurations.dwg"))
 (command "psetupin" fn "architects_A1")
 )
)
  (if fn
(command "plot" "no" "" "architects_a1" "" "no" "no" "yes")
)
  (princ)
  )
TheSwamp.org  (serving the CAD community since 2003)

hudster

  • Gator
  • Posts: 2848
Need help
« Reply #2 on: February 26, 2004, 06:56:16 AM »
Brilliant that works.

Is there a way is can adapt it so i can set a value with my macro command like say, Architet_a0, so it loads that A0 page setup, or do i have to change the lsp file so i have 27 seperate files?
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Need help
« Reply #3 on: February 26, 2004, 07:25:47 AM »
This would be better suited using a dialog box to pick you plot type, maybe someone will show you how to do that. In the mean time try this.
Code: [Select]

(defun c:Architect_A1 (/ switch fn)
  (if (= (load "delplot.lsp" "file not found") "file not found")
(exit) ; exit program if load failed
(progn (del_plot_config_list) ; else run this command
  (setq switch 1)
  )
)
  (if switch
(if (setq fn (findfile "plot_configurations.dwg"))
 (command "psetupin" fn "architects_A1")
 )
)
  (if fn
(if (setq pname (getstring "\nPlot config name: "))
 (command "plot" "no" "" pname "" "no" "no" "yes")
 )
)
  (princ)
  )
TheSwamp.org  (serving the CAD community since 2003)

hudster

  • Gator
  • Posts: 2848
Need help
« Reply #4 on: February 26, 2004, 07:32:36 AM »
A dialogue box would be a good idea, but not ideal for this situation.

What i want to do is just click on the pull down A0, A3 etc drawing sizes for each of the plot styles and it plots out the other end.

I take it i can't specity a user variable in the macro command that the list can call on when it runs?
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Need help
« Reply #5 on: February 26, 2004, 07:50:29 AM »
Well I'm not familiar with using page setups, could you upload your "plot_configurations.dwg" for me to look at? You can put it in the lilly.pond
http://theswamp.org/lilly.pond/
TheSwamp.org  (serving the CAD community since 2003)

hudster

  • Gator
  • Posts: 2848
Need help
« Reply #6 on: February 26, 2004, 07:57:09 AM »
copy of it uploaded

Here
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Need help
« Reply #7 on: February 26, 2004, 08:27:17 AM »
Mark,

Could you create a dynamic pull down menu with each plot style as the choice?

Here are the styles.

Code: [Select]
 ;; ---------------------------------------------------------------------------
  ;; Function: Plot_Config_list
  ;; Purpose : Returns list of strings of all user page set ups.
  ;; Local   : curdwg:   current drawing object
  ;;           pslayout: paper space layout object
  ;; ---------------------------------------------------------------------------

  (defun Plot_config_list (/ curdwg pslayout names x)
    (vl-load-com)
    (setq
      curdwg   (vla-get-ActiveDocument (vlax-get-Acad-Object))
      DwgName  (vl-string-right-trim ".dwg" (vla-get-fullname curdwg))
      pslayout (vla-get-Layout (vla-get-PaperSpace curdwg))
    ) ;_ end of setq
     ; Call RefreshPlotDeviceInfo before GetPlotDeviceNames
    (vla-RefreshPlotDeviceInfo pslayout)
    (cons '"Current" ; add Current as a choice
 (reverse
   (vlax-for x (vla-get-Plotconfigurations curdwg)
     (setq names (cons (vla-get-name x) names))
   ) ;_ end of vlax-for
 ) ;_ end of reverse
    ) ;_ end of cons
  ) ; End Plot_config_list
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
Need help
« Reply #8 on: February 26, 2004, 09:05:43 AM »
I'm curious, why wouldn't a dialog box work as well as a pull down menu?

CAB
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.

hudster

  • Gator
  • Posts: 2848
Need help
« Reply #9 on: February 26, 2004, 10:29:37 AM »
It's not that it woudln't work, I have a few aged engineers in here who aren't to computer literate, and the less buttons they have to push the better.

At the moment they click on plot, and select the drawing convention and size, e.g. plot -> Architect -> A1 and that's it, it was hard enough having to explain that to them about 100 times, without having to go through it all again.
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Need help
« Reply #10 on: February 26, 2004, 05:50:54 PM »
Here is my attempt at a dcl version. :?
You will have to debug, but it worked for me.
I wish I could center the stuff in the dialog box but haven't lernt how. :)


Code: [Select]
(defun c:plot_with_config (/ switch fn)


;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
;;;                      Local Functions                            
;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
;;;

 
  ;; ---------------------------------------------------------------------------
  ;; Function: Plot_Config_list
  ;; Purpose : Returns list of strings of all user page set ups.
  ;; Local   : curdwg:   current drawing object
  ;;           pslayout: paper space layout object
  ;; ---------------------------------------------------------------------------
  (defun plot_config_list (/ curdwg pslayout names x)
    (vl-load-com)
    (setq
      curdwg   (vla-get-activedocument (vlax-get-acad-object))
      dwgname  (vl-string-right-trim ".dwg" (vla-get-fullname curdwg))
      pslayout (vla-get-layout (vla-get-paperspace curdwg))
    ) ;_ end of setq
    ;; Call RefreshPlotDeviceInfo before GetPlotDeviceNames
    (vla-refreshplotdeviceinfo pslayout)
    (cons '"Current" ; add Current as a choice
 (reverse
   (vlax-for x (vla-get-plotconfigurations curdwg)
     (setq names (cons (vla-get-name x) names))
   ) ;_ end of vlax-for
 ) ;_ end of reverse
    ) ;_ end of cons
  ) ; End Plot_config_list

 
  ;; ---------------------------------------------------------------------------
  ;; Function: init_tiles
  ;; Purpose : Sets up dialogue box tiles prior to invoking dialogue box.
  ;; ---------------------------------------------------------------------------
  (defun init_tiles (/ one)
    (action_tile "accept" "(call_ok)")
    (start_list "PlotConfigs")
    (foreach one config-list
      (add_list one)
    ) ;_ end of foreach
    (end_list)
    (set_tile "PlotConfigs" (itoa config#))
  ) ; End init_tiles

 
  ;; ---------------------------------------------------------------------------
  ;; Function: init_vars
  ;; Purpose : Sets up variables prior to invoking dialogue box.
  ;; ---------------------------------------------------------------------------
  (defun init_vars ()
    (if (not Plot-Config) ; default choice
      (setq Plot-Config "Current")
    )
    (setq config-list (Plot_config_list) ;get list of page setups
    ) ;_ end of setq
    (if (and Plot-config (member Plot-config PlotConfigs))
      (setq config#
    (- (length config-list)
(length (member Plot-Config config-list))
    ) ;_ end of -
      ) ;_ end of setq
      (setq config# 0)
    ) ;_ end of if
  ) ; end defun init_vars

 
  ;; ---------------------------------------------------------------------------
  ;; Function: call_ok
  ;; Purpose : Callback function for OK button.
  ;;           Ensures a style was picked
  ;; ---------------------------------------------------------------------------
  (defun call_ok ()
    (if (setq config# (atoi (get_tile "PlotConfigs")))
      (progn
(setq Plot-cfg  (nth config# config-list))
(done_dialog 1)
      ) ;_ end of progn
      (set_tile "error" "Pick a plot style")
    ) ;_ end of if
  ) ; End call_ok


;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
;;;================================================================
;;;                    Start of Routine                            
;;;================================================================
;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-

  (if (= (load "delplot.lsp" "file not found") "file not found")
    (exit) ; exit program if load failed
    (progn (del_plot_config_list) ; else run this command
    (setq switch 1)
    )
  )
  (if switch
    (if (setq fn (findfile "plot_configurations.dwg"))
      (command ".-PSETUPIN" fn "*") ; Load all plot styles
      ;;(command "psetupin" fn "architects_A1")
    )
  )
  (if fn
    (cond
      ((not (findfile (setq dclfile "Plot_w_cfgs.dcl")))
       (alert "Cannot find Plot_w_cfgs.dcl")
      )
      ((< (setq dcl# (load_dialog dclfile)) 0) ; Error
       (prompt (strcat "\nCannot load " dclfile "."))
      )
      ((not (new_dialog "PlotCfgs" dcl#)) ; Error
       (prompt (strcat "\nProblem with " dclfile "."))
      )
      (t ; No DCL problems: fire it up
       (init_vars)
       (init_tiles)
       (setq action (start_dialog))
       (unload_dialog dcl#)
       (if (= action 1) ; Ok to Plot
           ;; debug(Prompt (strcat "\nEnd of routine. " Plot-cfg))
           (command "plot" "no" "" Plot-cfg "" "no" "no" "yes")
       )
      )
    ) ; end cond stmt
    (princ)
  ) ; endif
) ;end defun

;;; //////
;;;  EOF  
;;; \\\\\\


DCL file

Code: [Select]
/// --------------------------------------------------------------------------
/// Turn off error checking
/// --------------------------------------------------------------------------
dcl_settings : default_dcl_settings { audit_level = 0; }


PlotCfgs : dialog {
  label = "Plot_W_Configs.lsp";width=55;
: text {label = "Choose a plot configuration to use while plottting.";
  width = 55;alignment=centered;}
:row{alignment=centered;fixed_width=true;fixed_height=true;
  : popup_list {
    key = "PlotConfigs";
    edit_width = 35;
    //fixed_width = true;
  }
  }
  spacer;
  spacer;
  ok_cancel;
  errtile;
}

/// --------------------------------------------------------------------------
/// End Plot_w_cfgs.dcl
/// --------------------------------------------------------------------------



Updated the DCL file code 02/26/04 11:03PM
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.

hudster

  • Gator
  • Posts: 2848
Need help
« Reply #11 on: February 27, 2004, 03:53:30 AM »
great piece of work.  Something I will keep on my USB drive to take wherever I roam.
 :lol:  :dood:
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Need help
« Reply #12 on: February 27, 2004, 08:37:05 AM »
Your welcome.

CAB
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.

hudster

  • Gator
  • Posts: 2848
Need help
« Reply #13 on: February 27, 2004, 09:44:57 AM »
I sent this to a mate using AutoCAD 2002 and he says it doesn't work.

It doesn't return an error or anything else, it just returns to the command line.

Any ideas?

***EDIT***

It does work, he didn't put the plot-configurations.dwg into his support path. :roll:
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Need help
« Reply #14 on: February 27, 2004, 06:48:08 PM »
Change to this bit of code and the routine will alert you  before it quits.

Code: [Select]
 (if switch
    (if (setq fn (findfile "plot_configurations.dwg"))
      (command ".-PSETUPIN" fn "*") ; Load all plot styles
      ;;(command "psetupin" fn "architects_A1")
      (alert "File not found \"plot_configurations.dwg\"")
    )
  )
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.