乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 12|回复: 12

[编程交流] 激活视口

[复制链接]

73

主题

261

帖子

195

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
375
发表于 2022-7-5 15:16:36 | 显示全部楼层 |阅读模式
你好
 
我找到了一个Lee Mac lisp来激活视口。
但我想用另一种方式选择,这可能吗?
 
  1. (defun c:vpon ( / d s )
  2.    (vl-load-com)
  3.    (if (setq s (ssget "_+.:S:E:L" '((0 . "VIEWPORT"))))
  4.        (progn
  5.            (setq d (vla-get-activedocument (vlax-get-acad-object)))
  6.            (vla-put-mspace d :vlax-true)
  7.            (vla-put-activeviewport d (vlax-ename->vla-object (ssname s 0)))
  8.        )
  9.    )
  10.    (princ)
  11. )

 
 
而不是
想要使用这个,
  1. 2
回复

使用道具 举报

28

主题

317

帖子

292

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
140
发表于 2022-7-5 15:22:48 | 显示全部楼层
好的,我现在明白了。所以我从来没有“控制”哪个视口被激活,我只是更改了ActiveSpace属性,碰巧只有一个视口。非常感谢您抽出时间来阐明!
 
文件中的错误信息确实无助于。。。你看到你在链接页面上引用的那句话了吗?“除非视口处于活动状态,否则无法执行编辑或视图更改。要使视口处于活动状态,请使用文档对象的ActiveViewport属性”(!)。
如果我理解正确,这应该是“除非视口处于活动状态,否则无法执行任何编辑或视图更改。要使视口处于活动状态,请在文档对象上使用ActivePViewport属性”。。。正当
回复

使用道具 举报

18

主题

1529

帖子

973

银币

中流砥柱

Rank: 25

铜币
649
发表于 2022-7-5 15:29:51 | 显示全部楼层
否。该页面是关于视口对象的,该对象与“VPORT”实体相同。 
视口对象=视口图元。
PViewport对象=视口图元。
回复

使用道具 举报

28

主题

317

帖子

292

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
140
发表于 2022-7-5 15:33:48 | 显示全部楼层
回复

使用道具 举报

18

主题

1529

帖子

973

银币

中流砥柱

Rank: 25

铜币
649
发表于 2022-7-5 15:39:03 | 显示全部楼层
I don't think that limiting the selection to the current tab is redundant. At least there is an error in BricsCAD if the (ssname s 0) object is on a different layout.
回复

使用道具 举报

28

主题

317

帖子

292

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
140
发表于 2022-7-5 15:46:01 | 显示全部楼层
You are quite right, I had it upside down. (cons 410 (getvar 'ctab)) is required, that is the use of vla-put-activepviewport which doesn't seems to yield any advantages over vla-put-activeviewport. (My bad. Is it friday yet?)  
So the question would be, if the ssget only grab the viewports on the curent tab only, why would you say that vla-put-activepviewport (with 2 P's) should be used rather than vla-put-activeviewport?
回复

使用道具 举报

18

主题

1529

帖子

973

银币

中流砥柱

Rank: 25

铜币
649
发表于 2022-7-5 15:49:41 | 显示全部楼层
This seems to be a (rare) situation where BricsCAD Lisp is not compatible. The ActiveViewport property is always a "VPORT" in BricsCAD. And for the task at hand ("VIEWPORT") you have to use the ActivePViewport property.
 
EDIT:
I have sent Bricsys a Support Request regarding this compatibility issue. According to their answer BricCAD is in fact compatible with AutoCAD 2013-2018. So the original c:vpon function should fail with these AutoCAD versions as well.
 
The answer to Jef!'s question: Why use vla-put-activepviewport (with 2 P's)? Would then be: To make the code version independent.
回复

使用道具 举报

17

主题

1274

帖子

25

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
260
发表于 2022-7-5 15:51:58 | 显示全部楼层
With Jimmy Bergmark's https://jtbworld.com/autocad-vp-outline-lsp when in modelspace of a viewport it defaults to the active viewport using vla-get-activepviewport.  In paperspace it prompts you to select a viewport.  
 
Not sure where you're going with this routine, but his example may help.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 16:01:13 | 显示全部楼层
I can confirm that activepviewport is required - the code should be amended accordingly.
回复

使用道具 举报

28

主题

317

帖子

292

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
140
发表于 2022-7-5 16:05:35 | 显示全部楼层
While the viewport activate with both, I get the "; error: ActiveX Server returned an error: Le type ne correspond pas" error message only with vla-put-activeviewport. I had to play with the 2015 Active-x reference guide examples to get a better understanding. I'm not sure how/why the vport gets activated despite the error message when I try with vla-put-activeviewport. There are still things that are not clear in my mind...
 
vla-put-activeviewport obj propval
definition: Specifies the active viewport for the drawing.
obj: document
propval Type: Viewport
Viewport definition: A bounded area that displays some portion of a drawing's model space.
 
vla-put-activeviewport obj propval
definition: Specifies the active paper space viewport for the drawing.
obj: document
propval Type: PViewport
PViewport definition: Rectangular objects created in paper space that display views.
 
By reading the PViewport definition that makes me understand that the Viewport definition (A bounded area that displays some portion of a drawing's) is *not* a paperspace object. Ok. The confuzing part was/is that when I browse database entities for a given paperspace tab that contain a viewport, there are 2 (0 . "VIEWPORT") objects. The paperSpace itself (69 . 1) and the viewport (69 . 2). If I browse entities when in modelspace, I see the "VIEWPORT" objects from the last activated paperspace. If I split the model in multiple viewports and browse the "View Ports table", I see the (0 . "VPORT") objects. If I understood correctly, a PViewport active-x object is a (0 . "VIEWPORT"), and a Viewport active-x object is a (0 . "VPORT")?
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-14 13:04 , Processed in 1.290667 second(s), 73 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表