|

楼主 |
发表于 2010-2-4 22:14:26
|
显示全部楼层
;;;--------------------------------------------------------------------;
;;;
;;; FOXDIM.LSP Version 1.02
;;;
;;; (C) Copyright 1997 by College of Mechanical & Automotive
;;; Engineering(MAE), Hunan University.
;;;
;;; This program is copyrighted by MAE. and is licensed to
;;; you under the following conditions. You may not distribute
;;; or publish the source code of this program in any form. You
;;; may incorporate this code in object form in derivative works
;;; provided such derivative works are (i.) are designed and
;;; intended to work solely with MAE products, and (ii.) contain
;;; MAE's copyright notice "(C) Copyright 1997 by College of
;;; Mechanical & Automotive Engineering."
;;;
;;; MAE PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
;;; MAE SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF MER-
;;; CHANTABILITY OR FITNESS FOR A PARTICULAR USE. MAE DOES
;;; NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
;;; UNINTERRUPTED OR ERROR FREE.
;;;
;;; by Lu Yuanzhi, Zuo Feiyan.
;;; Nov. 28, 1997
;;; Tel: 086-731-8822994, or 086-731-8822125
;;;
;;;--------------------------------------------------------------------;
;;; DESCRIPTION
;;;
;;; REVISION
;;;
;;; At Foxconn(Shenzhen), on April 15, 1998.
;;;
;;;--------------------------------------------------------------------;
;(defun c:cancel(/ ctrl)
; (initget "y Y n N")
; (setq ctrl (getkword "\nThis will undo EVERYTHING, OK ?(y/n):"))
; (if (or (= ctrl "y") (= ctrl "Y"))
; (command "undo" "back")
; )
;)
(defun c:cancel(/ ent er_ed er_layer er_type pt1 pt2 er_all
old_cmdecho old_osmode old_blipmode)
(setq old_cmdecho (getvar "cmdecho")
old_osmode (getvar "osmode")
old_blipmode (getvar "blipmode")
)
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(setvar "blipmode" 0)
(setq ent (car (entsel
"\nPlease pick the DIMENSION or TEXT OBJECT to erase:")) )
(if (/= ent nil) (progn
(setq er_ed (entget ent))
(setq er_layer (cdr (assoc '8 er_ed))
er_type (cdr (assoc '0 er_ed)) )
(if (or (= er_type "DIMENSION") (= er_type "TEXT")) (progn
(setq pt1 (getpoint "\nPlease pick the FIRST corner:")
pt2 (getpoint "\nPlease pick the OTHER corner:")
)
(setq er_all (ssget "wp" (list pt1 (list (car pt2) (cadr pt1))
pt2 (list (car pt1) (cadr pt2)) pt1)
(list (cons 0 er_type) (cons 8 er_layer)) ))
(command "erase" er_all "")
) ;end progn
(alert "\nError: Objects are not the DIMENSION or TEXT ! ")
) ;end if "TEXT"
);end progn
(alert "\nError: Objects are not the DIMENSION or TEXT ! ")
);end if er_ed
(setvar "osmode" old_osmode)
(setvar "blipmode" old_blipmode)
(setvar "cmdecho" old_cmdecho)
(princ "\n\tOK")
(princ)
) ;end defun c:cancel 980414
;;**********************************************************************
;; The sub_procedure notes dimension of the circle in the certain
;; center area of the drawing.
;; "x0","y0" is the coordinate of circle to be noted .
;; If switch is "tb_row", then note the dimensions of
;; coordinate "y" in horizontal.
;; If switch is "tb_col", then note the dimensions of
;; coordinate "x" in vertical.
;;**********************************************************************
(defun dim_in(x0 y0 r decimal_sum switch / list_dalt_x list_dalt_y
x00 y00 j x y dim_x dim_y dalt_x dalt_y text_center_x
text_center_y loop integer_sum)
; (setq x00 (abs (- x0 (car pt_preference)))
; y00 (abs (- y0 (cadr pt_preference))) ;luyz 1998
; ) ;dimension text
(setq x00 (- x0 (car pt_preference))
y00 (- y0 (cadr pt_preference))
)
(setq j 0)
(while (< j m_hole_sum)
(setq x (car (nth j tb_m_hole))
y (last (nth j tb_m_hole))
)
(if (and (< (abs (- x x0)) 0.00001) (< (abs (- y y0)) 0.00001))
(setq decimal_sum 1)
)
(setq j (+ j 1))
);end while if it is m_hole
(setvar "dimdec" decimal_sum) ;lu 980414
;
; Try 7 times at different positions, if not confict with another
; circle & dimesion, Note the dimension at the position, if confict
; at all the position, note the dimension at default position,
; evenly the first position.
;
(setq j 0
loop T
)
(if (= switch "tb_row") ;y dimension
(progn
;
; calculate the textwidth of the dimension.
;
(cond ((< (abs y00) 100)
(setq integer_sum 2)
);end cond 1
((and (>= (abs y00) 100) (< (abs y00) 1000))
(setq integer_sum 3)
);end cond 2
((>= (abs y00) 1000)
(setq integer_sum 4)
);end cond 3
);end cond
(setq textwidth (* (+ integer_sum decimal_sum) textheight))
;
; select the blank position to note automaticly.
;
(while (and (< j 11) loop)
(setq list_dalt_x (car (nth j list_dalt_row))
list_dalt_y (last (nth j list_dalt_row))
)
(if (> list_dalt_x 0) ;left side
(setq dim_x (+ (+ x0 r) list_dalt_x)
dim_y (+ y0 list_dalt_y)
;
; "dim_x" "dim_y" is the coordinate of the endpoint
; of the dimension.
;
text_center_x (+ dim_x (/ textwidth 2))
text_center_y dim_y
;
; "text_center_x" "text_center_y" is the coordinate
; of the centerpoint of the dimension's text.
;
)
;else inner
(setq dim_x (+ (- x0 r) list_dalt_x)
dim_y (+ y0 list_dalt_y)
text_center_x (- dim_x (/ textwidth 2))
text_center_y dim_y
)
);end if
;
; Determine if conflict with others.
;
(crash_in text_center_x text_center_y "tb_row")
(if (= crashed "n")
(progn
; (command "dim1" "ord" (list x0 y0) "y" (list dim_x dim_y)
; (rtos y00 2 decimal_sum))
(setq dim_x00 (- dim_x (car pt_preference))
dim_y00 (- dim_y (cadr pt_preference)) )
(command "dim1" "ord" (list x00 y00) "y" (list dim_x00 dim_y00) ""
"move" "last" "" '(0 0 0) pt_preference)
;
; Record the coordinate of the center_pointer of
; the dimension's text.
;
(setq tb_in_row (cons (list text_center_x text_center_y) tb_in_row))
(setq loop nil)
)
;
; else If all of the position is inavailable , then
; note the dimension at first position.
;
(if (= j 10) ;crashed !!
(progn
; (command "dim1" "ord" (list x0 y0) "y" (list dim_x dim_y)
; (rtos y00 2 decimal_sum))
(setq dim_x00 (- dim_x (car pt_preference))
dim_y00 (- dim_y (cadr pt_preference)) )
(command "dim1" "ord" (list x00 y00) "y" (list dim_x00 dim_y00) ""
"move" "last" "" '(0 0 0) pt_preference)
(setq conflicted_sum (+ conflicted_sum 1))
(setq tb_in_row (cons (list text_center_x text_center_y) tb_in_row))
)
);end if j=10
);end if crashed |
|