⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gpreact.lsp

📁 Autocad-2005-简体中文-解密版.zip
💻 LSP
📖 第 1 页 / 共 2 页
字号:
;;;                                                                    ;
;;;  GPREACT.LSP                                                       ;
;;;                                                                    ;
;;;  Copyright 1987, 1988, 1990, 1992, 1994, 1996, 1997, 1998          ;
;;;  by Autodesk, Inc. All Rights Reserved.                            ;
;;;                                                                    ;
;;;  You are hereby granted permission to use, copy and modify this    ;
;;;  software without charge, provided you do so exclusively for       ;
;;;  your own use or for use by others in your organization in the     ;
;;;  performance of their normal duties, and provided further that     ;
;;;  the above copyright notice appears in all copies and both that    ;
;;;  copyright notice and the limited warranty and restricted rights   ;
;;;  notice below appear in all supporting documentation.              ;
;;;                                                                    ;
;;;  Incorporation of any part of this software into other software,   ;
;;;  except when such incorporation is exclusively for your own use    ;
;;;  or for use by others in your organization in the performance of   ;
;;;  their normal duties, is prohibited without the prior written      ;
;;;  consent of Autodesk, Inc.                                         ;
;;;                                                                    ;
;;;  Copying, modification and distribution of this software or any    ;
;;;  part thereof in any form except as expressly provided herein is   ;
;;;  prohibited without the prior written consent of Autodesk, Inc.    ;
;;;                                                                    ;
;;;  AUTODESK PROVIDES THIS SOFTWARE "AS IS" AND WITH ALL FAULTS.      ;
;;;  AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF           ;
;;;  MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK,       ;
;;;  INC. DOES NOT WARRANT THAT THE OPERATION OF THE SOFTWARE          ;
;;;  WILL BE UNINTERRUPTED OR ERROR FREE.                              ;
;;;                                                                    ;
;;;  Restricted Rights for US Government Users.  This software         ;
;;;  and Documentation are provided with RESTRICTED RIGHTS for US      ;
;;;  US Government users.  Use, duplication, or disclosure by the      ;
;;;  Government is subject to restrictions as set forth in FAR         ;
;;;  12.212 (Commercial Computer Software-Restricted Rights) and       ;
;;;  DFAR 227.7202 (Rights in Technical Data and Computer Software),   ;
;;;  as applicable.  Manufacturer is Autodesk, Inc., 111 McInnis       ;
;;;  Parkway, San Rafael, California 94903.                            ;
;;;                                                                    ;

;;;--------------------------------------------------------------------;
;;;  This file is from the Garden Path tutorial, and represents the    ;
;;;  final state of the application at the end of Lesson 7.  Use this  ;
;;;  file to check your work.                                          ;
;;;--------------------------------------------------------------------;


;;;--------------------------------------------------------------------;
;;;  General Notes:                                                    ;
;;;--------------------------------------------------------------------;
;;;  After the execution of these reactor functions, you might         ;
;;;  experience difficulty in returning to Visual Lisp.  If this does  ;
;;;  happen, type VLide at the AutoCAD command prompt and focus will   ;
;;;  be returned to Visual Lisp.                                       ;
;;;--------------------------------------------------------------------;
;;;  There are three types of reactors which we will be using:         ;
;;;          1. an object reactor                                      ;
;;;          2. a command reactor                                      ;
;;;          3. a drawing reactor                                      ;
;;;  We will define two functions that will notify us when the user    ;
;;;  has modified or changed the garden path.                          ;
;;;--------------------------------------------------------------------;
;;; Object Reactor                                                     ;
;;;----------------------|---------------------|-----------------------;
;;; Event                |Function to call     | Description           ;
;;;----------------------|---------------------|-----------------------;
;;; :vlr-modified        |gp:outline-changed   | Function called       ;
;;;                      |                     | when object declared  ;
;;;                      |                     | in owners is modified ;
;;;----------------------|---------------------|-----------------------;
;;; :vlr-erased	         |gp:outline-erased    | Function called       ;
;;;                      |                     | when object is erased ;
;;;----------------------|---------------------|-----------------------;
;;;                                                                    ;
;;; Command Reactor                                                    ;
;;;----------------------|---------------------|-----------------------;
;;; Event                |Function to call     | Description           ;
;;;----------------------|---------------------|-----------------------;
;;; :vlr-commandWillStart|gp:command-will-start| Function called when  ;
;;;                      |                     | a command is typed    ;
;;;                      |                     | at the command prompt ;
;;;----------------------|---------------------|-----------------------;
;;; :vlr-commandEnded	 |gp:command-ended     | Function called when  ;
;;;                      |                     | a command has ended   ;
;;;----------------------|---------------------|-----------------------;
;;;                                                                    ;
;;; Drawing Reactor                                                    ;
;;;----------------------|---------------------|-----------------------;
;;; Event                |Function to call     | Description           ;
;;;----------------------|---------------------|-----------------------;
;;; :vlr-beginClose      |gp:clean-all-reactors| Function to clean all ;
;;;                      |                     | existing reactors     ;
;;;                      |                     | before ACAD exits     ;
;;;--------------------------------------------------------------------;
;;; Since reactor events occur in sequence (commandWillStart occuring  ;
;;; before the object modified reactor, for example), we need a few    ;
;;; global variables to keep track of what changes are occuring to the ;
;;; path.  The following globals are used:                             ;
;;;          *lostAssociativity*                                       ;
;;;          *polyToChange*                                            ;
;;;          *reactorsToRemove*                                        ;
;;;          *reactorToChange*                                         ;
;;;          *Safe-to-Delete*                                          ;
;;;--------------------------------------------------------------------;


;;;--------------------------------------------------------------------;
;;;     Function: Gp:Safe-Delete                                       ;
;;;--------------------------------------------------------------------;
;;;  Description: This function is used to clean-up (erase) any objects;
;;;               that have not been erased in a previous command/     ;
;;;               reactor sequence.  This function is called only from ;
;;;               the :vlr-commandEnded reactor event callback function;
;;;               gp:Command-ended.  Items (tiles) to delete are       ;
;;;               collected within the global variable *Safe-to-Delete*;
;;;--------------------------------------------------------------------;
;;;  The parameter activeCommand is the name of the command that has   ;
;;;  just ended.  Because of the command/reactor sequence within any of;
;;;  the GRIP_* commands, entity may only be done if the command is NOT;
;;;  a GRIP_* command.                                                 ;
;;;--------------------------------------------------------------------;
(defun Gp:Safe-Delete (activeCommand / owner trl)
  (if (not (equal
	     (strcase (substr activeCommand 1 5))
	     "GRIP_"
	     )
	   )
    (progn
      (if *Safe-to-Delete*
	(foreach Item *Safe-to-Delete*
	  (if (not (vlax-erased-p Item))
	    (vla-erase item)
	    )
	  )
	)
    (setq *Safe-to-Delete* nil)

    (setq trl (assoc :VLR-OBJECT-REACTOR (vlr-reactors)))

    (if trl (setq trl (cdr trl)))
      (while trl
        (progn
          (foreach owner *OwnerReactorsToRemove*
	        (if owner
              (vlr-owner-remove (car trl) owner)
	        )
          )
          (setq trl (cdr trl))
        )
      )

    )
  )
)



;;;--------------------------------------------------------------------;
;;;     Function: gp:erase-tiles                                       ;
;;;--------------------------------------------------------------------;
;;;  Description: A utility function for erasing all of the tiles in a ;
;;;               garden path.                                         ;
;;;--------------------------------------------------------------------;
;;;  The parameter "reactor" passed to this function is a pointer to a ;
;;;  reactor associated with a garden path.  This reactor should have  ;
;;;  reactor data stored within it which contains VLA-object ID's for  ;
;;;  each of the tiles (circles) within the path.  By retrieving this  ;
;;;  data, the tiles can be erased.                                    ;
;;;  After erasing the tiles, a nil value is put back into the reactor ;
;;;  data (otherwise, the reactor would have bad pointers to tiles that;
;;;  have just been erased.)                                           ;
;;;--------------------------------------------------------------------;
(defun gp:erase-tiles (reactor / reactorData tiles tile)
  (if (setq reactorData (vlr-data reactor))
    (progn
      ;; Tiles in the path are stored as data in the reactor
      (setq tiles (cdr (assoc 100 reactorData)))
      ;; Erase all the existing tiles in the path
      (foreach tile tiles
	(if (and (null (member tile *Safe-to-Delete*))
		 (not (vlax-erased-p tile))
		 )
	  (progn
	    (vla-put-visible tile 0)
	    (setq *Safe-to-Delete* (cons tile *Safe-to-Delete*))
	    )
	  )
	)
      (vlr-data-set reactor nil)
      )
    )
  )


;;;--------------------------------------------------------------------;
;;;     Function: gp:command-will-start                                ;
;;;--------------------------------------------------------------------;
;;;  Description: This is a reactor to any command starting            ;
;;;--------------------------------------------------------------------;
;;;  This is the function where we figure out what will be happening   ;
;;;  to the garden path.  The various reactor globals are set to       ;
;;;  flag the changes that we expect to be made, so that subsequent    ;
;;;  reactor events will perform the correct actions.                  ;
;;;--------------------------------------------------------------------;
(defun gp:command-will-start (reactor command-list)
  ;; Reset all four reactor globals to nil
  (setq	*lostAssociativity*
	 nil
	*polyToChange*
	 nil
	*reactorsToRemove*
	 nil
	*reactorsToChange*
	 nil
	)
  (if (member (setq currentCommandName (car command-list))
	      '("U"	      "UNDO"	    "STRETCH"	  "MOVE"
		"ROTATE"      "SCALE"	    "BREAK"	  "GRIP_MOVE"
		"GRIP_ROTATE" "GRIP_SCALE"  "GRIP_MIRROR"
		)
	      )
    (progn
      (setq *lostAssociativity* T)
      (princ "\nNOTE: The ")
      (princ currentCommandName)
      (princ " command will break a path's associativity.")
      )
    )
  (princ)
  )



;;;--------------------------------------------------------------------;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -