TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Luke on January 11, 2008, 03:18:08 PM
-
OK So I'm not asking how to do it... YET :wink:
But do you think it is possibe to write a , lisp, script, VBA whatever... that could recognize all of MY title blocks in a drawing. 8-1/2" x 11" and 17" in various scales, all in model space and plot eack one individually on it's own piece of paper?
-
Yes.
-
I meant to add, all with the click of 1 button...
-
Yes.
-
I would think it would be kind of easy (if the title blocks are actually blocks).
Just thinking out loud...
Program would search for matching block names, find their position and extents and print based on that information. If they aren't blocks, I think you'd have a hard time doing this auto-magically.
-
I would think it would be kind of easy (if the title blocks are actually blocks).
Just thinking out loud...
Program would search for matching block names, find their position and extents and print based on that information. If they aren't blocks, I think you'd have a hard time doing this auto-magically.
x2
-
Yes they are actually blocks.
OK So currently I do some other / different "magic" plotting. All I do is run a script the does all the plotting from the command line instead of through the onscreen menu. This only works if there is only 1 title block in the model space or a different script if there is one title block in the Paper space.
When I try that it does not provide an option for plotting by block.
I do not think I want to do it through a VBA routine just because I know nothing about Visual Basic.
So for now I'm thinking I need to do it through a lisp. Would you say that is correct?
-
You don't actually plot "by block" - you get the coordinates of the block and use that as your window for plotting.
And it would most likely be easier/less code to do it in LSP than VBA.
-
Here is a quick starter. You will have to go through your plot options and fill in as necessary as well as modify the ssget filter to the block names you are looking for.
HTH
(defun c:pltalot (/ ss bbox name x minpt maxpt)
(if (setq ss
(ssget "_x"
'((0 . "INSERT") (2 . "8.5x11,11x17,22x34") (410 . "Model"))
)
)
(progn
(setq
ss (mapcar 'vlax-ename->vla-object
(vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
)
)
(mapcar
'(lambda (x)
(setq bbox (vla-getboundingbox x 'minpt 'maxpt)
bbox (mapcar 'vlax-safearray->list (list minpt maxpt))
name (vla-get-name x)
)
(cond ((= name "8.5x11")
(command "-plot" "y" "go through prompts and plot window and use bbox for values". . . . . . .)
)
((= name "11x17")
(command "-plot" "y" "go through prompts and plot window and use bbox for values". . . . . . .)
)
((= name "22x34")
(command "-plot" "y" "go through prompts and plot window and use bbox for values". . . . . . .)
)
)
)
ss
)
)
)
)
-
I'll have to mess with it Mon. Thanks for getting me started. Much appreciated.
Have agreat weekend
-
You too :)
-
I'm not having luck getting it to work. Can you help. Red are the items I'm thinking I need to update to match my plot settings and block names, etc. but I'm not sure if should be updating others or if I should not be changing something I'm changing.
Also not quite sure what info of mine is suppose to replace "INSERT" "8.5x11,11x17,22x34" "Model"
As is it is giving me the following error...
; error: misplaced dot on input
(defun c:pltalot (/ ss bbox name x minpt maxpt)
(if (setq ss
(ssget "[color=red]_x[/color]"
'((0 . "[color=red]INSERT[/color]") (2 . "[color=red]8.5x11,11x17,22x34[/color]") (410 . "[color=red]Model[/color]"))
)
)
(progn
(setq
ss (mapcar 'vlax-ename->vla-object
(vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
)
)
(mapcar
'(lambda (x)
(setq bbox (vla-getboundingbox x 'minpt 'maxpt)
bbox (mapcar 'vlax-safearray->list (list minpt maxpt))
name (vla-get-name x)
)
(cond ((= name "[color=red]8.5x11[/color]")
(command "-plot" "y" "[color=red]go through prompts and plot window and use bbox for values[/color]". . . . . . .)
)
((= name "[color=red]11x17[/color]")
(command "-plot" "y" "[color=red]go through prompts and plot window and use bbox for values[/color]". . . . . . .)
)
((= name "[color=red]22x34[/color]")
(command "-plot" "y" "[color=red]go through prompts and plot window and use bbox for values[/color]". . . . . . .)
)
)
)
ss
)
)
)
)
Posted on: January 11, 2008, 03:50:08 pmPosted by: Matt W
Insert Quote
You don't actually plot "by block" - you get the coordinates of the block and use that as your window for
-
See below:
(defun c:pltalot (/ ss bbox name x minpt maxpt)
(if (setq ss
(ssget "_x"
'((0 . "INSERT") (2 . "8.5x11,11x17,22x34") (410 . "Model"));;name of your different size titleblocks separated by commas (2 . "
)
)
(progn
(setq
ss (mapcar 'vlax-ename->vla-object
(vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
)
)
(mapcar
'(lambda (x)
(setq bbox (vla-getboundingbox x 'minpt 'maxpt)
bbox (mapcar 'vlax-safearray->list (list minpt maxpt))
name (vla-get-name x)
)
(cond ((= name "8.5x11")
(command "-plot" "y" "model" "printer" "papersize" "inches\mm" "portrait\lanscape");;see below for typical prompts when using -plot
)
((= name "11x17")
(command "-plot" "y" "go through prompts and plot window and use bbox for values")
)
((= name "22x34")
(command "-plot" "y" "go through prompts and plot window and use bbox for values")
)
)
)
ss
)
)
)
)
;;;Command: -plot
;;;Detailed plot configuration? [Yes/No] <No>: y
;;;Enter a layout name or [?] <Model>:
;;;Enter an output device name or [?] <\\aqua-srv01\HP LaserJet 5Si PCL 5e>:
;;;Enter paper size or [?] <Letter>:
;;;Enter paper units [Inches/Millimeters] <Inches>:
;;;Enter drawing orientation [Portrait/Landscape] <Landscape>:
;;;Plot upside down? [Yes/No] <No>:
;;;Enter plot area [Display/Extents/Limits/View/Window] <Display>:
;;;Enter plot scale (Plotted Inches=Drawing Units) or [Fit] <Fit>:
;;;Enter plot offset (x,y) or [Center] <0.00,0.00>:
;;;Plot with plot styles? [Yes/No] <Yes>:
;;;Enter plot style table name or [?] (enter . for none) <>:
;;;Plot with lineweights? [Yes/No] <Yes>:
;;;Enter shade plot setting [As displayed/Wireframe/Hidden/Visual styles/Rendered]
;;;<As displayed>:
;;;Write the plot to a file [Yes/No] <N>:
;;;Save changes to page setup [Yes/No]? <N>
;;;Proceed with plot [Yes/No] <Y>:
;;;Effective plotting area: 4.82 wide by 10.48 high
-
Are you saying I don't need to modify any of the code at the beginning?
Yes I'm pretty sure I understand the plot command portion. I'm already doing that in other applications. Only works for a single title block in model space or a single per paper tab. But much more efficient than going through the plot command on screen.
-
Can you post a sample DWG?
-
Try this...
-
Alright...try this one :)
The line (2 . "LCC_BRD_LANDSCAPE_*") is filtering out blocks that have a name LCC_BRD_LANDSCAPE_ and the asterisk is a wildcard to grab either 11x17 or 8.5x11.
(defun c:pltalot (/ ss bbox name x minpt maxpt)
(if (setq ss
(ssget "_x"
'((0 . "INSERT")
(2 . "LCC_BRD_LANDSCAPE_*")
(410 . "Model")
)
)
)
(progn
(setq
ss (mapcar 'vlax-ename->vla-object
(vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
)
)
(mapcar
'(lambda (x)
(setq bbox (vla-getboundingbox x 'minpt 'maxpt)
bbox (mapcar 'vlax-safearray->list (list minpt maxpt))
)
(command "-plot"
"yes"
"model"
"Dell Laser Printer 1710"
"Letter 8 ½ x 11 in"
"inches"
"landscape"
"no"
"window"
(car bbox)
(cadr bbox)
"fit"
"center"
"yes"
"monochrome.ctb"
"yes"
"as"
"no"
"yes"
"yes"
)
)
ss
)
)
)
)
-
This is untested code to show an example.
(defun c:pltalot (/ ss bbox name x minpt maxpt)
(if (setq ss
(ssget "_x"
'((0 . "INSERT") (2 . "LCC_BRD_LANDSCAPE_*") (410 . "Model"))
)
)
(progn
(setq lst (mapcar 'vlax-ename->vla-object
(vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
)
)
(foreach tb lst
(setq bname (cdr (assoc 2 (entget tb))))
(setq bbox (vla-getboundingbox x 'minpt 'maxpt)
bbox (mapcar 'vlax-safearray->list (list minpt maxpt))
)
(cond
((wcmatch bname "*8?11")(goplot "DELL1710_0811_L" bbox)
((wcmatch bname "*11?17") (goplot "HP5000_1117_L" bbox))
)
)
)
)
(princ)
)
(defun goplot (pname box)
(cond
((= pname "DELL1710_0811_L")
;; AUTOPLOT_"Model"_DELL1710_0811_L.scr
(command "-plot"
;Detailed plot configuration? [Yes/No]
"Yes"
;Enter a layout name or [?]
"Model"
;Enter an output device name or [?]
"Dell Laser Printer 1710"
;Enter paper size or [?]
"Letter 8 ½ x 11 in"
;Enter paper units ["Inches"/Millimeters]
"Inches"
;Enter drawing orientation [Portrait/Landscape]
"landscape"
;Plot upside down? [Yes/No]
"No"
;Enter plot area [Display/"Extents"/Limits/View/Window]
"window"
(car box)
(cadr box)
;Enter plot scale (Plotted "Inches"=Drawing Units) or ["Fit"]
"Fit"
;Enter plot offset (x,y) or ["Center"]
"Center"
;Plot with plot styles? [Yes/No]
"Yes"
;Enter plot style table name or [?]
"monochrome.ctb"
;Plot with lineweights? [Yes/No]
"Yes"
;Enter shade plot setting ["As" displayed/Wireframe/Hidden/Rendered]
"As"
;Write the plot to a file [Yes/No]
"No"
;Save changes to page setup [Yes/No]
"Yes"
;Proceed with plot [Yes/No]
"Yes"
)
)
((= pname "HP5000_1117_L")
;; AUTOPLOT_PAPER_HP5000_1117_L.scr
(command "-plot"
;Detailed plot configuration? [Yes/No]
"Yes"
;Enter a layout name or [?]
""
;Enter an output device name or [?]
"HP LaserJet 5000 Series PCL 6"
;Enter paper size or [?]
"11 x 17"
;Enter paper units ["Inches"/Millimeters]
"Inches"
;Enter drawing orientation [Portrait/Landscape]
"landscape"
;Plot upside down? [Yes/No]
"No"
;Enter plot area [Display/"Extents"/Limits/View/Window]
"window"
(car box)
(cadr box)
;Enter plot scale (Plotted "Inches"=Drawing Units) or ["Fit"]
"Fit"
;Enter plot offset (x,y) or ["Center"]
"Center"
;Plot with plot styles? [Yes/No]
"Yes"
;Enter plot style table name or [?]
"monochrome.ctb"
;Plot with lineweights? [Yes/No]
"Yes"
;Scale lineweights with plot scale? [Yes/No]
"No"
;Plot paper space first? [Yes/No]
"Yes"
;Hide paperspace objects? [Yes/No]
"No"
;Write the plot to a file [Yes/No]
"No"
;Save changes to page setup [Yes/No]
"Yes"
;Proceed with plot [Yes/No]
"Yes"
)
)
((= pname "PAPER_PDF_1117_L")
;; AUTOPLOT_PAPER_PDF_1117_L.scr
(command "-plot"
;Detailed plot configuration? [Yes/No]
"Yes"
;Enter a layout name or [?]
""
;Enter an output device name or [?]
"Adobe PDF"
;Enter paper size or [?]
"Tabloid"
;Enter paper units ["Inches"/Millimeters]
"Inches"
;Enter drawing orientation [Portrait/Landscape]
"landscape"
;Plot upside down? [Yes/No]
"No"
;Enter plot area [Display/"Extents"/Limits/View/Window]
"window"
(car box)
(cadr box)
;Enter plot scale (Plotted "Inches"=Drawing Units) or ["Fit"]
"Fit"
;Enter plot offset (x,y) or ["Center"]
"Center"
;Plot with plot styles? [Yes/No]
"Yes"
;Enter plot style table name or [?]
"monochrome.ctb"
;Plot with lineweights? [Yes/No]
"Yes"
;Scale lineweights with plot scale? [Yes/No]
"No"
;Plot paper space first? [Yes/No]
"Yes"
;Hide paperspace objects? [Yes/No]
"No"
;Write the plot to a file [Yes/No]
"No"
;Save changes to page setup [Yes/No]
"Yes"
;Proceed with plot [Yes/No]
"Yes"
)
)
)
)
-
The shorter version from Ron worked perfectly. Thank you! Greatly appreciated. I'm slammed with getting jobs to the shop this morning but will likely return to this post. Thanks to all!
-
Revised codes above, Made a correction in variable spelling.
-
The shorter version from Ron worked perfectly. Thank you! Greatly appreciated. I'm slammed with getting jobs to the shop this morning but will likely return to this post. Thanks to all!
Glad it worked for you :)...I tested it a bit after posting and could not get it to work on my end. :?
-
I don't think I changed anything to make it work for me
-
OK So I've made it work, different code different commands for each printer I want to possibly send to. They have all been Model space.
So now I'm wanting to do the same for Layout Tabs. when my code asks for ... Enter a layout name or [?] is there a way just to tell it to print all layout tabs. Difficulty I'm running into is that there is no consistent naming and an * does not seem to do it.
-
CAB has a perfect app for what you want. All you will need to do is make some page setups to work with it.
http://www.theswamp.org/index.php?topic=1916.0
Here is the code above modified to plot paper space tabs:
*modified to plot tabname instead of model
(defun c:pltalot (/ ss bbox name x minpt maxpt tabname)
(if (setq ss
(ssget "_x"
'((0 . "INSERT")
(2 . "LCC_BRD_LANDSCAPE_*")
(-4 . "<NOT")
(410 . "Model")
(-4 . "NOT>")
)
)
)
(progn
(setq
ss (mapcar 'vlax-ename->vla-object
(vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
)
)
(mapcar
'(lambda (x)
(setq tabname
(cdr (assoc 410 (entget (vlax-vla-object->ename x))))
)
(setvar 'ctab tabname)
(setq bbox (vla-getboundingbox x 'minpt 'maxpt)
bbox (mapcar 'vlax-safearray->list (list minpt maxpt))
)
(command "-plot"
"yes"
tabname
"Dell Laser Printer 1710"
"Letter 8 ½ x 11 in"
"inches"
"landscape"
"no"
"window"
(car bbox)
(cadr bbox)
"fit"
"center"
"yes"
"monochrome.ctb"
"yes"
"as"
"no"
"yes"
"yes"
)
)
ss
)
)
)
)
-
Thanks Ron.
One thing my routine does not provide is a way to plot each tab with a different page set up for each one. Unless the Tabs are already set & you use PREVIOUS as the page set up.
-
I do not need to plot different settings or different printers per tab. At least not all in the same process. May need to send all to big printer today and then send them all to PDF tomorrow. But never some to laser and some to PDF at sam time so it will work for me. Not sure about for others.
Ron,
Thanks!!! This is awesome. Code required a little tweaking to get through the plot inputs. See changes in red... and even these changes might need changed depending on how you want your drawing to plot...
basically the few lines below the plot style input
(command "-plot"
"yes"
tabname
"Dell Laser Printer 1710"
"Letter 8 ½ x 11 in"
"inches"
"landscape"
"no"
"window"
(car bbox)
(cadr bbox)
"fit"
"center"
"yes"
"monochrome.ctb"
[color=red]"yes"
"no"
"yes"
"no"
"no"
"yes"
"yes"[/color]
-
Glad to help :)
-
Can you help me with how to make it so that I can window pick what all borders I want to plot?
-
Luke
Can you help me with how to make it so that I can window pick what all borders I want to plot?
If you still need an option window select and plot - take a look at this:
http://www.theswamp.org/index.php?topic=27682.msg332354#msg332354
-
OK so you guys all helped me with this previously. Greatly appreciated.
Now I'm working on getting everything setup to work for 2010.
My support patha are all looking for the correct folders.
I have apploaded the lisp.
but when I try to plot I get the following on the command line...
; error: no function definition: nil
Can anybody help trouble shoot