Guest Posted June 5, 2015 Posted June 5, 2015 Hi .I want to ask if someone have a lisp to calculate the area of layout print paper. Thanks Quote
tombu Posted June 5, 2015 Posted June 5, 2015 This worked for me: http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-get-real-printable-size-per-layout-via-lisp/td-p/5527568 Quote
Guest Posted June 5, 2015 Posted June 5, 2015 hi tombu thanks for the reply. This lisp gives me the dimension of each layout,I want a lisp to culculate the area of the curent layout. Thanks Quote
Guest Posted June 6, 2015 Posted June 6, 2015 (edited) Hi bigal . I need to calculate the printing cost for the current layout. The first lisp code gives me the dimensions of all layouts . This lisp calculate the cost of the last layout . Can any one change it to calculate the cost of the current layout? (defun c:test (/ lo wdt lg plotarea) (vl-load-com) (vlax-for lo (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) (vla-getpapersize lo 'wdt 'lg) (setq plotarea (list wdt lg)) (princ "\n") (princ (vla-get-name lo)) (princ "\n\t\tPlot size - ") (princ (if (zerop (rem (vla-get-plotrotation lo) 2)) plotarea ) ) ) (setq area (/( * wdt lg) 1000000)) (setq pr (cond ((getreal "\n The print cost €/sq.m (π.χ 2.30 €/sq.m monochrome ή 3.50 €/sq.m color) : "))(2.30))) (setq cost (* pr area)) (setq sx (cond ((getreal "\n Give the number of copies (example 3) : "))(3))) (setq scost (* sx cost)) (textscr) (princ (strcat "\n Calculations" "\n --------------------------------------------------------------------------" "\n dimension x = " (rtos wdt 2 2) " m" "\n dimension y = " (rtos lg 2 2) " m" "\n Area of the print paper = " (rtos area 2 2) " sq.m" "\n Cost per drawing = " (rtos cost 2 2) " €" "\n Total Cost of Printing = " (rtos scost 2 2) " €" ) ) (princ) ) Thanks Edited June 6, 2015 by prodromosm Quote
Guest Posted June 6, 2015 Posted June 6, 2015 I update the code but i still have the same problem.This lisp calculate the cost of the last layout Quote
hmsilva Posted June 6, 2015 Posted June 6, 2015 Try this revised code... (defun c:test (/ lo wdt lg plotarea) (vl-load-com) ;(vlax-for lo (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) (setq lo (vla-item (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) (getvar 'CTAB))) (vla-getpapersize lo 'wdt 'lg) (setq plotarea (list wdt lg)) (princ "\n") (princ (vla-get-name lo)) (princ "\n\t\tPlot size - ") (princ (if (zerop (rem (vla-get-plotrotation lo) 2)) plotarea (reverse plotarea); <<<< ) ) (setq area (/( * wdt lg) 1000000)) (setq pr (cond ((getreal "\n The print cost €/sq.m (p.? 2.30 €/sq.m monochrome ? 3.50 €/sq.m color) : "))(2.30))) (setq cost (* pr area)) (setq sx (cond ((getreal "\n Give the number of copies (example 3) : "))(3))) (setq scost (* sx cost)) (textscr) (princ (strcat "\n Calculations" "\n --------------------------------------------------------------------------" "\n dimension x = " (rtos wdt 2 2) " m" "\n dimension y = " (rtos lg 2 2) " m" "\n Area of the print paper = " (rtos area 2 2) " sq.m" "\n Cost per drawing = " (rtos cost 2 2) " €" "\n Total Cost of Printing = " (rtos scost 2 2) " €" ) ) (princ) ) Henrique Quote
Lee Mac Posted June 6, 2015 Posted June 6, 2015 @Henrique, This: (setq lo (vla-item (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) (getvar 'CTAB))) Could become: (setq lo (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object)))) Quote
Lee Mac Posted June 6, 2015 Posted June 6, 2015 Perhaps the code could be shortened to: (defun c:test ( / lay len lst num prc wid ) (if (= 1 (getvar 'tilemode)) (princ "\nCommand only available in paperspace.") (progn (initget 6) (setq prc (cond ((getreal "\nThe print cost €/sq.m <2.30 €/sq.m>: ")) (2.30))) (initget 6) (setq num (cond ((getint "\nNumber of copies <1>: ")) (1)) lay (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))) ) (vla-getpapersize lay 'wid 'len) (if (zerop (rem (vla-get-plotrotation lay) 2)) (setq lst (list wid len)) (setq lst (list len wid)) ) (textscr) (princ (strcat "\n Calculations for layout \"" (vla-get-name lay) "\"" "\n ------------------------------------------------------------" "\n Dimensions: " (rtos len 2 2) " mm x " (rtos wid 2 2) " mm" "\n Paper area: " (rtos (* len wid 1e-6) 2 2) " sq.m" "\n Cost per dwg: " (rtos (* prc len wid 1e-6) 2 2) " €" "\n Total cost: " (rtos (* prc len wid num 1e-6) 2 2) " €" "\n ------------------------------------------------------------" ) ) ) ) (princ) ) Quote
hmsilva Posted June 6, 2015 Posted June 6, 2015 @Henrique,This: (setq lo (vla-item (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) (getvar 'CTAB))) Could become: (setq lo (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object)))) Hi Lee, of course it is much more logical to get the 'activelayout' object... My intente was to show to OP that we don't need to loop through each item in the 'Layouts' collection, just get one, the current one... Cheers Henrique Quote
Lee Mac Posted June 6, 2015 Posted June 6, 2015 of course it is much more logical to get the 'activelayout' object... My intente was to show to OP that we don't need to loop through each item in the 'Layouts' collection, just get one, the current one... I understand Henrique - my apologies for interefering with the lesson for the OP Lee Quote
hmsilva Posted June 6, 2015 Posted June 6, 2015 I understand Henrique - my apologies for interefering with the lesson for the OP Lee Lee, no need for apologies. Your comments, explanations and codes, are always welcome. Cheers Henrique Quote
Recommended Posts
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.