Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AutoPlot lisp

3 REPLIES 3
Reply
Message 1 of 4
CAD_user85
1208 Views, 3 Replies

AutoPlot lisp

 

Dear autocad users, auto-,vlisp writers,

 

Might i ask your help.

 

I would like to create a lisp that "automatically" plots all present layouts.

I've written the following and it works if the plot setting are equal in every layout.

 

The only problem is.. Not all the layouts are equal.

I want to add a kind of “page orientation recognizer” that will tell alter the lisp-route

To check Portrait orientated layout sizes.

 

The only problem is… It does not keep in consideration the differences in the layouts. Differences like Page Orientation or Size.

I would really like to add this “consideration”.

 

 

I've tried to solve my little problem... but i still lack the proper knowlage of good autolisp coding.

 

could you please help me? 

Manny thanks in advance.

 

Greets Michel

 

 

 

 

I’ve written the following code:

(defun c:tolp (/ )
(setq hhmax (car (getvar "limmax"))) ; X-Limits
(setq vvmax (cadr (getvar "limmax"))) ; Y-Limmits
 
 
; Get page orientation.
(vl-load-com)(setq rot (vla-get-plotrotation (vla-get-activelayout
(vla-get-activedocument (vlax-get-acad-object)))))
 
;Set $var ROT, to sting.
(setq rot (itoa rot)
; Start the If-statements to check page size, if landscape (or that is the idea)
                                   (if (= rot 1);true run next if statements...
 
                                   (if (< hhmax 400) ; true
                                               (setq plotsize "A4") ; True
                                   )
                                   (if (> hhmax 400) ; True A3
                                               (setq plotsize "A3") ; True
                                   )
                                   (if (> hhmax 500) ; True A2
                                               (setq plotsize "A2")
                                   )
                                   (if (> hhmax 800) ; True A1
                                               (setq plotsize "A1")
                                   )
                                   (if (> hhmax 1000) ; True A0
                                               (setq plotsize "A0")
                                   )
                                   (princ “\nNo correct papersize found! ”)
 
 
;accept for this part… the lisp works
;Portrait
;If page orientation is 0 or Portrait run the following If-statements)
            (setq orientation portrait)
                                   (if (< hhmax 250) ; True
                                               (setq plotsize "A4")                            
                                   )
                                   (if (> hhmax 250) ; True
                                               (setq plotsize "A3")                            
                                   )
                                   (if (> hhmax 300) ; True
                                               (setq plotsize "A2")
                                   )
                                   (if (< hhmax 500) ; True
                                               (setq plotsize "A1")
                                   )                                                         
                                   (if (< hhmax 800) ; True
                                               (setq plotsize "A0")
                                   )
                                   (Princ ”Digital input failed, please resort to manual input.”  )
)          
)

 

 

 

 

3 REPLIES 3
Message 2 of 4
Lee_Mac
in reply to: CAD_user85

Perhaps something along these lines:

(defun c:tolp ( / dim psz wid )
    (if (< 1.0 (apply '/ (setq dim (mapcar '- (getvar 'limmax) (getvar 'limmin))))) ;; landscape
        (setq wid (car  dim))
        (setq wid (cadr dim))
    )
    (setq psz
        (cond
            (   (< wid 400)  "A4")
            (   (< wid 500)  "A3")
            (   (< wid 800)  "A2")
            (   (< wid 1000) "A1")
            (   "A0"   )
        )
    )
)

 

Or, to simply use the longest dimension, without the conditional:

(defun c:tolp ( / psz wid )
    (setq wid (apply 'max (mapcar '- (getvar 'limmax) (getvar 'limmin))))
    (setq psz
        (cond
            (   (< wid 400)  "A4")
            (   (< wid 500)  "A3")
            (   (< wid 800)  "A2")
            (   (< wid 1000) "A1")
            (   "A0"   )
        )
    )
)

 

Message 3 of 4
CAD_user85
in reply to: Lee_Mac

Dear Lee Mac, 

 

Thank you verry much for your help.

 

I've tested the part you gave me, with the part i've created, And it works! 

It works like a charm.

 

Thank you verry verry much.

 

Greets

Michel

 

 

Message 4 of 4
Lee_Mac
in reply to: CAD_user85

You're very welcome Michel, thank you.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost