Leaderboard
Popular Content
Showing content with the highest reputation on 07/21/2019 in all areas
-
Autolisp can make you a way faster. I once wrote a lisp for drawing development for sheet metal box that proved to be 150 times faster than doing it without the lisp. Start with Afralisp.1 point
-
I made something. See if it can be useful to you. - It will copy "Layout1" multiple times, and name them "Paper1", "Paper2", ... So prepare the pagesetup of Layout1. Remove the viewport (new viewports will be created), but you can add a cartouche (or whatever you need there) Command ALS (for Automatic Layout Setup) - user set the length, height and overlap (for example 800 500 50). - user selects a polyline. -> Along the polyline rectangles (polylines) are created. -> Paper spaces are created, each with a viewport the same size as the rectangles. -> Each viewport pans/zooms (scale is set to 1.00) to a next rectangle Try it on my dwg first (vl-load-com) ;; https://www.cadtutor.net/forum/topic/18257-entmake-functions/ (defun LWPoly (lst cls) (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 (length lst)) (cons 70 cls)) (mapcar (function (lambda (p) (cons 10 p))) lst))) ) ;; based on @see http://www.lee-mac.com/totallengthandarea.html (defun totalLengthPolyline ( s / i) (setq l 0.0) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) l (+ l (vlax-curve-getdistatparam e (vlax-curve-getendparam e))) ) ) l ) ;;;;;;;;;;;;;;;;;;;;;; (defun vat (viewport_length viewport_height overlap / obj pline total_length needle mp1 mp2 ang1 rec1 rec2 rec3 rec4) ;; settings ;;(setq viewport_length 700.0) ;;(setq viewport_height 400.0) ;;(setq overlap 50.0) ;; (princ "\nSelect Polytine") (setq pline (ssget (list (cons 0 "LWPOLYLINE,POLYLINE")) )) (setq obj (vlax-ename->vla-object (ssname pline 0))) (princ (setq total_length (totalLengthPolyline pline)) ) (setq needle 0.0) (while (< needle total_length) ;; (+ total_length viewport_length) (setq mp1 (vlax-curve-getPointAtDist obj needle)) (setq needle (+ needle viewport_length)) (setq mp2 (vlax-curve-getPointAtDist obj needle)) ;; last point, take the end of the polyline (if (= mp2 nil) (setq mp2 (vlax-curve-getPointAtDist obj total_length)) ) (setq ang1 (angle mp1 mp2)) (setq rec1 (polar mp2 (+ ang1 (/ pi 2)) (/ viewport_height 2))) (setq rec2 (polar rec1 (+ ang1 pi) viewport_length)) (setq rec3 (polar rec2 (+ ang1 (* pi 1.5)) viewport_height)) (setq rec4 (polar rec3 ang1 viewport_length)) ;; fill in the globals (setq LWPolylines_data (append LWPolylines_data (list (list rec1 rec2 rec3 rec4) ))) (setq LWPolylines (append LWPolylines (list (LWPoly (list rec1 rec2 rec3 rec4) 1) ))) (setq pointpairs (append pointpairs (list (list mp1 mp2) ))) (setq needle (- needle overlap)) ) (princ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; c:copying-lay-out ;; It will name the layouts "Paper1", "Paper2", ... (defun clo (pointpairs / i n layoutname ) (if (and (setq layoutname "Layout1") (setq n (length pointpairs)) ;; number of new layouts (setq i (+ n 1)) (member layoutname (layoutlist)) ) (repeat n (command "layout" "Copy" layoutname (strcat "Paper" (rtos (setq i (- i 1)))) ) );; repeat );; if (princ) );; demo (defun AlignView (p1 p2 / ang) ;;(command "ucs" "world" "\\") (and ;;(setq p1 (getpoint "\nFirst alignment point: ")) ;;(setq p2 (getpoint p1 "\nSecond alignment point: ")) (setq ang (- (angle (trans p1 1 0) (trans p2 1 0)))) (command "_.dview" "" "_twist" (angtos ang (getvar 'aunits) 16) "") ) (command "ucs" "view" "\\") (princ) ) ;; rotate view (defun rv (1point 2point / ) (command "_ucs" "_w") (if (and 1point 2point) (progn (command "_zoom" "_c" 1point "") (if (= (getvar "angdir") 0) (command "_dview" "" "_tw" (angtos (+ (* -1 (angle 1point 2point)) (getvar "angbase"))(getvar "aunits") 10) "") (command "_dview" "" "_tw" (angtos (+ (angle 1point 2point) (getvar "angbase")) (getvar "aunits") 10) "") ) (setvar "snapang" (angle 1point 2point)) );progn (progn (command "_dview" "" "_tw" "0" "") (setvar "snapang" 0.0) );progn ) (command "_ucs" "_w") (princ) );end defun ;; globals (setq pointpairs (list)) (setq LWPolylines (list)) (setq LWPolylines_data (list)) (defun ALS (viewport_length viewport_height overlap / i pair pt1 pt2) ;; settings ;;(setq viewport_length 800.0) ;;(setq viewport_height 500.0) ;;(setq overlap 50.0) ;; (re) initiate globals (setq LWPolylines (list)) (setq LWPolylines_data (list)) (setq pointpairs (list)) (vat viewport_length viewport_height overlap) (clo pointpairs) (princ LWPolylines_data) (setq i 0) (foreach pair pointpairs (setvar "ctab" (strcat "Paper" (itoa (+ i 1) ))) ;; This example creates a paper space viewport and makes it active. (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) (setq centerPoint (vlax-3d-point (/ viewport_length 2.0) (/ viewport_height 2.0) 0) height viewport_height width viewport_length) ;; Create a paper space Viewport object (vla-put-ActiveSpace doc acPaperSpace) (setq newPViewport (vla-AddPViewport (vla-get-PaperSpace doc) centerPoint width height)) (vla-ZoomAll acadObj) (vla-Display newPViewport :vlax-true) ;; Before making a pViewport active, ;; the mspace property needs to be True (vla-put-MSpace doc :vlax-true) (vla-put-ActivePViewport doc newPViewport) (rv (nth 0 pair) (nth 1 pair)) ;; pt1 pt2 ;zoom window (setq pt1 (nth 2 (nth i LWPolylines_data))) (setq pt2 (nth 0 (nth i LWPolylines_data))) (command "zoom" "_o" (nth i LWPolylines) "") (vla-put-MSpace doc :vlax-false) (vla-put-customscale newPViewport 1.0) ;;(command "_.PSPACE") ;;(command "ucs" "world" "\\") (setq i (+ i 1)) ) ) ;; Automatic layout setup (defun c:ALS2 ( / viewport_length viewport_height overlap ) ;; settings (setq viewport_length 800.0) (setq viewport_height 500.0) (setq overlap 50.0) (ALS viewport_length viewport_height overlap ) ) ;; Automatic layout setup (defun c:ALS ( / ) (ALS (getreal "\nViewport length: ") (getreal "\nViewport height: ") (getreal "\noverlap: ") ) ) viewports_along_track.dwg1 point