home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BUG 15
/
BUGCD1998_06.ISO
/
aplic
/
felixcad
/
fcaddata.z
/
FLX_AEXP.LSP
< prev
next >
Wrap
Lisp/Scheme
|
1997-12-03
|
39KB
|
1,092 lines
;;; flx_aexp.lsp
;;; ================================================================
;;; EXPORT ATTRIBUTES OF PARTS
;;; ================================================================
;;; Provided by FELIX Computer Aided Technologies GmbH 1995-96
;;; ================================================================
;;; Created: Apr 20, 1996 dn
;;; Changed: Oct 21, 1996 vp
;;; ================================================================
;;; This file is called by FLX_MAIN.LSP
;;; ================================================================
(defun FLX_ATTEXP ( / prt_list PARTS
GET_ATTNAMES ERASE_LISTEL CREATE_EXPORT_TAB SEL_FILENAME
ATT_INSERT ATT_DELETE PRT_INSERT PRT_DELETE
ATTEXP_READ_FLX ListAction DlgInit CALL_COPYCLIP UHR
READ_INI WRITE_INI W_TO_FILE GET_VALUES SHOW_ATTRIB
Att_Name_Lst Att_Value_Lst Prt_Value_Lst
selset OUTPUT OUTPUT_OK EXPORTFILE
ERRORSTR SEP_FLD SEP_TXT SAVEINI
DLG_NOT_ACTIVE tmp)
(setq prt_list '(
"Retrieving Attribute Information..." ; 0
"Writing Information..." ; 1
"Write Attribute Export File" ; 2
"Attribute already in list: " ; 3
"Searching for all parts with attributes..." ; 4
"No parts" ; 5
" part" ; 6
" part(s)" ; 7
" with attributes in drawing" ; 8
" with attributes found" ; 9
"File not found: " ;10
"Clipboard function can not be executed!" ;11
"Alert" ;12
"Cannot open file: " ;13
"Part Name: '" ;14
"X coordinate: '" ;15
"Y coordinate: '" ;16
"Z Coordinate: '" ;17
"Layer: '" ;18
"Scale Factor X: '" ;19
"Scale Factor Y: '" ;20
"Scale Factor Z: '" ;21
"Rotation Angle: '" ;22
"Field overflow (Record " ;23 )
"'\t(Max.: " ;24 (
" char.)" ;25
"Not numeric " ;26
"(Record " ;27
")\tAttribute '" ;28
"---" ;29
"<< Back" ;30
"Warnings: " ;31
"Display Warnings" ;32
"Display Export File" ;33
"Export file: " ;34
" record created" ;35
" records created" ;36
"No records created!" ;37
" record written" ;38
" records written" ;39
"No records written!" ;40
"There are warnings!" ;41
"Cannot open file to write: " ;42
"Cannot open file to read: " ;43
"No preferences saved!" ;44
"Attributes" ;45
))
(if FLX_XLANGUAGE (FLX_XLANGUAGE "_aexp" nil))
;;; ***********************************************************************
;;; Input/Output related defuns follow ...
;;; ***********************************************************************
;;; -----------------------------------------------------------------------
;;; READ_INI
;;; -----------------------------------------------------------------------
(defun READ_INI (warn / HOLE_INI_PARAMETER s tmp be_anz f$)
(defun HOLE_INI_PARAMETER (ss / TO_COMMA t1 t2 t3 t4 x TYP)
(defun TO_COMMA( / FLAG ret x)
(if (= (type ss) 'STR)
(progn
(setq FLAG nil x 1)
(while (AND (not FLAG) (<= x (strlen ss)))
(if (= (substr ss x 1) ",")(setq FLAG T))
(setq x (+ x 1))
)
(if (<= x (strlen ss))
(progn (setq ret (substr ss 1 (- x 2))) (setq ss (substr ss x )))
(setq ret nil)
)
)
)
ret
)
(if (= (type ss) 'STR)
(progn
;;; (setq TYP (TO_COMMA))
(setq TYP (substr ss 1 1)) ; P, A, F, T
(setq ss (substr ss 3 (strlen ss)))
(setq t1 (TO_COMMA))
(if (setq t2 (TO_COMMA))(if (> (strlen t2) 2) (setq t2 nil)))
(if (= t2 "C")
(progn (setq t3 ss) (setq t4 ""))
(progn
(if (setq t3 (TO_COMMA))(if (/= (type (read t3)) 'INT) (setq t3 nil)))
(setq t4 ss)
)
)
;(setq t4 ss)
(cond
((= typ "A")
(if (/= (type (read t3)) 'INT) (setq t3 nil))
(if (AND t1 t2 t3 t4)
(setq Att_Value_Lst (append Att_Value_Lst (list (list t1 t2 t3 t4))))
)
)
((= typ "P")
(if (/= (type (read t3)) 'INT) (setq t3 nil))
(if (AND t1 t2 t3 t4)
(setq Prt_Value_Lst (append Prt_Value_Lst (list (list t1 t2 t3 t4))))
)
)
((= typ "F")
(if (AND (= (type t4) 'STR)(= (strlen t4) 1))(setq SEP_FLD t4))
)
((= typ "T")
(if (AND (= (type t4) 'STR)(= (strlen t4) 1))(setq SEP_TXT t4))
)
((= typ "X")
(if (= (type t4) 'STR) (setq EXPORTFILE t4))
)
)
)
)
) ; defun
(if (setq f$
(open (strcat (cdr (assoc "FCADCFG" (getenv))) "\\attexp.ini") "r")
)
(progn
(while (setq s (read-line f$)) (HOLE_INI_PARAMETER s) )
(close f$)
)
(if warn
(ALERT
(strcat
(nth 43 prt_list) ;;;@Cannot open file to read:
(cdr (assoc "FCADCFG" (getenv))) "\\attexp.ini"
)
(nth 2 prt_list) ;;;@Write Attribute Export File
"EXCLAMATION"
)
)
)
)
;;; ------------------------------------------------------------------------
;;; WRITE_INI
;;; ------------------------------------------------------------------------
(defun WRITE_INI (how / el f$)
(if (setq f$
(open (strcat (cdr(assoc "FCADCFG" (getenv))) "\\attexp.ini") "w")
)
(progn
(if (= how 1)
(progn
(if Prt_Value_Lst
(foreach el Prt_Value_Lst
(write-line
(if (= (cadr el) "C")
(strcat "P=" (car el) "," (cadr el) "," (caddr el) )
(strcat "P=" (car el) "," (cadr el) "," (caddr el) "," (last el))
)
f$
)
)
)
(if Att_Value_Lst
(foreach el Att_Value_Lst
(write-line
(if (= (cadr el) "C")
(strcat "A=" (car el) "," (cadr el) "," (caddr el) )
(strcat "A=" (car el) "," (cadr el) "," (caddr el) "," (last el))
)
f$
)
)
)
(if (= (type SEP_FLD) 'STR) (write-line (strcat "F=" SEP_FLD) f$))
(if (= (type SEP_TXT) 'STR) (write-line (strcat "T=" SEP_TXT) f$))
(if (= (type EXPORTFILE) 'STR) (write-line (strcat "X=" EXPORTFILE) f$))
)
)
(close f$)
)
(ALERT
(strcat
(nth 42 prt_list) ;;;@Cannot open file to write:
(cdr (assoc "FCADCFG" (getenv))) "\\attexp.ini"
)
(nth 2 prt_list) ;;;@Write Attribute Export File
"EXCLAMATION"
)
)
)
;;; -----------------------------------------------------------------------
;;; W_TO_FILE
;;; -----------------------------------------------------------------------
(defun W_TO_FILE ( / DlgWarning f$ el anz tmp)
(defun DlgWarning ( / n)
(if FLX$WIN95 (foreach n
'("IDOK" "display" "Static1")
(Dlg_TileSetFont n 2)
))
(Dlg_TileAction "IDOK" "(setq anz nil)(Dlg_DialogDone)")
(Dlg_TileAction "display" "(setq anz T)(Dlg_DialogDone)")
)
(if OUTPUT
(progn
(if (setq f$ (open EXPORTFILE "w"))
(progn
(foreach el OUTPUT (write-line el f$))
(close f$)
(princ (strcat
(itoa (setq tmp (length OUTPUT)))
(if (= tmp 1) (nth 38 prt_list) (nth 39 prt_list)) ;;;@ records written
))
)
;;; else
(ALERT
(strcat
(nth 42 prt_list) ;;;@Cannot open file to write:
"\n" EXPORTFILE
)
(nth 2 prt_list) ;;;@Write Attribut Export File
"EXCLAMATION"
)
)
(if ERRORSTR (progn
(if (FLX_DLGDSP "flx_axp" "warning" "(princ)" "(DlgWarning)") (princ)(exit))
(if anz (SHOW_ATTRIB T))
))
)
;;; else
(princ (nth 40 prt_list)) ;;;@No records written!
)
)
;;; -----------------------------------------------------------------------
;;; CREATE_EXPORT_TAB
;;; -----------------------------------------------------------------------
(defun CREATE_EXPORT_TAB( / n x tmp1 tmp2 ret )
(if UHR (UHR 1))
(Dlg_TileSet "message1" (nth 1 prt_list)) ;;;@Writing Information...
(foreach n OUTPUT
(setq x 1 tmp2 "")
(while (<= x (strlen n))
(if (/= (setq tmp1 (substr n x 1)) "\t")
(setq tmp2 (strcat tmp2 tmp1))
)
(setq x (1+ x))
)
(setq ret (append ret (list tmp2)))
)
(if UHR (UHR 0))
(setq OUTPUT ret)
)
;;; -----------------------------------------------------------------------
;;; GET_VALUES
;;; -----------------------------------------------------------------------
(defun GET_VALUES ( / GET_PARTPROP GET_PARTATTR
tmp TZT x ATVAL l Prt_Prop SAV_TZF)
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(defun GET_PARTPROP (el / tmp el_type el_num el_dec err ret
len_check luprec auprec sep)
(setq
tmp (strcase (car el))
el_type (nth 1 el)
el_num (nth 2 el)
el_dec (nth 3 el)
ret ""
err ""
)
(if (= el_type "N")
(setq len_check (+ (atoi el_num) 1 (atoi el_dec))
luprec (atoi el_dec)
auprec (atoi el_dec)
)
(setq len_check (atoi el_num)
luprec 0
auprec 0
)
)
(cond
((= tmp "NAME")
(setq err (nth 14 prt_list)) ;;;@Part Name: '
(setq ret (strcat ret (cdr (assoc 2 Prt_Prop))))
)
((= tmp "LAYER")
(setq err (nth 18 prt_list)) ;;;@Layer: '
(setq ret (strcat ret (cdr (assoc 8 Prt_Prop))))
)
((= tmp "X")
(setq err (nth 15 prt_list)) ;;;@X coordinate: '
(setq ret (strcat ret (rtos (car (cdr (assoc 10 Prt_Prop))) 2 luprec)))
)
((= tmp "Y")
(setq err (nth 16 prt_list)) ;;;@Y coordinate: '
(setq ret (strcat ret (rtos (cadr (cdr (assoc 10 Prt_Prop))) 2 luprec)))
)
((= tmp "Z")
(setq err (nth 17 prt_list)) ;;;@Z coordinate: '
(setq ret (strcat ret (rtos (caddr (cdr (assoc 10 Prt_Prop))) 2 luprec)))
)
((= tmp "XS")
(setq err (nth 19 prt_list)) ;;;@Scale Factor X: '
(setq ret (strcat ret (rtos (cdr (assoc 41 Prt_Prop)) 2 luprec)))
)
((= tmp "YS")
(setq err (nth 20 prt_list)) ;;;@Scale Factor Y: '
(setq ret (strcat ret (rtos (cdr (assoc 42 Prt_Prop)) 2 luprec)))
)
((= tmp "ZS")
(setq err (nth 21 prt_list)) ;;;@Scale Factor Z: '
(setq ret (strcat ret (rtos (cdr (assoc 43 Prt_Prop)) 2 luprec)))
)
((= tmp "ORIENT")
(setq err (nth 22 prt_list)) ;;;@Rotation Angle: '
(setq ret (strcat ret (angtos (cdr (assoc 50 Prt_Prop)) 0 auprec)))
)
)
;;; Check length of fields:
(if (> (strlen ret) len_check) (progn
(setq ERRORSTR (append ERRORSTR (list (strcat
(nth 23 prt_list) ;;;@Field overflow (Record
(itoa (1+ x)) ")\t"
err
ret
(nth 24 prt_list) ;;;@'\t(Max.:
(itoa len_check)
(nth 25 prt_list) ;;;@ char.)
))))
(setq RET (substr ret 1 len_check))
))
(setq sep (if (= el_type "C") SEP_TXT ""))
(setq RET (strcat sep RET sep SEP_FLD))
RET
)
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;;; GET_PARTATTR: Get filtered attribute list to be displayed
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(defun GET_PARTATTR (e / GET_ATTRIB att el tmp1 tmp2 tmp3 ret z)
(defun GET_ATTRIB (en / en ret tmp)
(setq ret '())
(while (and (setq en (entnext en))(= (cdr (assoc 0 (entget en))) "ATTRIB"))
(setq ret (append ret (list (entget en))))
)
(setq ret ret)
)
(if (setq att (GET_ATTRIB e)) ;;; local function defined above
(progn
(setq z 1)
;;; Check if attribute is contained in ATT_VALUE_LIST ...
(foreach el att
(if (setq tmp3
(assoc (strcase (setq tmp1 (cdr (assoc 2 el)))) Att_Value_Lst)
)
;;; IF Yes -> register name and value
(progn
(setq tmp2 (cdr (assoc 1 el)))
(if (= (cadr tmp3) "N")
(progn
(if (setq tmp2 (atof tmp2))
(setq tmp2 (rtos tmp2 2 (atoi (last tmp3))))
(progn
(setq tmp2 "0.00")
(setq ERRORSTR (append ERRORSTR (list (strcat
(nth 26 prt_list) ;;;@Not numeric
(nth 27 prt_list) ;;;@(Record ;)
(itoa (1+ x))
(nth 28 prt_list) ;;;@")\tAttribute '"
(strcase tmp1)
"' = '" tmp2 "'!"
))))
)
)
)
)
(if (> (strlen tmp2) (atoi (caddr tmp3)))
(progn
(setq ERRORSTR (append ERRORSTR (list (strcat
(nth 23 prt_list) ;;;@Field Overflow (Record ;)
(itoa (+ x 1))
(nth 28 prt_list) ;;;@)\tAttribute '
(strcase tmp1) "' = '" tmp2
(nth 24 prt_list) ;;;@'\t(Max.: ;)
(caddr tmp3)
(nth 25 prt_list) ;;;@ char.)
))))
(setq tmp2 (substr tmp2 1 (atoi (caddr tmp3))))
)
)
(setq ret (append ret (list (list (strcase tmp1) tmp2))))
)
)
(setq z (+ z 1))
)
)
)
(setq ret ret)
)
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(setq ERRORSTR nil)
(setq OUTPUT nil)
(setq SAV_TZF SEP_FLD)
(if (= $key "display")(setq SEP_FLD (strcat SEP_FLD "\t")))
(if (not DLG_NOT_ACTIVE) (progn
(setq EXPORTFILE (Dlg_TileGet "editsaveas"))
(setq SAVEINI (Dlg_TileGet "saveini"))
(Dlg_TileSet "message1" (nth 0 prt_list)) ;@Retrieving Attribute Information...
))
(if UHR (UHR 1))
(setq x 0)
(while (AND selset Att_Value_Lst (< x (sslength selset)))
(setq Prt_Prop (entget (ssname selset x)))
;;;
(setq OUTPUT_X "")
(if Prt_Value_Lst
(foreach el Prt_Value_Lst (setq OUTPUT_X (strcat OUTPUT_X (GET_PARTPROP el))))
)
;;;
(setq atval (GET_PARTATTR (ssname selset x)))
(if atval (progn
(foreach el Att_Value_Lst
(setq wert (if (setq tmp (assoc (car el) atval))(cadr tmp) ""))
(setq TZT (if (= (cadr el) "C") SEP_TXT ""))
(setq OUTPUT_X (strcat OUTPUT_X TZT wert TZT))
(if (/= (last Att_Value_Lst) el) (setq OUTPUT_X (strcat OUTPUT_X SEP_FLD)))
)
(setq OUTPUT (append OUTPUT (list OUTPUT_X)))
))
(setq x (1+ x))
) ; while
(if UHR (UHR 0))
(if (not DLG_NOT_ACTIVE) (Dlg_TileSet "message1" "")) ;;;### no of parts
(setq SEP_FLD SAV_TZF)
)
;;; -----------------------------------------------------------------------
;;; SHOW_ATTRIB: Dialog to display list of attributes to export
;;; -----------------------------------------------------------------------
(defun SHOW_ATTRIB (from / CLIPBOARD SHOW_INFO MAKE_LABELSTR MAKE_TABLIST
DlgInit_4
mode tmp label)
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(defun CLIPBOARD ( / REQUEST howmany copylst lines el)
(defun REQUEST ( / DlgInit_5)
(defun DlgInit_5( / n)
(if FLX$WIN95 (foreach n
'("IDCANCEL" "selection" "selectall" "Static1")
(Dlg_TileSetFont n 2)
))
(Dlg_TileAction "IDCANCEL" "(setq howmany 0)(Dlg_DialogDone)")
(Dlg_TileAction "selection" "(setq howmany 1)(Dlg_DialogDone)")
(Dlg_TileAction "selectall" "(setq howmany 2)(Dlg_DialogDone)")
)
(if (FLX_DLGDSP "flx_axp" "request" "(princ)" "(DlgInit_5)")(princ)(exit))
)
(setq howmany 2) ;;; 2=All 1=Selection 0=Nothing
(setq copylst '())
(setq lines (Dlg_TileGet "info"))
(setq lines (read (strcat "(" lines ")" )))
(if lines (REQUEST))
(cond
((= howmany 1)
(foreach el lines (setq copylst (append copylst (list (nth el OUTPUT)))))
)
((= howmany 2)
(setq copylst OUTPUT)
)
)
(if copylst (if (not COPYCLIP)(princ)(COPYCLIP copylst)))
)
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(defun SHOW_INFO()
(cond
((= mode 1) ;;; Display Warnings
(Dlg_TileSet "show" (nth 30 prt_list)) ;;;@<< Back
(Dlg_TileSet "error" "")
(Dlg_TileSet "disp" "")
(ListAction "label" (list (nth 31 prt_list))) ;;;@Warnings:
(ListAction "info" ERRORSTR)
(setq mode 0)
)
(T ;;; Display Parts Information
(Dlg_TileSet "show" (nth 32 prt_list)) ;;;@Display Warnings
(ListAction "label" label)
(ListAction "info" OUTPUT)
(setq mode 1)
)
)
)
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(defun MAKE_LABELSTR( / ret el)
(setq ret "")
(if Prt_Value_Lst
(foreach el Prt_Value_Lst (setq ret (strcat ret (strcase (car el)) "\t")))
)
(if Att_Value_Lst
(foreach el Att_Value_Lst (setq ret (strcat ret (car el) "\t")))
)
(if (= ret "") nil (list ret))
)
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(defun MAKE_TABLIST( / ret el n1)
(setq ret "" n1 0)
(if Prt_Value_Lst
(foreach el Prt_Value_Lst
(setq n1 (+ n1 (atoi (caddr el))))
(setq ret (strcat ret (itoa n1) " "))
)
)
(if Att_Value_Lst
(foreach el Att_Value_Lst
(setq n1 (+ n1 (atoi (caddr el))))
(setq ret (strcat ret (itoa n1) " "))
)
)
(if (= ret "") nil ret)
)
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(defun DlgInit_4 ( / n)
(if FLX$WIN95 (foreach n
'("IDOK" "show" "clip" "info" "error" "disp" "label")
(Dlg_TileSetFont n 2)
))
(Dlg_TileAction "IDOK" "(Dlg_DialogDone)")
(Dlg_TileAction "show" "(SHOW_INFO)")
(Dlg_TileAction "clip" "(CLIPBOARD)")
(if from
(progn
(ListAction "info" ERRORSTR)
(setq mode 0)
(Dlg_TileSet "error" "")
(Dlg_TileSet "show" (nth 33 prt_list)) ;;;@Display Export File
(Dlg_TileSet "disp" "")
(ListAction "label" (list (nth 31 prt_list))) ;;;@Warnings:
;;;@Display Export File
(setq label (list (strcat (nth 34 prt_list) "'" EXPORTFILE "'")))
)
(progn
(if OUTPUT
(progn
(if (setq tmp (MAKE_TABLIST))
(progn
(Dlg_ListSetTabStops "info" tmp)
(Dlg_ListSetTabStops "label" tmp)
)
)
(if (setq label (MAKE_LABELSTR))
(ListAction "label" label)
(ListAction "label" (setq label (list (nth 45 prt_list)))) ;;;@Attributes
)
(ListAction "info" OUTPUT)
(setq tmp (length OUTPUT))
(setq tmp (strcat
(symbtos tmp)
(if (= tmp 1)
(nth 35 prt_list) ;;;@ record created
(nth 36 prt_list) ;;;@ records created
)
))
)
(progn
(setq tmp (nth 37 prt_list)) ;;;@No records created!
(Dlg_TileMode "clip" 1)
)
)
(Dlg_TileSet "disp" tmp)
(if ERRORSTR
(progn
(setq mode 1)
(Dlg_TileSet "error" (nth 41 prt_list)) ;;;@There are warnings!
)
(progn
(setq mode 0)
(Dlg_TileSet "error" "") ;;;No warnings
(Dlg_TileMode "show" 1)
)
)
)
)
)
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;;; SUB-DIALOG Display...
(if (FLX_DLGDSP "flx_axp" "display" "(princ)" "(DlgInit_4)") (princ)(exit))
(setq OUTPUT_OK T) ;;; ###(setq OUTPUT nil)
)
;;; ****************************************************************************
;;; -----------------------------------------------------------------------
;;; ATTEXP_READ_FLX
;;; -----------------------------------------------------------------------
(defun ATTEXP_READ_FLX ( / x)
(setq Att_Name_Lst nil)
(if UHR (UHR 1))
(setq selset (ssget "X" '((-4 . "<AND")(0 . "INSERT")(66 . 1)(-4 . "AND>"))))
(if selset (progn
(setq x 0)
(while (< x (sslength selset))
(GET_ATTNAMES (ssname selset x))
(setq x (1+ x))
)
))
(NO_OF_PARTS selset)
(if UHR (UHR 0))
)
;;; ------------------------------------------------------------------------
;;; ERASE_LISTEL, ATT_DELETE, PRT_DELETE
;;; ------------------------------------------------------------------------
(defun ERASE_LISTEL (lst x / lst x tmp1 tmp2 ret)
(if (setq tmp2 (cdr (member (nth x lst) (reverse lst))))
(setq ret (append ret (reverse tmp2)))
)
(if (setq tmp1 (cdr (member (nth x lst) lst)))
(setq ret (append ret tmp1))
)
ret
)
;;; ------------------------------------------------------------------------
(defun ATT_DELETE( / del el )
(while (/= (setq del (Dlg_TileGet "attributes")) "")
(setq del (read (strcat "(" del ")")))
(if del (Dlg_ListStart "attributes" 11 (car del)) ) ;;; 11=delete
(setq Att_Value_Lst (ERASE_LISTEL Att_Value_Lst (car del)))
(setq OUTPUT_OK nil)
)
) ;;; creates new list Att_Value_Lst
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(defun PRT_DELETE( / del el )
(while (/= (setq del (Dlg_TileGet "partinfo")) "")
(setq del (read (strcat "(" del ")")))
(if del (Dlg_ListStart "partinfo" 11 (car del)))
(setq Prt_Value_Lst (ERASE_LISTEL Prt_Value_Lst (car del)))
(setq OUTPUT_OK nil)
)
) ;;; creates new list Prt_Value_Lst
;;; ------------------------------------------------------------------------
;;; ATT_INSERT
;;; ------------------------------------------------------------------------
(defun ATT_INSERT ( / TOGGLE_ALL_ATT GET_TILES DlgInit_2
ret el)
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(defun TOGGLE_ALL_ATT ( / x s)
(if (= $value "1")
(progn
(setq x 0 s "")
(while (<= x (length Att_Name_Lst))
(setq s (strcat s (itoa x) " "))
(setq x (1+ x))
)
(Dlg_TileSet "attributes" s)
)
;;; else:
(ListAction "attributes" Att_Name_Lst)
)
)
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(defun GET_TILES ( / a tmp f d el typ)
(if (and (setq tmp (Dlg_TileGet "attributes" ))
(/= tmp "")
)
(progn
(setq tmp (read (strcat "(" tmp ")" )))
(foreach el tmp (setq a (append a (list (nth el Att_Name_Lst)))))
(if (= (setq f (Dlg_TileGet "flength" )) "")(setq f "0"))
(if (= (setq d (Dlg_TileGet "decplaces")) "")(setq d "0"))
(setq typ (if (= (Dlg_TileGet "notnum") "1") "C" "N"))
(if (= typ "C") (setq d ""))
;;; a = Attribute names
;;; typ = Numerical / Not numerical
;;; f = Field width
;;; d = Decimal places
(setq ret (list a typ f d))
)
(setq ret nil)
)
)
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(defun DlgInit_2()
(if FLX$WIN95 (foreach n
'("IDCANCEL" "IDOK" "IDHELP"
"attributes" "allparts" "notnum" "numerical"
"allparts" "dec" "flength" "decplaces" "Static1" "Static3"
)
(Dlg_TileSetFont n 2)
))
(if Att_Name_Lst
(ListAction "attributes" Att_Name_Lst) ;;;### besser FillList
)
(Dlg_TileSet "notnum" "1")
(Dlg_TileSet "flength" "16")
(Dlg_TileSet "decplaces" "0")
(Dlg_TileMode "dec" 1)
(Dlg_TileMode "decplaces" 1)
;;; Actions: - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Dlg_TileAction "IDCANCEL" "(setq ret nil) (Dlg_DialogDone)")
(Dlg_TileAction "IDOK" "(setq ret (GET_TILES))(Dlg_DialogDone)")
(Dlg_TileAction "allparts" "(TOGGLE_ALL_ATT)")
(Dlg_TileAction "notnum"
"(if (= $value \"1\")(progn (Dlg_TileSet \"decplaces\" \"0\")(Dlg_TileMode
\"dec\" 1)(Dlg_TileMode \"decplaces\" 1)))"
)
(Dlg_TileAction "numerical"
"(if (= $value \"1\")(progn (Dlg_TileSet \"decplaces\" \"2\")(Dlg_TileMode
\"dec\" 0)(Dlg_TileMode \"decplaces\" 0)))"
)
)
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;;; Display the sub-dialog:
(if (FLX_DLGDSP "flx_axp" "ins_att" "(princ)" "(DlgInit_2)")(princ)(exit))
;;; If attributes have been selected the list ret is structured as follows:
;;; (("ATTNAME1" "ATTNAME2" ...) NUM|CHAR FIELDWIDTH DEC_PLACES)
;;; If ret list: update list "attributes" in the main dialog:
(if ret
(progn
(Dlg_ListStart "attributes" 2)
(foreach el (car ret)
(if (assoc el Att_Value_Lst)
(ALERT
(strcat (nth 3 prt_list) "\n" el) ;;;@Attribute already in list:
(nth 12 prt_list) ;;;@Alert
"EXCLAMATION"
)
(progn
(Dlg_ListAdd (strcat
(symbtos el) "\t"
(cadr ret) "\t"
(caddr ret) "\t"
(last ret)
))
(setq Att_Value_Lst (append Att_Value_Lst (list
(list el (cadr ret) (caddr ret) (last ret)))))
)
)
)
(Dlg_ListEnd)
(setq OUTPUT_OK nil)
)
)
)
;;; ------------------------------------------------------------------------
;;; PRT_INSERT - Add Part Properties to Export List
;;; ------------------------------------------------------------------------
(defun PRT_INSERT( / GET_TILES DlgInit_3
ret el sav_tzt sav_tzf sav_bl)
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(defun GET_TILES( / KEY_LIST_CHAR KEY_LIST_NUM f d b el)
;;; b = key
;;; typ = numeric/alpha
;;; f = Field width
;;; d = Decimal places
(setq SEP_FLD (Dlg_TileGet "delim_fld"))
(setq SEP_TXT (Dlg_TileGet "delim_txt"))
(setq Prt_Value_Lst nil)
(setq KEY_LIST_CHAR (list "name" "layer" ))
(setq KEY_LIST_NUM (list "x" "y" "z" "orient" "xs" "ys" "zs"))
(foreach el KEY_LIST_CHAR
(if (= (Dlg_TileGet el) "1")(progn
(if (= (setq f (Dlg_TileGet (strcat "field" el))) "") (setq f "0"))
(setq Prt_Value_Lst (append Prt_Value_Lst (list (list el "C" f ""))) )
))
)
(foreach el KEY_LIST_NUM
(if (= (Dlg_TileGet el) "1")(progn
(if (= (setq f (DLG_TileGet (strcat "field" el))) "")
(setq f "0")
)
(if (= (setq d (DLG_TileGet (strcat "dec" el))) "")
(setq d "0")
)
(setq Prt_Value_Lst (append Prt_Value_Lst (list (list el "N" f d))))
))
)
)
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(defun DlgInit_3( / luprec)
(if FLX$WIN95 (foreach n
'("IDCANCEL" "IDOK" "IDHELP"
"name" "layer"
"fieldname" "fieldlayer"
"x" "y" "z" "xs" "ys" "zs" "orient"
"fieldx" "fieldy" "fieldz" "fieldxs" "fieldys" "fieldzs" "fieldorient"
"decx" "decy" "decz" "decxs" "decys" "deczs" "decorient"
;;; "delim_fld" "delim_txt"
"GroupBox1" "GroupBox2"
"Static1" "Static2" "Static3" "Static8" "Static9"
)
(Dlg_TileSetFont n 2)
))
(setq luprec (itoa (getvar "LUPREC")))
(Dlg_TileSet "delim_fld" SEP_FLD)
(Dlg_TileSet "delim_txt" SEP_TXT)
(Dlg_TileSet "fieldname" "12")
(Dlg_TileSet "fieldlayer" "12")
(Dlg_TileSet "fieldx" "8")
(Dlg_TileSet "fieldy" "8")
(Dlg_TileSet "fieldz" "8")
(Dlg_TileSet "decx" luprec)
(Dlg_TileSet "decy" luprec)
(Dlg_TileSet "decz" luprec)
(Dlg_TileSet "fieldorient" "4")
(Dlg_TileSet "decorient" (itoa (getvar "AUPREC")))
(Dlg_TileSet "fieldxs" "4")
(Dlg_TileSet "fieldys" "4")
(Dlg_TileSet "fieldzs" "4")
(Dlg_TileSet "decxs" luprec)
(Dlg_TileSet "decys" luprec)
(Dlg_TileSet "deczs" luprec)
(if Prt_Value_Lst
(foreach el Prt_Value_Lst
(Dlg_TileSet (car el) "1")
(Dlg_TileSet (strcat "field" (car el)) (nth 2 el))
(Dlg_TileSet (strcat "dec" (car el)) (nth 3 el))
)
)
(Dlg_TileAction "IDOK" "(GET_TILES)(Dlg_DialogDone)")
(Dlg_TileAction "IDCANCEL" "(Dlg_DialogDone)")
)
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(setq sav_tzt SEP_TXT sav_tzf SEP_FLD sav_bl Prt_Value_Lst)
(if (FLX_DLGDSP "flx_axp" "selpartprop" "(princ)" "(DlgInit_3)")(princ)(exit))
;; Create list 'be_anz' to display part properties
(if Prt_Value_Lst (progn
(setq be_anz nil)
(foreach el Prt_Value_Lst
(setq be_anz (append be_anz (list (strcat
(strcase (car el))
"\t" (nth 1 el)
"\t" (nth 2 el)
"\t" (nth 3 el)
))))
)
(ListAction "partinfo" be_anz)
))
(Dlg_TileSet "delim_fld" SEP_FLD)
(Dlg_TileSet "delim_txt" SEP_TXT)
(if (or (/= sav_tzt SEP_TXT)
(/= sav_tzf SEP_FLD)
(/= sav_bl Prt_Value_Lst)
)
(setq OUTPUT_OK nil)
)
)
;;; -----------------------------------------------------------------------
;;; SEL_FILENAME
;;; -----------------------------------------------------------------------
(defun SEL_FILENAME ( / fn)
(foreach key
'("IDCANCEL" "IDOK" "IDHELP" "attributes" "partinfo"
;;; "delim_fld" "delim_txt"
"ins" "del" "ins_pp" "del_pp" "display" "message1" "allparts"
"saveini" "editsaveas" "saveas"
"Static4" "Static6" "Static7" "Static8" "Static9" "Static10"
)
(Dlg_TileMode key 1)
)
(if (setq fn (GETFILED
(nth 2 prt_list) ;;;@Write Attribut Export File
(Dlg_TileGet "editsaveas")
"txt"
1
))
(Dlg_TileSet "editsaveas" fn)
)
(foreach key
'("IDCANCEL" "IDOK" "IDHELP" "attributes" "partinfo"
;;; "delim_fld" "delim_txt"
"ins" "del" "ins_pp" "del_pp" "display" "message1" "allparts"
"saveini" "editsaveas" "saveas"
"Static4" "Static6" "Static7" "Static8" "Static9" "Static10"
)
(Dlg_TileMode key 0)
)
)
;;; ------------------------------------------------------------------------
;;; INIPAR_LIST
;;; ------------------------------------------------------------------------
(defun INIPAR_LIST ()
(if (and Att_Value_Lst (not DLG_NOT_ACTIVE))
(progn
(Dlg_ListStart "attributes" 2)
(foreach el Att_Value_Lst
(Dlg_ListAdd (strcat
(car el)
"\t" (cadr el)
"\t" (caddr el)
"\t" (last el)
))
)
(Dlg_ListEnd)
)
)
;; Liste 'be_anz' zusammenstellen fⁿr Anzeige der part properties.
(if (AND Prt_Value_Lst (not DLG_NOT_ACTIVE))
(progn
(setq be_anz nil)
(foreach el Prt_Value_Lst
(setq be_anz (append be_anz (list (strcat
(strcase(car el)) "\t" (nth 1 el) "\t" (nth 2 el) "\t" (nth 3 el)
))))
)
(ListAction "partinfo" be_anz)
)
)
)
;;; ------------------------------------------------------------------------
;;; Initialization of MAIN Dialog
;;; ------------------------------------------------------------------------
(defun DlgInit ( / n)
(if FLX$WIN95 (foreach n
'("IDCANCEL" "IDOK" "IDHELP" "attributes" "partinfo"
;;; "delim_fld" "delim_txt"
"ins" "del" "ins_pp" "del_pp" "display" "message1" "allparts"
"saveini" "editsaveas" "saveas"
"Static4" "Static6" "Static7" "Static8" "Static9" "Static10"
)
(Dlg_TileSetFont n 2)
))
(Dlg_ListSetTabstops "attributes" "8 10 12")
(Dlg_ListSetTabstops "partinfo" "8 10 12")
(INIPAR_LIST)
(NO_OF_PARTS selset)
(Dlg_TileSet "delim_fld" SEP_FLD)
(Dlg_TileSet "delim_txt" SEP_TXT)
(Dlg_TileSet "saveini" "1") ;;; Turn Save INI-file on (!?)
(Dlg_TileSet "editsaveas"
(if EXPORTFILE
EXPORTFILE
(strcat (cdr (assoc "FCADCFG" (getenv))) "\\attexp.txt")
)
)
;;; Actions: - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Dlg_TileAction "IDCANCEL" "(setq OUTPUT nil)(Dlg_DialogDone)")
(Dlg_TileAction "IDOK"
"(if (and OUTPUT OUTPUT_OK) (CREATE_EXPORT_TAB)(GET_VALUES)) (Dlg_DialogDone)"
)
(Dlg_TileAction "allparts" "(ATTEXP_READ_FLX)")
(Dlg_TileAction "ins" "(ATT_INSERT)")
(Dlg_TileAction "del" "(ATT_DELETE)")
(Dlg_TileAction "ins_pp" "(PRT_INSERT)")
(Dlg_TileAction "del_pp" "(PRT_DELETE)")
(Dlg_TileAction "saveas" "(SEL_FILENAME)")
(Dlg_TileAction "display" "(GET_VALUES)(SHOW_ATTRIB nil)")
)
;;; --------------------------------------------------------------------------
;;; CALL_COPYCLIP
;;; --------------------------------------------------------------------------
(defun CALL_COPYCLIP ( / flx_dll prog)
(setq flx_dll "fl_stup.dll")
(if (findfile (strcat FLX$DIRECTORY flx_dll))
(if (not COPYCLIP) (xload (strcat FLX$DIRECTORY flx_dll)) )
(ALERT ; else
(strcat
(nth 10 prt_list) ;;;@File not found: \n
"\n" flx_dll
"\n" (nth 11 prt_list) ;;;@Clipboard function can not be executed!
)
(nth 12 prt_list) ;;;@Alert
"EXCLAMATION"
)
)
)
;;; --------------------------------------------------------------------------
;;; GET_ATTNAMES
;;; --------------------------------------------------------------------------
(defun GET_ATTNAMES (en / tmp)
(while (and (setq en (entnext en))
(= (cdr (assoc 0 (entget en))) "ATTRIB")
)
(setq tmp (strcase (cdr (assoc 2 (entget en)))))
(if (not (member tmp Att_Name_Lst))
(setq Att_Name_Lst (append Att_Name_Lst (list tmp)))
)
)
;;; return
)
;;; --------------------------------------------------------------------------
;;; NO_OF_PARTS: Number of parts with attributes
;;; --------------------------------------------------------------------------
(defun NO_OF_PARTS (sset / sset parts)
(setq parts
(if sset
(strcat (itoa (sslength sset)) (nth 7 prt_list)) ;;;@ part(s)
(nth 5 prt_list) ;;;@No parts
)
)
(Dlg_TileSet
"message1"
(strcat
parts
(if (= e "X")
(nth 8 prt_list) ;;;@ with attributes in drawing
(nth 9 prt_list) ;;;@ with attributes found
)
)
)
)
;;; ---------------------------------------------------------------------------
;;; ListAction
;;; ---------------------------------------------------------------------------
(defun ListAction(box lst / box lst)
(Dlg_ListStart box)
(mapcar 'Dlg_ListAdd lst)
(Dlg_ListEnd)
)
;;; ---------------------------------------------------------------------------
;;; MAIN
;;; ---------------------------------------------------------------------------
;;; Error Handler
(FLX_FUNC_INIT)
;;; Init of variables and lists
(setq dlg_not_active nil)
(setq OUTPUT_OK nil)
(setq SEP_FLD "," SEP_TXT "'")
(setq Att_Name_Lst '())
;;; Xload Clipboard function
(CALL_COPYCLIP)
;;; Read INI file
(READ_INI)
;;; Object selection & previous selection set filter:
(setq selset (ssget))
(if selset
(setq selset (ssget "_P" '((-4 . "<AND")(0 . "INSERT")(66 . 1)(-4 . "AND>"))))
)
;;; GET_ATTNAMES creates Att_Name_Lst (parts and attributes of selection set)
(if selset
(progn
(setq x 0)
(while (< x (sslength selset))
(GET_ATTNAMES (ssname selset x))
(setq x (1+ x))
)
)
;;; No ELSE: The dialog allows to select all parts !
)
;;; Display dialog box
(if (FLX_DLGDSP "flx_axp" "attexport" "(princ)" "(DlgInit)")(princ)(exit))
;;; Write the export file
(if OUTPUT (W_TO_FILE))
;;; Write the INI file
(WRITE_INI (if (= saveini "1") 1 0))
;;; Xunload
(if COPYCLIP (xunload "fl_stup.dll"))
(FLX_FUNC_EXIT)
(princ)
)
(princ)