找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1554|回复: 7

[求助] [求助]:能否通过LISP,使透明命令('zoom、'pan)更加简便好用

[复制链接]
发表于 2005-11-5 21:46:00 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
能否通过LISP,使透明命令('zoom、'pan)更加好用。例如:在move命令提示“指定基点或位移:”或“指定位移的第二点或 <用第一点作位移>”下,输入z并回车即等同于'zoom的功能。望高手指教,谢谢!
怎么没人理呢?郁闷!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2005-11-15 17:17:40 | 显示全部楼层
没人理是因为这个问题不好回答!我和你一起期待关注高手们的解答。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2005-11-15 17:34:23 | 显示全部楼层

Re: [求助]:能否通过LISP,使透明命令('zoom、'pan)更加简便好用

最初由 hsslyl 发布
[B]能否通过LISP,使透明命令('zoom、'pan)更加好用。例如:在move命令提示“指定基点或位移:”或“指定位移的第二点或 <用第一点作位移>”下,输入z并回车即等同于'zoom的功能。望高手指教,谢谢!
怎么没人理呢??.. [/B]

鼠标滚轮是干吗使的!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 8157个

财富等级: 富甲天下

发表于 2005-11-15 17:35:13 | 显示全部楼层
Jon Fleming
May 28 2002, 8:38 pm   show options

Newsgroups: autodesk.autocad.customization
From: Jon Fleming <j...@fleming-group.com> - Find messages by this author  
Date: Tue, 28 May 2002 05:25:22 -0700
Local: Tues, May 28 2002 8:25 pm  
Subject: Re: Using Transparent command within a command in AutoLISP
Reply to Author | Forward | Print | Individual Message | Show original | Report Abuse  

You have to use ActiveX methods:


(vl-load-com)


;;; Workaround for (vlax-add-cmd) bug.
;;; by Stephan Koster


;; Comments by JRF: This code should be
;;; run before adding any other commands with vlr-add-cmd.
;;; Otherwise, when using added commands in multiple documents
;;; (MDI mode), sometimes the commands fail with a "Visual LISP
;;; command document mismatch" error.  Apparently vlax-add-cmd
;;; must be called in a document in order to activate commands
;;; in that document.
(defun DummyCommand () NIL)
(vlax-add-cmd "DummyCommand" 'DummyCommand)
(defun AddCommandsHelper (a b)
  (vlax-add-cmd "DummyCommand" 'DummyCommand)
)
;; Install dummy command reactor only if it's not
;; defined already
(or DummyCommandReactor
    (setq DummyCommandReactor
           (vlr-docmanager-reactor
             NIL
             '((:vlr-documentBecameCurrent . AddCommandsHelper))
           )
    )
)


;;; Two-letter aliases for zooms:


;;; First a wrapper function for zooming using ActiveX methods.
;;; If necessary, first switches to paper space.  Does the zoom.
;;; If necessary, switches back to model space.


;;; Argument:
;;;   A quoted function to actually do the zoom.  It may use the
;;;   variables AcadObject and ActiveDocumentObject, which will be
;;;   set appropriately by the ZoomWrapper function.


(defun ZoomWrapper (ZoomFunction / SwitchBack OldViewport AcadObject
                    ActiveDocumentObject
                   )
  (setq AcadObject           (vlax-get-acad-object)
        ActiveDocumentObject (vlax-get-property
                                AcadObject "ActiveDocument")
  )
  ;; If we're in a model space viewport in paper space and that
  ;; viewport's display is locked (saving the currently active viewport
  ;; in case it's needed later) ...
  (if (and (= (getvar "TILEMODE") 0)
           (/= (getvar "CVPORT") 1)
           (equal :vlax-true
                  (vlax-get-property
                    (setq OldViewport
                           (vlax-get-property
                             ActiveDocumentObject
                             "ActivepViewport"
                           )
                    )
                    "DisplayLocked"
                  )
           )
      )
    ;; Set a flag to switch back later, and switch to paper space
    (progn
      (setq SwitchBack T)
      (vlax-put-property
        ActiveDocumentObject
        "MSpace"
        :vlax-false
      )
    )
  )
  ;; Do the zoom
  (eval ZoomFunction)
  ;; If we need to switch back to model space ...
  (if SwitchBack
    ;; Do it
    (progn
      (vla-Display OldViewport :vlax-true)
      (vlax-put-property ActiveDocumentObject "MSpace" :vlax-true)
    )
  )
)


(defun ZoomAll ()
  (ZoomWrapper '(vla-ZoomAll AcadObject))
  (princ)
)
(vlax-add-cmd "ZA" 'ZoomAll "ZA" ACRX_CMD_TRANSPARENT)


(defun ZoomCenter (/ Magnification)
  (ZoomWrapper
    '(vla-ZoomCenter
      AcadObject
      (vlax-3d-point
       (trans (getpoint "\nSpecify center point: ") 1 0)
      )
      (if
       (setq
        Magnification
        (getreal
         (strcat
          "\nEnter magnification or height <"
          (rtos (getvar "VIEWSIZE"))
          ">: "
         )
        )
       )
       (vlax-make-variant Magnification vlax-vbDouble)
       (vlax-make-variant (getvar "VIEWSIZE") vlax-vbDouble)
      )
     )
  )
  (princ)
)
(vlax-add-cmd "ZC" 'ZoomCenter "ZC" ACRX_CMD_TRANSPARENT)


;;; Because there's no vla-ZoomDynamic,we have to use a kludge
;;; that works except you can't repeat it by hitting <Enter>;
;;; hitting <Enter> repeats the ZOOM command.
(defun ZoomDynamic ()
  (vla-SendCommand
    (vla-Get-ActiveDocument
      (vlax-get-acad-object)
    )
    "'._Zoom _D "
  )
  (princ)
)
(vlax-add-cmd "ZD" 'ZoomDynamic "ZD" ACRX_CMD_TRANSPARENT)


(defun ZoomExtents ()
  (ZoomWrapper '(vla-ZoomExtents AcadObject))
  (princ)
)
(vlax-add-cmd "ZE" 'ZoomExtents "ZE" ACRX_CMD_TRANSPARENT)


;;; Because there's no vla-ZoomVMAX,we have to use a kludge
;;; that works except you can't repeat it by hitting <Enter>;
;;; hitting <Enter> repeats the ZOOM command.
(defun ZoomVMAX ()
  (vla-SendCommand
    (vla-Get-ActiveDocument
      (vlax-get-acad-object)
    )
    "'._Zoom _VMAX "
  )
  (princ)
)
(vlax-add-cmd "ZM" 'ZoomVMAX "ZM" ACRX_CMD_TRANSPARENT)


(defun ZoomPrevious ()
  (ZoomWrapper '(vla-ZoomPrevious AcadObject))
  (princ)
)
(vlax-add-cmd "ZP" 'ZoomPrevious "ZP" ACRX_CMD_TRANSPARENT)


(defun ZoomWindow (/ FirstCorner)
  (ZoomWrapper
    '(vla-ZoomWindow
      AcadObject
      (vlax-3d-point
       (trans
        ;; When the first point is picked, the crosshairs will
        ;; align with the current UCS ... I don't see a simple
        ;; way around that.
        (setq FirstCorner (getpoint "\nSpecify first corner: "))
        1
        0
       )
      )
      (vlax-3d-point
       (trans
        (getcorner FirstCorner "Specify opposite corner: ")
        1
        0
       )
      )
     )
  )
  (princ)
)
(vlax-add-cmd "ZW" 'ZoomWindow "ZW" ACRX_CMD_TRANSPARENT)


(defun ZoomHalf ()
  (ZoomWrapper
    '(vla-ZoomScaled
      AcadObject
      (vlax-make-variant 0.5 vlax-vbDouble)
      acZoomScaledRelative
    )
  )
  (princ)
)
(vlax-add-cmd "Z5" 'ZoomHalf "Z5" 1)
(vlax-add-cmd "ZH" 'ZoomHalf "ZH" 1)


(defun ZoomTwice ()
  (ZoomWrapper
    '(vla-ZoomScaled
      AcadObject
      (vlax-make-variant 2.0 vlax-vbDouble)
      acZoomScaledRelative
    )
  )
  (princ)
)
(vlax-add-cmd "Z2" 'ZoomTwice "Z2" ACRX_CMD_TRANSPARENT)


jrf
Member of the Autodesk Discussion Forum Moderator Program
Please do not email questions unless you wish to hire my services
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2005-11-15 20:36:57 | 显示全部楼层
一般来说,我都是用autohook来完成这些操作的
感觉autolisp在定义功能键还是比较麻烦
比如用autohook定义F1为'z d ,就连按空格键或者鼠标右键都不需要了
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 1个

财富等级: 恭喜发财

发表于 2005-11-15 20:57:14 | 显示全部楼层
我用autohook主要是来搞定逗号,不然在输入坐标的时候,太痛苦了。
楼主若只是针对'zoom、'panr的话,用鼠标的中键就能解决,若是想广义的解决这一类问题的话,还得再讨论讨论。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2005-11-15 23:18:45 | 显示全部楼层
好像讨论过,是不可以的
而且会引起混乱
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2005-11-16 20:57:15 | 显示全部楼层
要是可以在cad中抛开autohook就好了,因为hook有个麻烦,就是定义的字母键再不能和其他的字母组合了,而且也不能用两个字母组合成命令。用dvb可以实现就好了,比如:Sub d()
'Zoom .3x
End Sub
(语法是错的)就象cad的内部命令一样,d键这时还可以同其他组合:ds、gd等,这是个想法。要是可以办的,我想cad同仁会皆大欢喜的,可惜这需要高手才知道可不可以办到了。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2025-9-28 19:01 , Processed in 0.281719 second(s), 46 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表