本帖最后由 叮咚 于 2021-4-12 14:12 编辑
http://www.lee-mac.com/vpoutline.html
可以参考lee mac这个程序,先把画的矩形反到模型空间中,找到中心点。也就是下面代码的中心 vpt
- (defun ttx(ptcen vpt ww dd ang blx)
- ;(setq ptcenx (mapcar '(lambda(xx)(/ xx 1.0 blx)) ptcen))
- (setq obj_mv (vlax-invoke-method aps "AddPViewport" (vlax-3D-point ptcen) (+ (/ ww blx) 0.0) (+ (/ hh blx) 0.0)))
- (vlax-put-property obj_mv "Layer" "0-视口")
- (vlax-put-property obj_mv "Color" acYellow)
- (vlax-put-property obj_mv "ViewportOn" acTrue)
- (vlax-put-property obj_mv "TwistAngle" (* -1 ang))
- (vlax-put-property obj_mv "GridOn" acFalse)
- ; ActivePViewport示例中有以下说明
- ;' 在将图纸空间 Viewport 设为活动前,mspace 属性必须为 True
- ; ThisDrawing.mspace = True
- ; ThisDrawing.ActivePViewport = newPViewport
- (vlax-put-property adoc_l "ActiveSpace" acPaperspace)
- (vlax-invoke-method (vlax-get-property acad_l "Application") "ZoomExtents")
- (vlax-put-property adoc_l "MSpace" acTrue)
- (vlax-put-property adoc_l "ActivePViewport" obj_mv)
- ;(vlax-put-property adoc_l "ActivePViewport" obj_mv)
- (vlax-invoke-method (vlax-get-property acad_l "Application") "ZoomCenter" (vlax-3D-point vpt) 1.0)
- (vlax-put-property adoc_l "MSpace" acFalse)
- (vlax-put-property obj_mv "CustomScale" (/ 1.0 blx))
- ;(vlax-invoke-method (vlax-get-property acad_l "Application") "ZoomPrevious")
- )
|