ttechnik 发表于 2022-7-5 17:29:45

如何获取绘图坐标

你好
 
如何获取区域坐标?
 
我知道,vla getwindowtoplot方法。
“必须将PlotType属性设置为acWindow,才能将这些坐标用于打印。”
 
但是,不是acWindow!如果使用setwindowtoplot方法设置,该方法可以获取坐标。
 
我喜欢在布局模式下绘制区域坐标。
 
我想用它来选择打印纸空间
使用ssget“_WP”点列表
你怎么能做到?

Hippe013 发表于 2022-7-5 17:41:20

我不确定你想做什么,但你描述的方法是获得坐标的正确方法。
 
您可以使用此方法获取布局的坐标,无论其设置为acWindow还是acLayout。如果将setwindowtoplot方法设置为acLayout,则不能使用该方法,因为acLayout使用版面的纸张大小。
 
我希望这会有所帮助。

ttechnik 发表于 2022-7-5 17:51:05

布局设置为A布局。
我喜欢ssget的pointlist。
我喜欢选择paperspace对象。
如何获取点列表?

Roy_043 发表于 2022-7-5 17:57:28

你为什么不使用这样的东西
(ssget
"_X"
(list
   (cons 410 (getvar 'ctab))
   '(-4 . "<OR")
   '(0 . "~VIEWPORT")
   '(-4 . "<NOT")
       '(69 . 1) ; Do not select the main PS viewport.
   '(-4 . "NOT>")
   '(-4 . "OR>")
)
)

ttechnik 发表于 2022-7-5 17:59:49

thx,但对我不好。
 
此代码在图纸空间中全选。
 
我需要打印区域上的对象。只是,不是全部。
 
我的代码:
(setq plottedarea (getWindowToPlot layout))
(setq x1 (caarplottedarea)
y1 (cadar plottedarea)
x2 (caadr plottedarea)
y2 (cadadr plottedarea))

(setq ents (ssget "_CP" (list (car plottedarea)
                        (list x2 y1)
                        (cadr plottedarea)
                        (list x1 y2))
          (list (cons 8layer) (cons 0"INSERT")))) ; "_layout" fólián keresünk objektumokat, itt lesz a rajzpecsét és a keret, a navigáció is!

 
但是这个rutine不好,A布局图类型:
 
(defun getWindowToPlot (layout / balalso jobbfelso plottype)
(vla-GetWindowToPlot layout 'balalso 'jobbfelso)
(setq balalso   (vlax-safearray->list balalso)
jobbfelso (vlax-safearray->list jobbfelso))
(list balalso jobbfelso)
)

Hippe013 发表于 2022-7-5 18:08:00

让我们看看acLayout和acWindow的区别。
 
当布局设置为“A布局”时,AutoCad将打印表窗口从0,0设置到右上角,这由设置的纸张大小决定。
 
如果需要自定义可打印窗口,则需要将其设置为acWindow。
 
因此,如果你想做你似乎想做的事情,那么布局需要设置为acWindow。
 
这有意义吗?

Roy_043 发表于 2022-7-5 18:18:33

好的,这是第一次尝试:
; (LayoutEntityList (getvar 'ctab))
(defun LayoutEntityList (nme / dic enm)
(if
   (and
   (setq dic (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_LAYOUT"))))
   (setq enm (cdr (assoc -1 (dictsearch dic nme))))
   )
   (entget enm)
)
)

; The function assumes symmetrical margins (left=right, top=bottom).
; Groupcodes:
;40 ; Left margin in mm.
;41 ; Bottom margin in mm.
;44 ; Paper width in mm.
;45 ; Paper height in mm.
;72 ; Plot units.
;73 ; Plot rotation.
; 142 ; Numerator of print scale.
; 143 ; Denominator print scale.
; 148 ; Paper origin: X value.
; 149 ; Paper origin: Y value.
; (command "_.rectangle" "_non" (car (LayoutPaperWindow (getvar 'ctab) T)) "_non" (cadr (LayoutPaperWindow (getvar 'ctab) T)))
(defun LayoutPaperWindow (nme inclMarginsP / btm elst fac hgt lft ptBL wid)
(if (setq elst (LayoutEntityList nme))
   (progn
   (setq fac
       (/
         (cdr (assoc 143 elst))
         (cdr (assoc 142 elst))
         (if (zerop (cdr (assoc 72 elst))) 25.4 1.0)
       )
   )
   (if (zerop (rem (cdr (assoc 73 elst)) 2))
       (progn
         (setq lft (cdr (assoc 40 elst)))
         (setq btm (cdr (assoc 41 elst)))
         (setq wid (cdr (assoc 44 elst)))
         (setq hgt (cdr (assoc 45 elst)))
       )
       (progn
         (setq lft (cdr (assoc 41 elst)))
         (setq btm (cdr (assoc 40 elst)))
         (setq wid (cdr (assoc 45 elst)))
         (setq hgt (cdr (assoc 44 elst)))
       )
   )
   (list
       (setq ptBL
         (list
         (- (- (cdr (assoc 148 elst))) (if inclMarginsP (* fac lft) 0.0))
         (- (- (cdr (assoc 149 elst))) (if inclMarginsP (* fac btm) 0.0))
         )
       )
       (list
         (+ (car ptBL)(* fac wid) (if inclMarginsP 0.0 (* -2.0 fac lft)))
         (+ (cadr ptBL) (* fac hgt) (if inclMarginsP 0.0 (* -2.0 fac btm)))
       )
   )
   )
)
)

ttechnik 发表于 2022-7-5 18:24:07

嘿,罗伊,
 
这是非常好的代码。
这正是我所需要的。
 
非常感谢你。

Roy_043 发表于 2022-7-5 18:35:23

... 我必须承认,这有点让人困惑,所以我很高兴听到代码对你有用。
页: [1]
查看完整版本: 如何获取绘图坐标