嗨。我正在搜索aa lisp以在相同坐标下从模型空间创建新的Viewport布局(用户每次都会给出viwport比例)。
我在想两种方法来做到这一点。
1)在模型规范中选择一个矩形,该矩形出现在具有相同坐标的Viewport的Layout中。
2)指定模型中出现在具有相同坐标的Viewport的Layout中的区域。
我找到了LeeMac lisp代码ms2psV1-0.lsp但不完全是我正在搜索的
- ;;-------------------=={ Modelspace to Paperspace }==-------------------;;
- ;; ;;
- ;; This program allows the user to copy a selection of objects from ;;
- ;; Modelspace to Paperspace through an active viewport. ;;
- ;; ;;
- ;; This functionality is similar to the standard CHSPACE command, ;;
- ;; however, this program will copy the selection of objects as ;;
- ;; opposed to moving the objects from Modelspace to Paperspace. ;;
- ;; ;;
- ;; Upon issuing the command 'ms2ps' at the AutoCAD command-line, the ;;
- ;; user is prompted to make a selection of objects to copy. ;;
- ;; ;;
- ;; Following a valid selection, the program will copy the objects to ;;
- ;; the active Paperspace layout, before performing the necessary ;;
- ;; matrix transformations to maintain the visual appearance of the ;;
- ;; objects as displayed through the active viewport. ;;
- ;; ;;
- ;; The program is compatible with rectangular & polygonal viewports, ;;
- ;; under all UCS & view settings, and with objects constructed in ;;
- ;; any UCS construction plane. ;;
- ;; ;;
- ;; Note that the command is only available when a Paperspace Layout ;;
- ;; is set current, with a viewport active. ;;
- ;; ;;
- ;;----------------------------------------------------------------------;;
- ;; Author: Lee Mac, Copyright © 2014 - www.lee-mac.com ;;
- ;;----------------------------------------------------------------------;;
- ;; Version 1.0 - 2014-02-16 ;;
- ;; ;;
- ;; First release. ;;
- ;;----------------------------------------------------------------------;;
-
- (defun c:ms2ps ( / *error* ang doc enx idx lst mat nor scl sel )
-
- (defun *error* ( msg )
- (LM:endundo (LM:acdoc))
- (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
- (princ (strcat "\nError: " msg))
- )
- (princ)
- )
-
- (LM:startundo (LM:acdoc))
- (cond
- ( (= 1 (getvar 'tilemode))
- (prompt "\nCommand only available in Paperspace.")
- )
- ( (= 1 (getvar 'cvport))
- (prompt "\nPlease activate a viewport.")
- )
- ( (setq sel (ssget '((410 . "Model"))))
- (repeat (setq idx (sslength sel))
- (setq lst (cons (vlax-ename->vla-object (ssname sel (setq idx (1- idx)))) lst))
- )
- (setq enx (entget (ssname (ssget "_X" (list '(0 . "VIEWPORT") (cons 69 (getvar 'cvport)))) 0))
- ang (cdr (assoc 51 enx))
- nor (cdr (assoc 16 enx))
- scl (/ (cdr (assoc 41 enx)) (cdr (assoc 45 enx)))
- )
- (setq mat
- (vlax-tmatrix
- (append
- (mapcar '(lambda ( a b ) (append a (list b)))
- (setq mat ;; The following is adapted from gile's WCS2PCS function:
- (mxm
- (list
- (list (cos ang) (- (sin ang)) 0.0)
- (list (sin ang) (cos ang) 0.0)
- '(0.0 0.0 1.0)
- )
- (mapcar (function (lambda ( v ) (vxs (trans v nor 0 t) scl)))
- '(
- (1.0 0.0 0.0)
- (0.0 1.0 0.0)
- (0.0 0.0 1.0)
- )
- )
- )
- )
- (mapcar '+
- (mxv mat (mapcar '- (cdr (assoc 17 enx))))
- (vxs (cdr (assoc 12 enx)) (- scl))
- (cdr (assoc 10 enx))
- )
- )
- '((0.0 0.0 0.0 1.0))
- )
- )
- )
- (foreach obj
- (vlax-invoke (setq doc (vla-get-activedocument (vlax-get-acad-object))) 'copyobjects lst
- (vla-get-block
- (vla-item
- (vla-get-layouts doc)
- (getvar 'ctab)
- )
- )
- )
- (vla-transformby obj mat)
- )
- )
- )
- (LM:endundo (LM:acdoc))
- (princ)
- )
-
- ;; Matrix Transpose - Doug Wilson
- ;; Args: m - nxn matrix
-
- (defun trp ( m )
- (apply 'mapcar (cons 'list m))
- )
-
- ;; Matrix x Matrix - Vladimir Nesterovsky
- ;; Args: m,n - nxn matrices
-
- (defun mxm ( m n )
|