乐筑天下

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

[编程交流] zoom & pan in MDI

[复制链接]

29

主题

36

帖子

6

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
150
发表于 2022-7-6 12:03:39 | 显示全部楼层 |阅读模式
Reply
I want to write a program working in such that when I zoom or pan window A, view in window B also changes accordingly. I have written the following code so far. It is 2 lisp files first.lsp & second.lsp. One is loaded in one of the drawings and the other in the second one.
 
 
 
  1. (defun c:first()(vl-load-com); Access autocad application object.(setq app(vlax-get-acad-object)); Access the documents collection.(setq docs(vlax-get-property app "documents")) ; Access the targed drawings.(setq doc1(vla-item docs 0))(setq doc2(vla-item docs 1)); Set command reactor to monitor pan command.(vlr-command-reactor nil '((:vlr-commandended . checkPan)))); Check if a pan command is performed in the current drawing.(defun checkPan(reactorObj cmdInfo); Get the name of the command ended.(setq cmd(nth 0 cmdInfo))(setq center (getvar "viewctr"))(setq height (getvar "viewsize"))(setq ratio (getvar "screensize"))(setq width (* height (/ (car ratio)(cadr ratio))))(setq wseg (/ width 2.0))(setq hseg (/ height 2.0));find screen corners(Setq ll (list (- (car center) wseg)(- (cadr center) hseg)))(Setq ur (list (+ (car center) wseg)(+ (cadr center) hseg)))(Setq ul (list (- (car center) wseg)(+ (cadr center) hseg)))(Setq lr (list (+ (car center) wseg)(- (cadr center) hseg)))(setq ll(vlax-3d-point ll))(setq ur(vlax-3d-point ur))(vla-activate doc2))*************************************************************************; To zoom/pan second drawing as we zoom/pan first one.(defun c:second()(vl-load-com); Set command reactor to monitor pan command.(vlr-docmanager-reactor nil '((:vlr-documentBecameCurrent . panView)))); Check if a pan command is performed in the current drawing.(defun panView(reactorObj cmdInfo)(vla-zoomwindow (vl-bb-ref 'appRef) (vlax-3d-point(vl-bb-ref 'a)) (vlax-3d-point(vl-bb-ref 'b))) ;(vla-regen (vl-bb-ref 'doc2Ref) acActiveViewPort)(vla-activate (vl-bb-ref 'doc1Ref)))
 
 
 
It is working and changes the view in the second drawing, but the problem is that the vla-activate function is not working in any of the lisp routines and I
 
have to manually click the title bar of a window to make it activate after which the view automatically changes. Please guide about this issue. Secondly I want
 
to be able to intercept tranparent zom and pan commands, otherwise I have to manually issue PAN and ZOOM commands for these lisp routines to work.
回复

使用道具 举报

1

主题

316

帖子

311

银币

初来乍到

Rank: 1

铜币
29
发表于 2022-7-6 13:24:52 | 显示全部楼层
try vla-put-activedocument
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-5 10:37 , Processed in 0.373876 second(s), 56 queries .

© 2020-2025 乐筑天下

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