14
122
108
初露锋芒
使用道具 举报
0
33
初来乍到
;;------------------------------------------------;; Programmer's Tool Box Feb 1996;; CADENCE MAGAZING: Bill Kramer;; Dimension Edits and Checking;;;;------------------------------------------------;; LISTING 1: MAIN FUNCTION C:DIMCHK;;------------------------------------------------(defun C:DIMCHK ( / DIML ;dimension layer name TOL ;tolerance value SS1 ;selection set II ;index into pick set JJ ;index to distances D1 ;distances list D2 ;found flag P1 P2 ;points of dim entity TY TX ;type / text XB ;text block of dim XT ;text in text block VAL ;value of dim text EL EN) ;entity list and name (prompt "\nDIMCHK: Check associative dimension values") (while (null DIML) (setq DIML (getstring "\nLayer name for dimensions: ")) (if (or (= DIML "") (null (tblsearch "LAYER" DIML))) (setq DIML ;;nil (prompt "\nLayer does not exist!")) ) ) (setq TOL (getdist "\nEnter tolerance <0.001>: ")) (if (null TOL) (setq TOL 0.001)) (setvar "CMDECHO" 0) (if (null (tblsearch "LAYER" "DIM_BAD")) (command "_LAYER" "_N" "DIM_BAD,DIM_OUTTOL" "_C" "YELLOW" "DIM_OUTTOL" "_C" "RED" "DIM_BAD" "") ) (setq SS1 (ssget "X" (list (cons 8 DIML)))) (if SS1 (progn (setq II 0) (repeat (sslength SS1) (if (GET_DIM_DATA) (progn (setq JJ 1 D2 nil) (if (DIM_VALUES) (DIM_VALUE_CHECK)) (redraw EN) ) (prompt " unable to translate text.")) );;end REPEAT ) (prompt "\nNothing found!") ) (princ));;------------------------------------------------;; Listing 2: Retrieve entity information into ;; global variables used by remainder of function;; set.;;(defun GET_DIM_DATA () (setq EN (ssname SS1 II) II (1+ II) EL (entget EN) ) (redraw EN -3) (cond ((= (cdr (assoc 0 EL)) "DIMENSION") (setq P10 (cdr (assoc 10 EL)) P13 (cdr (assoc 13 EL)) P14 (cdr (assoc 14 EL)) P15 (cdr (assoc 15 EL)) TY (cdr (assoc 70 EL));;type TX (cdr (assoc 1 EL)) ;;text XB (cdr (assoc 2 EL)) ;;block name XT (BLOCK_TEXT XB) ;;text in block ) ;;check to see if dimension location flag ;;is set. Remove if found. (if (> TY 70) (setq TY (- TY 128))) ;; (if (or (= TX "") ;;nothing in text or (wcmatch TX "*<>*")) ;;variable (progn ;;then look in block (prompt "\nAssociative dim,") (setq VAL XT) ) (progn ;;else look in text (prompt "\nAssoc w/ text override,") (setq VAL TX) ) ) ;;Convert VAL to distance value (setq VAL (distof (Convert_Mtext_Dim VAL))) ) (t (prompt "\nNon-associative dimension object: ") (prompt (cdr (assoc 0 EL))) ) ));;------------------------------------------------;; Listing 3: Calculate dim distances;;(defun DIM_VALUES ( / TYP) (setq TYP (logand TY 7))