home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BUG 15
/
BUGCD1998_06.ISO
/
aplic
/
felixcad
/
fcaddata.z
/
FLX_TCOR.LSP
< prev
next >
Wrap
Lisp/Scheme
|
1996-09-30
|
13KB
|
329 lines
;;; FLX_TCOR.LSP
;;; =====================================================================
;;; (C)opyright: Felix Computer Aided Technologies GmbH 1995-96
;;; Created: Jan 30,1995 vp
;;; Modified: Aug 30, 1996
;;; =====================================================================
;;; Command: TCORRECT
;;; This utility allows to correct text in the drawing.
;;; The user is prompted to select text objects to be modified.
;;; =====================================================================
(defun FLX_TCORRECT ( / prt_list luprec auprec lunits aunits angbase
textsize textfont
FINDFONT MODENT CHANGE_SINGLE CHANGE_GLOBAL
ss c n e w new ct os osl ns nsl ch s si tmp el)
;;; Prompt List
(setq prt_list (list
"Select text...\n" ;0
"Font" ;1
"Text Height" ;2
"Insertion Angle" ;3
"Qblique Angle" ;4
"Width Factor" ;5
"No or invalid entry in edit box: " ;6
"Alert" ;7
" text entities selected" ;8
"No text selected!" ;9
))
(if FLX_XLANGUAGE (FLX_XLANGUAGE "_tcor" nil))
;;; -------------------------------------------------------------------
(defun FINDFONT( / s1 lst)
(setq s1 (tblnext "STYLE" T))
(setq lst (list (cdr (assoc 2 s1))))
(while (setq s1 (tblnext "STYLE"))
(setq lst (append lst (list (cdr (assoc 2 s1)))))
)
(setq lst (reverse lst))
)
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;;; MODENT function to 'entmod' entity
;;; e = entity list / var = dotted pair index / new = new content/value
(defun MODENT (e var new)
(setq e (subst (cons var new) (assoc var e) e))
(entmod e)
)
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(defun CHANGE_GLOBAL (tmp)
;;; Replace Text
(if tmp (setq OS (caar tmp) NS (cadar tmp)))
(if OS (setq OSL (strlen OS) NSL (strlen NS)))
(if (and OSL (> OSL 0))
(progn
(setq c 0)
(repeat (sslength ss)
(setq ch nil
si 1
e (entget (ssname ss c))
s (cdr (assoc 1 e))
)
(if (member (cdr (assoc 0 e)) '("TEXT" "ATTDEF"))
(progn
(while (= osl (setq sl (strlen (setq st (substr s si osl)))))
(if (= st os)
(progn
(setq s (strcat (substr s 1 (1- si)) ns (substr s (+ si osl))))
(setq si (+ si nsl) ch T )
)
(setq si (1+ si)) ; else
)
)
(if ch (MODENT e 1 s))
)
)
(setq c (1+ c))
) ; repeat
)
)
; change other properties
(if (= (type (setq tmp (cadr tmp))) 'LIST) (progn
(setq c 0)
(repeat (sslength ss)
(setq e (entget (ssname ss c)))
(foreach el tmp (setq e (subst (cons (car el)(cadr el)) (assoc (car el) e ) e)) )
(entmod e)
(setq c (+ c 1))
)
))
) ; defun
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; MAIN
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(FLX_FUNC_INIT) ;;; Global Error Handler
(setq
lunits (getvar "LUNITS")
luprec (getvar "LUPREC")
aunits (getvar "AUNITS")
auprec (getvar "AUPREC")
angbase (getvar "ANGBASE")
textsize (getvar "TEXTSIZE")
textfont (getvar "TEXTSTYLE")
)
; object selection
(princ (nth 0 prt_list)) ;;;@Select text ...\n"
(setq selset (ssget))
(setq ss (ssadd) ss_index 0)
; reduced selection set
(repeat (sslength selset)
(setq ename (ssname selset ss_index))
(setq e (entget ename))
(if (member (cdr (assoc 0 e)) '("TEXT" "ATTDEF")) (ssadd ename ss))
(setq ss_index (1+ ss_index))
)
(setq selset nil)
(if (> (sslength ss) 0)
(progn
(princ (strcat (itoa (sslength ss)) (nth 8 prt_list) )) ;;; ###@" text entities selected"
(if (setq tmp (FLX_EDIT_GLOBAL))(CHANGE_GLOBAL tmp))
;;; ### if single
)
(princ (nth 9 prt_list)) ;;; @No text selected!
)
(FLX_FUNC_EXIT) (setq *error* nil)
(princ)
)
;;; ===========================================================================
;;; FLX_EDIT_GLOBAL
;;; ===========================================================================
(defun FLX_EDIT_GLOBAL ( / ret READCONTROLS SETMODE DlgInit)
(defun READCONTROLS ( / ret1 ret2 err2 tmp el)
;;; Text Font
(if (= (Dlg_TileGet "retain1") "0")(progn
(setq tmp (Dlg_TileGet "Font2"))
(if (tblsearch "STYLE" tmp)
(setq ret2 (append ret2 (list (list 7 tmp))))
(setq err2 (append err2 (list (nth 1 prt_list)))) ;;;@Font
)
))
;;; Text Size
(if (= (Dlg_TileGet "retain2") "0")(progn
(setq tmp (Dlg_TileGet "Height2"))
(setq tmp (distof tmp)) ;;; current unit system specification to float
(if (= tmp 0.00)
(setq err2 (append err2 (list (nth 2 prt_list)))) ;;;@Text Height
(setq ret2 (append ret2 (list (list 40 tmp))))
)
))
;;; Insertion Angle
(if (= (Dlg_TileGet "retain3") "0")(progn
(setq tmp (Dlg_TileGet "Angle2"))
(setq tmp (angtof tmp aunits)) ;;; current unit system; returns radians or nil
(if tmp
(setq ret2 (append ret2 (list (list 50 tmp))))
(setq err2 (append err2 (list (nth 3 prt_list)))) ;;;@Insertion Angle
)
))
;;; X Scale Factor
(if (= (Dlg_TileGet "retain5") "0")(progn
(setq tmp (Dlg_TileGet "Width2"))
(setq tmp (atof tmp))
(if (= tmp 0.00)
(setq err2 (append err2 (list (nth 5 prt_list)))) ;;;@Width Factor
(setq ret2 (append ret2 (list (list 41 tmp))))
)
))
;;; Slant Angle
(if (= (Dlg_TileGet "retain4") "0")(progn
(setq tmp (Dlg_TileGet "Oblique2"))
(setq tmp (angtof tmp 0)) ;;; decimal degrees, returns radians or nil
(if tmp
(setq ret2 (append ret2 (list (list 51 tmp))))
(setq err2 (append err2 (list (nth 4 prt_list)))) ;;;@Qblique Angle
)
))
(setq ret1 (list (Dlg_TileGet "Search")(Dlg_TileGet "Replace")))
(if (= (type err2) 'LIST)
(alert
(strcat
(nth 6 prt_list) ;;;@No or invalid entry in edit box:
(foreach el err2 (setq tmp (strcat tmp "\n" el)))
" !"
)
(nth 7 prt_list) ;;;@Alert
"EXCLAMATION"
)
(progn
(setq ret (list ret1 ret2))
(Dlg_DialogDone)
)
)
)
(defun SETMODE (x1 x2 / n)
(foreach n x1 (Dlg_TileMode n x2))
(Dlg_TileMode (cadr x1) 2)
)
(defun DlgInit ()
(if FLX$WIN95 (foreach n
'("IDCANCEL" "IDOK" "IDHELP" "Single"
"Static1" "Static2" "Static3" "Static4" "Static5"
"Font0" "Height0" "Angle0" "Oblique0" "Width0"
"Font1" "Height1" "Angle1" "Oblique1" "Width1"
"Font2" "Height2" "Angle2" "Oblique2" "Width2"
"retain1" "retain2" "retain3" "retain4" "retain5"
)
(Dlg_TileSetFont n 2)
))
(Dlg_TileSet "Height2" (rtos textsize lunits luprec))
(Dlg_TileSet "Angle2" (angtos 0.00 aunits auprec))
(Dlg_TileSet "Oblique2" (angtos 0.00 0 0))
(Dlg_TileSet "Width2" (rtos 1.00 2 2))
(Dlg_TileSet "retain1" "1")
(Dlg_TileSet "retain2" "1")
(Dlg_TileSet "retain3" "1")
(Dlg_TileSet "retain4" "1")
(Dlg_TileSet "retain5" "1")
(Dlg_ListStart "Font2")(mapcar 'Dlg_ListAdd (FINDFONT))(Dlg_ListEnd)
(Dlg_TileSet "Font2" textfont)
;;; Control modes
(SETMODE
(list
"Font0" "Height0" "Angle0" "Oblique0" "Width0"
"Font1" "Height1" "Angle1" "Oblique1" "Width1"
"Font2" "Height2" "Angle2" "Oblique2" "Width2"
)
1
)
(Dlg_TileMode "search" 2)
;;; Event handling
(Dlg_TileAction "retain1" "(SETMODE (list \"Font0\" \"Font1\" \"Font2\")(atoi $value))")
(Dlg_TileAction "retain2" "(SETMODE (list \"Height0\" \"Height1\" \"Height2\")(atoi $value))")
(Dlg_TileAction "retain3" "(SETMODE (list \"Angle0\" \"Angle1\" \"Angle2\")(atoi $value))")
(Dlg_TileAction "retain4" "(SETMODE (list \"Oblique0\" \"Oblique1\" \"Oblique2\")(atoi $value))")
(Dlg_TileAction "retain5" "(SETMODE (list \"Width0\" \"Width1\" \"Width2\")(atoi $value))")
(Dlg_TileAction "IDOK" "(READCONTROLS)")
(Dlg_TileAction "IDCANCEL" "(setq ret nil)(Dlg_DialogDone)")
(Dlg_TileAction "Single" "(setq ret nil single T)(Dlg_DialogDone)") ;###
)
(if (FLX_DLGDSP "flx_dlg" "TCORglobal" "(princ)" "(DlgInit)") (princ) (exit))
(setq ret ret)
)
;;; ===========================================================================
;;; FLX_EDIT_SINGLE
;;; ===========================================================================
(defun SING (ss_index) ;;; ###
(setq e (entget (ssname ss ss_index)))
(if (member (cdr (assoc 0 e)) '("TEXT" "ATTRIB" "ATTDEF")) ;;; ### ATTRIB ?
(if (= (type (setq txtlst (FLX_EDIT_SINGLE e))) 'LIST)
(CHANGE_SINGLE txtlst)
)
)
)
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(defun CHANGE_SINGLE (txtlist / W_OUT)
(defun W_OUT (w / ret) (setq ret (* pi (/ w 180.00))))
(setq e (subst (cons 1 (nth 0 txtlst)) (assoc 1 e) e)) ; text
(setq e (subst (cons 7 (nth 1 txtlst)) (assoc 7 e) e)) ; font
(setq tmp (atof (nth 2 txtlst)))
(setq e (subst (cons 40 tmp) (assoc 40 e) e))
(setq e (subst (cons 41 (atof (nth 5 txtlst))) (assoc 41 e) e ))
(setq e (subst (cons 50 (W_OUT (atof (nth 3 txtlst)))) (assoc 50 e) e))
(setq e (subst (cons 51 (W_OUT (atof (nth 4 txtlst)))) (assoc 51 e) e))
(entmod e)
)
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(defun FLX_EDIT_SINGLE (s / SETCONTROL RESTORE READCONTROLS DlgInit remain ret)
(defun SETCONTROL (i s / i)
(Dlg_TileSet (strcat "Font" i) (cdr (assoc 7 s)))
(Dlg_TileSet (strcat "Height" i) (rtos (cdr (assoc 40 s)) lunits luprec))
(Dlg_TileSet (strcat "Angle" i) (angtos (cdr (assoc 50 s)) aunits auprec))
(Dlg_TileSet (strcat "Oblique" i) (angtos (cdr (assoc 51 s)) 0 0 ))
(Dlg_TileSet (strcat "Width" i) (rtos (cdr (assoc 41 s)) 2 luprec))
)
(defun RESTORE()
(SETCONTROL "2" s)
(Dlg_TileSet "Remain" "0")
)
(defun READCONTROLS ( / r1 r2 r3 r4 r5 r6)
(setq r1 (Dlg_TileGet "ReplaceText"))
(setq r2 (Dlg_TileGet "Font2"))
(setq r3 (Dlg_TileGet "Height2"))
(setq r4 (Dlg_TileGet "Angle2"))
(setq r5 (Dlg_TileGet "Oblique2"))
(setq r6 (Dlg_TileGet "Width2"))
(setq remain (if (= (Dlg_TileGet "Remain") "1") 1 nil))
(setq ret (list r1 r2 r3 r4 r5 r6))
)
(defun DlgInit ()
(Dlg_TileSet "LineInfo"
(strcat "" (itoa (+ ss_index 1)) " / " (itoa (sslength ss)) )
) ;;; ### prt: Line ... of ...
(Dlg_TileSet "CurrentText" (cdr (assoc 1 s)))
(Dlg_TileSet "ReplaceText" (cdr (assoc 1 s)))
(Dlg_ListStart "Font2")(mapcar 'DLG_ListAdd (FINDFONT))(Dlg_ListEnd)
(SETCONTROL "1" s)
(if (= remain 1)
(progn
(Dlg_TileSet "Remain" "1")
(if (= (type txtlst) 'LIST)(progn
(Dlg_TileSet "Font2" (nth 1 txtlst))
(Dlg_TileSet "Height2" (nth 2 txtlst))
(Dlg_TileSet "Angle2" (nth 3 txtlst))
(Dlg_TileSet "Oblique2" (nth 4 txtlst))
(Dlg_TileSet "Width2" (nth 5 txtlst))
))
)
(SETCONTROL "2" s) ;;; else
)
(Dlg_TileAction "Restore" "(RESTORE)")
(Dlg_TileAction "IDOK" "(READCONTROLS)(Dlg_DialogDone)")
(Dlg_TileAction "IDCANCEL" "(setq ret nil)(Dlg_DialogDone)")
) ; defun
(if (FLX_DLGDSP "flx_dlg" "TCORsingle" "(princ)" "(DlgInit)") (princ)(exit))
(setq ret ret) ;;; returns txtlst
)
;;; =========================================================
(princ)