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

📄 dimex.lsp

📁 Autocad-2005-简体中文-解密版.zip
💻 LSP
📖 第 1 页 / 共 3 页
字号:
;;;                                                                    ;
;;;  DIMEX.LSP                                                         ;
;;;                                                                    ;
;;;  Copyright 1987, 1988, 1990, 1992, 1994, 1996, 1997, 1998, 1999    ;
;;;  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.                            ;
;;;                                                                    ;

;;;--------------------------------------------------------------------;
;;; General Note:  THIS FILE IS A MEMBER OF THE REAC-TST PROJECT       ;
;;;--------------------------------------------------------------------;
;;;	This file contains an Active DIMENSION example.                ;
;;;	This program creates a red circle and an                       ;
;;;	associated dimension. You will be prompted                     ;
;;;	to select the center and radius of the circle.                 ;
;;;	When the circle radius changes, the MTEXT                      ;
;;;	dimension also changes. Conversely, when you                   ;
;;;	change the value of the MTEXT dimension, the                   ;
;;;	circle radius will change.                                     ;
;;;                                                                    ;
;;;                                                                    ;
;;; Active DIMENSION Radial                                            ;
;;; You first bind a CIRCLE or ARC with DIMENTION                      ;
;;; When the circle radius changes the MTEXT in the dimension changes  ;
;;; as well and when you change the number in MTEXT                    ;
;;; the radius will be changed                                         ;
;;;--------------------------------------------------------------------;

;;;--------------------------------------------------------------------;
;;;       Function:  CREATE-DIM                                        ;
;;;                                                                    ;
;;;    Description:  This function creates a dimension object and      ;
;;;                  an mtext object.                                  ;
;;;                                                                    ;
;;;      Arguments:                                                    ;
;;;         ins-pnt = a valid list of 3 reals.                         ;
;;;           width = width of the mtext.                              ;
;;;            text = string value for the mtext                       ;
;;;     coordinates = a list of numbers representing the leader        ;
;;;                   coordinates. such as:                            ;
;;;                   (38.3776 106.162 0.0 38.3776                     ;
;;;                     117.066 0.0 49.2812 127.97 0.0)                ;
;;;                                                                    ;
;;; Returned Value:  A list comprising of a vla-mtextobject and a      ;
;;;                  vla-eader-object. Such as:                        ;
;;;                    (vla-mtext vla-leader)                          ;
;;;                                                                    ;
;;;          Usage:                                                    ;
;;;              (create-dim                                           ;
;;;                 '(49.2812 127.97 0.0)                              ;
;;;                    2.72591                                         ;
;;;                    10.9037                                         ;
;;;                   '(38.3776 106.162 0.0 38.3776                    ;
;;;                     117.066 0.0 49.2812 127.97 0.0)                ;
;;;               )                                                    ;
;;;--------------------------------------------------------------------;
(defun create-dim
		  (ins-pnt    width	 text	    Coordinates
		   /	      acadApp	 acadDoc    acadMode
		   vla-mtext ptlstlen PointDataA PointData
		  )
  (princ (list ins-pnt    width	 text	    Coordinates))
  (if (not (= (type text) 'STR))
    (setq text "TEXT")
  )

(setq ptlstlen (length Coordinates))
(setq PointDataA (vlax-make-safearray vlax-vbDouble (cons 0 (1- ptlstlen))))
(vlax-safearray-fill PointDataA Coordinates)
(setq PointData (vlax-make-variant PointDataA (logior vlax-vbarray vlax-vbDouble)))

  (setq	acadApp	   (vlax-get-acad-object)
	acadDoc	   (vla-get-ActiveDocument acadApp)
	acadModel  (vla-get-ModelSpace acadDoc)
	vla-mtext  (vla-AddMtext acadModel (vlax-3d-point ins-pnt) width text)
	vla-leader (vla-AddLeader
		     acadModel
		     PointData  ;;Coordinates
		     vla-mtext
		     acLineNoArrow
		   )
  )
  (list vla-mtext vla-leader)
)

;;;--------------------------------------------------------------------;
;;;       Function:  CREATE-DIM-FOR-CIRCLE                             ;
;;;                                                                    ;
;;;    Description:  This updates a vla dimension object.              ;
;;;                                                                    ;
;;;                  Required Functions:                               ;
;;;                       set-dim-params-for-circle                    ;
;;;                       create-dim                                   ;
;;;                       update-parameter-mdim                        ;
;;;                                                                    ;
;;;      Arguments:                                                    ;
;;;      vla-circle = a valid vla circle object.                       ;
;;;                                                                    ;
;;; Returned Value:  A vla-dimension-object.                           ;
;;;                                                                    ;
;;;          Usage:                                                    ;
;;;              (create-dim-for-circle                                ;
;;;                 vla-circle-object                                  ;
;;;               )                                                    ;
;;;--------------------------------------------------------------------;
(defun create-dim-for-circle
			     (vla-circle  /	      ins-pnt
			      width	  text	      vla-dim
			      vla-leader  center      height
			      Coordinates
			     )
  (set-dim-params-for-circle vla-circle)
  (setq vla-dim (create-dim ins-pnt width text Coordinates))
  (update-parameter-mdim (car vla-dim) "height" height)
  (update-parameter-mdim
    (cadr vla-dim)
    "Coordinates"
    Coordinates
  )
  vla-dim
)

;;;--------------------------------------------------------------------;
;;;       Function:  SET-DIM-PARAMS-FOR-CIRCLE                         ;
;;;                                                                    ;
;;;    Description:  This function sets the parameters required        ;
;;;                  to associate a dimension object to the circle.    ;
;;;                                                                    ;
;;;                  defines global parameters:                        ;
;;;                        center                                      ;
;;;                        width                                       ;
;;;                        text                                        ;
;;;                        ins-pnt                                     ;
;;;                        height                                      ;
;;;                        Coordinates                                 ;
;;;                                                                    ;
;;;                                                                    ;
;;;      Arguments:                                                    ;
;;;      vla-circle = a valid vla circle object.                       ;
;;;                                                                    ;
;;; Returned Value:  coordinates to the leader object.                 ;
;;;                                                                    ;
;;;          Usage:                                                    ;
;;;              (set-dim-params-for-circle                            ;
;;;                 vla-circle-object                                  ;
;;;               )                                                    ;
;;;--------------------------------------------------------------------;
(defun set-dim-params-for-circle
       (vla-circle / delta lead-pnt1 lead-pnt2 lead-pnt3)
  (if (and (= (type vla-circle) 'VLA-OBJECT)
	   (vlax-read-enabled-p vla-circle)
      )
       (progn
        (setq center  (vla-get-center vla-circle))
        (if (eq (type center) 'VARIANT)
            (if (> (vlax-variant-type center) 8192)
               (setq center (vlax-safearray->list (vlax-variant-value center)))
            )
        )

⌨️ 快捷键说明

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