David Bethel 发表于 2022-7-5 17:52:06

通过entmake创建视图

有人通过(entmake)成功创建了视图表定义吗?
 
(entmake '((0 . "VIEW") (2 . "TEST1") (70 . 0) (40 . 15.9716) (10 -3.3541 -2.29394) (41 .
34.4822) (11 1.0 2.0 0.8137) (12 0.0 0.0 0.0) (42 . 50.0) (43 . 0.0) (44 . 0.0)
(50 . 0.0) (71 . 0) (72 . 1) (110 0.0 0.0 0.0) (111 1.0 0.0 0.0) (112 0.0 1.0
0.0) (79 . 0) (146 . 0.0)))
 
谢谢
 
-大卫

tombu 发表于 2022-7-5 18:07:29

我使用它创建打印视图:
;| Create plot view adjusting for margins and extents.
In Model Space adjust for annotation scale
(pview description Width Height RightMargin TopMargin)
Plot Properties… => Modify Standard Paper Sizes (Printable Area) => select Paper size displays Printable Area
I always leave TopMargin 0, then check "Center the plot:" for the Page setup
Once you get it to work for a plotter's Paper size that macro will work on any layout for that plotter's Paper size.
It pulls Page Setup from "Templates.dwt" so a "24×36" Layout would need "Templates.dwt" to have the Page Setup "PS 24×36"
Example macros:
^C^C^P(or pview (load "pview.lsp"));(pview "24×36" 35.6 23.6 0.7 0.0)
^C^C^P(or pview (load "pview.lsp"));(pview "11×17 1120c" 16.31 10.52 0.035 0)
^C^C^P(or pview (load "pview.lsp"));(pview "11×17 Xerox" 16.54 10.54 0.035 0)
^C^C^P(or pview (load "pview.lsp"));(pview "11×17 Xerox" 16.52 10.44 0.035 0)
^C^C^P(or pview (load "pview.lsp"));(pview "11×17 Xerox" 16.54 10.54 0.035 0)
|;
(defun pview (vname wid hgt xmar ymar / xmax xmin maxx maxy minx miny mid vw)
(if (= 1 (getvar "cvport"))
   (setq vname (strcat "PS " vname))
   (setq vname (strcat "MS " vname)
         wid (/ wid (getvar "cannoscalevalue"))
         hgt (/ hgt (getvar "cannoscalevalue"))
         xmar (/ xmar (getvar "cannoscalevalue"))
         ymar (/ ymar (getvar "cannoscalevalue"))
   )
)
(if (tblsearch "view" vname)(command "-view" "D" vname))
(vla-ZoomExtents (vlax-get-acad-object))
(vla-ZoomPrevious (vlax-get-acad-object))
(setq xmax (getvar "extmax")
   xmin (getvar "extmin")
   maxx (car xmax)
   maxy (cadr xmax)
   minx (car xmin)
   miny (cadr xmin)
)
(cond
   ((> (- maxx minx)wid)
   (progn
       (setq midx (car(getvar "viewctr")) hwid (/ wid 2))
       (setq midx (if(< (- midx hwid) minx) (+ minx hwid) (- maxx hwid)))
       (princ "\nGot width!")
   )
   )
   ((> xmar 0) (setq midx (/ (- (+ xmar maxx maxx) wid) 2)))
   ((< xmar 0) (setq midx (/ (+ xmar minx minx wid) 2)))
   (T (setq midx (/ (+ minx maxx) 2)))
)
(cond
   ((> (- maxy miny)hgt)
   (progn
       (setq midy (cadr(getvar "viewctr")) hhgt (/ hgt 2))
       (setq midy (if(< (- midy hhgt) miny) (+ miny hhgt) (- maxy hhgt)))
       (princ "\nGot higth!")
   )
   )
   ((> ymar 0) (setq midy (/ (- (+ ymar maxy maxy) hgt) 2)))
;    ((> ymar 0) (setq midy (/ (+ (+ ymar maxy) (- maxy hgt)) 2)))
   ((< ymar 0) (setq midy (/ (+ ymar miny miny hgt) 2)))
   (T (setq midy (/ (+ miny maxy) 2)))
)

(setq mid (list midx midy))
(setq vw
   (list
   '(0 . "VIEW")
   '(100 . "AcDbSymbolTableRecord")
   '(100 . "AcDbViewTableRecord")
   (cons 2 vname)
   (if (= 1 (getvar "cvport")) (cons 70 1) (cons 70 0))
   (cons 40 hgt)
   (cons 10 mid)
   (cons 41 wid)
   '(11 0.0 0.0 1.0)
   '(12 0.0 0.0 0.0)
   '(42 . 50.0)
   '(43 . 0.0)
   '(44 . 0.0)
   '(50 . 0.0)
   '(71 . 0)
   '(72 . 0)
   )
)
;                        (command "._-PSETUPIN" "Templates.dwt" vname)
(if(entmake vw)
                (progn
                        (command "._-PSETUPIN" "Templates.dwt" vname)
                        (if (= 1 (logand 1 (getvar "cmdactive")))(command "Y"))
                        (if(putPagesetup (getvar "ctab") vname)
                  (princ (strcat "\nView \"" vname "\" has been created & Page Setup \"" vname "\" has been assigned to current layout."))
                  (princ (strcat "\nView \"" vname "\" has been created, but Page Setup \"" vname "\" was not found."))
                        )
                )
                (princ (strcat "\n*ERROR* view \"" vname "\" could not be created!"))
)
(princ)
)

; Jason Piercey . May 16th, 2003 - https://www.theswamp.org/index.php?topic=3007.msg55202#msg55202
; assign a pagesetup to a layout
; - string, layout name
; - string, pagesetup to assign
; return: T or nil
(defun putPagesetup (layout setup / layouts plots)
(defun item-p (collection item)
(if
(not
   (vl-catch-all-error-p
    (vl-catch-all-apply
   '(lambda () (setq item (vla-item collection item))))))
item
)
)
(and
(or *acad* (setq *acad* (vlax-get-acad-object)))
(or *doc* (setq *doc* (vla-get-activedocument *acad*)))
(setq layouts (vla-get-layouts *doc*))
(setq plots (vla-get-plotconfigurations *doc*))
(setq layout (item-p layouts layout))
(setq setup (item-p plots setup))
(not (vla-copyfrom layout setup))
)
)

Stefan BMR 发表于 2022-7-5 18:14:16

将以下两项添加到您的列表中:
(entmake
'(
   (0 . "VIEW")
    (100 . "AcDbSymbolTableRecord")
   (100 . "AcDbViewTableRecord")
   (2 . "TEST1")
   (70 . 0)
   (40 . 15.9716)
   (10 -3.3541 -2.29394)
   (41 . 34.4822)
   (11 1.0 2.0 0.8137)
   (12 0.0 0.0 0.0)
   (42 . 50.0)
   (43 . 0.0)
   (44 . 0.0)
   (50 . 0.0)
   (71 . 0)
   (72 . 1)
   (110 0.0 0.0 0.0)
   (111 1.0 0.0 0.0)
   (112 0.0 1.0 0.0)
   (79 . 0)
   (146 . 0.0)
   )
)

Lee Mac 发表于 2022-7-5 18:19:45

是的-虽然我没有找到其他选项,但如果您希望创建一个针对特定纸张空间布局的视图,则只能使用ActiveX LayoutID属性;据我所知,图纸空间布局和视图实体之间的关联似乎没有暴露在Vanilla AutoLISP中。

David Bethel 发表于 2022-7-5 18:28:51

这就成功了:
 
 
 
 
不是我!这太离谱了!
 
这些是标准模型空间视图。从可以导入到其他dwg的1个dwg导出。
 
谢谢-大卫
 
来自旧线程的查询:
 
 
 
http://www.cadtutor.net/forum/showthread.php?88522-快速保存视图和还原视图

David Bethel 发表于 2022-7-5 18:40:28

基于前缀将命名模型空间视图从1个dwg导出和导入到其他dwg的可能场景:
 

;;;EXPORT VIEWS
(defun c:exv (/ wf p td vn)
(setq wf (open "VIEW.EMK" "w"))
(setq p "VIEW")
(while (setq td (tblnext "VIEW" (not td)))
         (setq vn (cdr (assoc 2 td)))
         (princ (strcat "\n" vn))
         (if (= (strcase p) (substr (strcase vn) 1 (strlen p)))
             (progn
               (princ "(entmake '((0 . \"VIEW\")" wf)
               (princ "(100 . \"AcDbSymbolTableRecord\")" wf)
               (princ "(100 . \"AcDbViewTableRecord\")"wf)
               (foreach g (cdr td)
                  (prin1 g wf))
               (princ "))" wf)
               (write-line "" wf))))
(close wf)
(prin1))

;;;IMPORT THE VIEWS
(defun c:imv (/ rf)
(setq rf "VIEW.EMK")
(if (findfile rf)
      (load rf))
(prin1))

tombu 发表于 2022-7-5 18:45:16

导入视图&李•麦克(leemac)的电影可以完成一大堆其他的事情。lsp

tombu 发表于 2022-7-5 18:55:55

从选定图形中导入模型视图的另一个。
;这将从另一个选定图形中导入模型视图;保罗·格雷格森“
页: [1]
查看完整版本: 通过entmake创建视图