TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: xianaihua on January 05, 2010, 07:23:28 AM
-
Hello all,
I want to assemble a body of statistics for each sub-assembly and parts of the total numbers,
Their assembly relation is shown below.
The number behind each piece, but the pieces in the last one in a number of sub-assembly.
According to bom of each dwg,I constructed the following list:
("sub-assembly1-1" "assembly" 2)
("sub-assembly1-2" "assembly" 3)
("sub-assembly1-3" "assembly" 2)
("pat1-1" "assembly" 3)
("pat1-2" "assembly" 2)
("pat1-3" "assembly" 1)
("sub-assembly2-1" "sub-assembly1-1" 3)
("sub-assembly2-2" "sub-assembly1-1" 3)
("sub-assembly2-3" "sub-assembly1-1" 2)
("pat2-1" "sub-assembly1-1" 3)
("pat2-2" "sub-assembly1-1" 2)
("pat1-3" "sub-assembly1-1" 1)
("pat3-1" "sub-assembly2-1" 3)
("pat3-2" "sub-assembly2-1" 2)
("pat2-1" "sub-assembly2-1" 1)
Example:total numbers of "pat3-1"=3X3X2X1
That,numbers of "pat3-1" in the "sub-assembly2-1" * numbers of "sub-assembly2-1" in the "sub-assembly1-1" * numbers of "sub-assembly1-1" in the "assembly" * numbers of "assembly"(By default, the top-level assembly's number is one)
I want to have a recursive algorithm, was the total number of new list
("sub-assembly1-1" "assembly" 2 2);2X1
("sub-assembly1-2" "assembly" 3 3);3X1
("sub-assembly1-3" "assembly" 2 2);2X1
("pat1-1" "assembly" 3 3);3X1
("pat1-2" "assembly" 2 2);2X1
("pat1-3" "assembly" 1 1);1X1
("sub-assembly2-1" "sub-assembly1-1" 3 6);3X2X1
("sub-assembly2-2" "sub-assembly1-1" 3 6);3X2X1
("sub-assembly2-3" "sub-assembly1-1" 2 4);2X2X1
("pat2-1" "sub-assembly1-1" 3 6);3X2X1
("pat2-2" "sub-assembly1-1" 2 4);2X2X1
("pat1-3" "sub-assembly1-1" 1 2);1X2X1
("pat3-1" "sub-assembly2-1" 3 18);3X3X2X1
("pat3-2" "sub-assembly2-1" 2 12);2X3X2X1
("pat2-1" "sub-assembly2-1" 1 6);1X3X2X1
All friends, how to do this recursively?
First of all, thanks !
-
Hi all..
Anyone have an idea on how to get tol numbers of parts?
thanks.
-
Maybe tomorrow, I'm done for the day. :-)
-
I look forward to the guidance of CAB, and other masters! :-D
-
Here is a start. You can do the recursion changes to make it do what you want exactly.
(defun ShowBlockNesting ( blkName blkCol / tempList tempName NestingList)
(if (not (vl-catch-all-error-p (setq BlkObj (vl-catch-all-apply 'vla-Item (list blkCol blkName)))))
(vlax-for obj BlkObj
(if (= (vla-get-ObjectName obj) "AcDbBlockReference")
(if (setq tempList (assoc (setq tempName (vla-get-Name obj)) NestingList))
(setq NestingList (subst (cons tempName (1+ (cdr tempList))) tempList NestingList))
(setq NestingList (cons (cons tempName 1) NestingList))
)
)
)
)
(cons blkName NestingList)
)
(defun c:Test ()
(showblocknesting (cdr (assoc 2 (entget (car (entsel))))) (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))
)
-
No master here, but I would block everything (with attributes).
SSget all the parts, and drill through list(s) , counting as you go.
Sound so simmple, doesn't it?
i.e.
Block A contains 4 distint parts .
Get/count all instances of block A.
(List "Block A" integer-blockcountA ("subpart1" (* integer-blockcountA qty-subpart1)) ("subpart2" (* integer-blockcountA qty-subpart2)))
("subpart3" (* integer-blockcountA qty-subpart3))) ("subpart4" (* integer-blockcountA) qty-subpart4)))
Block B contains 12 distint parts .
(List "Block B" integer-blockcountB ("subpart1" (* integer-blockcountB qty-subpart1)) ...
There may be a lot of "hard coding" necessary to achieve your goal,
but if your needs are specific to your discipline ,
just "Get 'er done", any 'ole way you can.
AA
-
Better yet, follow T.Wiley.
-
thanks,
Sorry, my English is poor, not explained clearly.
Now, regardless of anything else, we can reduce the problem only to the list of recursive processing.
In accordance with the above requirements, how the recursive computation of the list? Please express anyone's idea and suggestions!
-
Why does it have to be recursive? Is this a homework assignment?
-
hi,CAB!
Of course, do not use the recursive method can also be!Doing mechanical design, we often have statistical part quantity.Bom assembly drawings of each style is shown below
-
This thread my be of interest.
http://www.theswamp.org/index.php?topic=28043.msg336481#msg336481
-
Why does it have to be recursive? Is this a homework assignment?
I think because I said recursive, as that lends itself to these type of situations.
-
Thanks Tim, but at the end of the Op's first post:
All friends, how to do this recursively?
From futher postings it is obviously not Homework, from school anyway. :-)
-
You pay better attention that I do Alan, as I didn't even see that requirement. :-D
-
Here is another play toy:
http://www.theswamp.org/index.php?topic=29953.0
-
Here is one I just wrote. Seemed fun, and I need to stretch the grey matter.
(defun c:ShowNesting (/ *error* ActDoc BlkCol Sel EntData BlkName NestList)
(defun *error* ( msg )
(vl-bt)
)
;------------------------------
(defun GetBlockBlocks ( blkObj doc / BlkCol BlkCntList tempList tempName )
(setq BlkCol (vla-get-Blocks doc))
(vlax-for obj blkObj
(if (= (vla-get-ObjectName obj) "AcDbBlockReference")
(setq BlkCntList
(if (setq tempList (assoc (setq tempName (vla-get-Name obj)) BlkCntList))
(subst (list tempName (1+ (cadr tempList)) (caddr tempList)) tempList BlkCntList)
(cons (list tempName 1(GetBlockBlocks (vla-Item BlkCol tempName) doc)) BlkCntList)
)
)
)
)
BlkCntList
)
;-------------------------------------
(defun PrintList ( lst indent )
(prompt (strcat "\n" indent (car lst) " - " (itoa (cadr lst))))
(foreach i (caddr lst)
(PrintList i (strcat " " indent))
)
)
;-------------------------------------
(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(setq BlkCol (vla-get-Blocks ActDoc))
(if
(and
(setq Sel (entsel "\n Select block to get nesting block list: "))
(setq EntData (entget (car Sel)))
(= (cdr (assoc 0 EntData)) "INSERT")
(setq BlkName (cdr (assoc 2 EntData)))
(setq NestList (GetBlockBlocks (vla-Item BlkCol BlkName) ActDoc))
)
(progn
(prompt (strcat "\nReport for:" BlkName))
(foreach lst NestList
(PrintList lst " ")
)
)
)
(princ)
)
Returns to the command line
Report for:testing
test - 3
DI-NOTE - 1
CIR-NOTE - 4
-
Another bit of code looking at nested blocks, not sure whether it helps?
http://www.theswamp.org/index.php?topic=29988.0 (http://www.theswamp.org/index.php?topic=29988.0)
-
Looked good on my test Tim. 8-)
Select block to get nesting block list:
Report for:sub-ass2-1
sub-ass-1 - 2
part-1 - 1
part-2 - 1
part-3 - 1
sub-ass-2 - 1
part-3 - 1
part-2 - 1
part-1 - 1
sub-ass-3 - 1
part-3 - 1
part-2 - 1
part-1 - 1
-
Thanks Alan. I didn't have too many nested blocks, so I just created a simple one.
-
Thanks Alan,Tim
Thank you for your reply.You spent valuable time
In mechanical design, in each assembly has a bom, the bom sets out the assembly of all the sub-assembly and parts of some information, such as: code, name, quantity, material, weight, etc., but these sub - assembly and parts in the model space is not necessarily a block reference, may be a line, arc, pline, etc., bom data is entered manually. It is not possible with the search block refer to the number of ways of doing.
The question now is: can be a folder of all the following dwg files of these bom data extraction, and how to process these data?
-
xianaihua,
Are you exporting each BOM to a .CSV file ??
if yes ;
is there a seperate .CSV file for each assembly ?
and ; are the CSV files the same name as the assembly ?
How are you generating the lists shown in your first post ??
Regards
Kerry
-
It would help if you supplied a sample DWG file.
-
xianaihua,
Are you exporting each BOM to a .CSV file ??
if yes ;
is there a seperate .CSV file for each assembly ?
and ; are the CSV files the same name as the assembly ?
How are you generating the lists shown in your first post ??
Regards
Kerry
Hi,Kerry
I exporting all BOM from assembly's dwg(a folder of all the following dwg files ) to a database (.mdb) file .
-
It would help if you supplied a sample DWG file.
ok,I have supplied a sample DWG file and BOM.txt file.
-
Hi,all
I had already won the way to solve this problem, the following is my practice, everyone please review a review, or give some advice
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=;;
;; ;;
;; AUTHOR: lihuaili, November 2011. ;;
;;...............................................................................;;
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=;;
;;;In the schedule list, statistics a part in code number
;;;Statistical method: first find out the parts in the assembly code father quantity, to find the father in the more higher level assembly father assemble number... ,
;;;And so on, until inquires the top to assembly, the number of these factors, and that of the parts of the total number.
;;;I through trial and error, finally using a recursive method solved the difficult problem.
;;;Parameters:
;;;Bom_lst: bom all list; 【 list 】
;;;Assemble_No: father assembly code; 【 str 】
;;;Part_No_index: spare parts list list adept in code in the list of the index number (note: the first listed as 0) 【 INT 】
;;;Assemble_No_index: assembly code in the list belong to the list of the index number list adept 【 INT 】
;;;Num_index: in its parts assembly (father assembly) of the quantity, understood in the list of the index number list adept 【 INT 】
;;;return:
;;;Total number 【INT】
(defun SumPartCounts (bom_lst assemble_No part_No_index
assemble_No_index Num_index
/ tol_num
)
(or tol_num (setq tol_num 1))
(foreach x bom_lst
(if (= assemble_No (nth part_No_index x))
(setq assemble_No (nth assemble_No_index x)
tol_num (* tol_num
(atoi (nth Num_index x))
(SumPartCounts
bom_lst assemble_No
part_No_index assemble_No_index
Num_index
) ;_ 结束SumPartCounts
;_ 结束SumPartCounts
) ;_ 结束*
) ;_ 结束setq
) ;_ 结束if
) ;_ 结束foreach
tol_num
) ;_ 结束defun
;;;writie list data to the text file
(defun WriteDataFile (file_name data_lst / _tostring file)
;by:Lee Mac
(defun _tostring (x / dimzin)
(cond
((eq 'INT (type x))
(itoa x)
)
((eq 'REAL (type x))
(setq dimzin (getvar 'DIMZIN))
(setvar 'DIMZIN 0)
(setq x (rtos x 2 8))
(setvar 'DIMZIN dimzin)
x
)
((vl-prin1-to-string x))
) ;_ 结束cond
) ;_ 结束defun
(if (setq file (open file_name "w"))
(progn
(foreach x data_lst (write-line (_tostring x) file))
(setq file (close file))
t
) ;_ 结束progn
) ;_ 结束if
) ;_ 结束defun
;;;bomlst:Is the way to get through some parts list (list specific methods in this not discussed)
;;;Among them the first listed as parts of each line of code
;;;The second listed as parts assembly code belongs
;;;The third listed as in its parts assembly of quantity
(setq bomlst '(
("sub-assembly1-1" "assembly" "2")
("sub-assembly1-2" "assembly" "3")
("sub-assembly1-3" "assembly" "1")
("pat1-1" "assembly" "3")
("pat1-2" "assembly" "2")
("pat1-3" "assembly" "5")
("sub-assembly2-1" "sub-assembly1-1" "2")
("sub-assembly2-2" "sub-assembly1-1" "2")
("sub-assembly2-3" "sub-assembly1-1" "4")
("pat2-1" "sub-assembly1-1" "3")
("pat2-2" "sub-assembly1-1" "4")
("pat1-3" "sub-assembly1-1" "2")
("pat3-1" "sub-assembly2-1" "2")
("pat3-2" "sub-assembly2-1" "3")
("pat2-1" "sub-assembly2-1" "1")
)
) ;_ 结束setq
(defun c:test (/ partnumlst Ap_No p_num partnumlst fname)
(setq partnumlst '())
(foreach n (reverse bomlst)
(setq Ap_No (nth 1 n)
p_num (atoi (nth 2 n))
partnumlst
(cons
(append n
(list (itoa (* (SumPartCounts bomlst Ap_No 0 1 2) p_num)))
) ;_ 结束append
partnumlst
) ;_ 结束cons
) ;_ 结束setq
) ;_ 结束foreach
(setq
fname (getfiled "save list data input filename";
(getvar "dwgprefix")
"txt"
3
) ;_ 结束getfiled
) ;_ 结束setq
(if fname
(progn
(WriteDataFile fname partnumlst)
(alert "The current data has been preserved!");
) ;_ 结束progn
) ;_ 结束if
) ;_ 结束defun
-
ElpanovEvgeniy
Good weekend!
If you have time, please optimization or simplify my program In the following posts。
Thanks agan!
http://www.theswamp.org/index.php?topic=31524.msg452218#msg452218 (http://www.theswamp.org/index.php?topic=31524.msg452218#msg452218)
:)
Hi,all
I had already won the way to solve this problem, the following is my practice, everyone please review a review, or give some advice
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=;;
;; ;;
;; AUTHOR: lihuaili, November 2011. ;;
;;...............................................................................;;
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=;;
;;;In the schedule list, statistics a part in code number
;;;Statistical method: first find out the parts in the assembly code father quantity, to find the father in the more higher level assembly father assemble number... ,
;;;And so on, until inquires the top to assembly, the number of these factors, and that of the parts of the total number.
;;;I through trial and error, finally using a recursive method solved the difficult problem.
;;;Parameters:
;;;Bom_lst: bom all list; 【 list 】
;;;Assemble_No: father assembly code; 【 str 】
;;;Part_No_index: spare parts list list adept in code in the list of the index number (note: the first listed as 0) 【 INT 】
;;;Assemble_No_index: assembly code in the list belong to the list of the index number list adept 【 INT 】
;;;Num_index: in its parts assembly (father assembly) of the quantity, understood in the list of the index number list adept 【 INT 】
;;;return:
;;;Total number 【INT】
(defun SumPartCounts (bom_lst assemble_No part_No_index
assemble_No_index Num_index
/ tol_num
)
(or tol_num (setq tol_num 1))
(foreach x bom_lst
(if (= assemble_No (nth part_No_index x))
(setq assemble_No (nth assemble_No_index x)
tol_num (* tol_num
(atoi (nth Num_index x))
(SumPartCounts
bom_lst assemble_No
part_No_index assemble_No_index
Num_index
) ;_ 结束SumPartCounts
;_ 结束SumPartCounts
) ;_ 结束*
) ;_ 结束setq
) ;_ 结束if
) ;_ 结束foreach
tol_num
) ;_ 结束defun
;;;writie list data to the text file
(defun WriteDataFile (file_name data_lst / _tostring file)
(defun _tostring (x / dimzin)
(cond
((eq 'INT (type x))
(itoa x)
)
((eq 'REAL (type x))
(setq dimzin (getvar 'DIMZIN))
(setvar 'DIMZIN 0)
(setq x (rtos x 2 8))
(setvar 'DIMZIN dimzin)
x
)
((vl-prin1-to-string x))
) ;_ 结束cond
) ;_ 结束defun
(if (setq file (open file_name "w"))
(progn
(foreach x data_lst (write-line (_tostring x) file))
(setq file (close file))
t
) ;_ 结束progn
) ;_ 结束if
) ;_ 结束defun
;;;bomlst:Is the way to get through some parts list (list specific methods in this not discussed)
;;;Among them the first listed as parts of each line of code
;;;The second listed as parts assembly code belongs
;;;The third listed as in its parts assembly of quantity
(setq bomlst '(
("sub-assembly1-1" "assembly" "2")
("sub-assembly1-2" "assembly" "3")
("sub-assembly1-3" "assembly" "1")
("pat1-1" "assembly" "3")
("pat1-2" "assembly" "2")
("pat1-3" "assembly" "5")
("sub-assembly2-1" "sub-assembly1-1" "2")
("sub-assembly2-2" "sub-assembly1-1" "2")
("sub-assembly2-3" "sub-assembly1-1" "4")
("pat2-1" "sub-assembly1-1" "3")
("pat2-2" "sub-assembly1-1" "4")
("pat1-3" "sub-assembly1-1" "2")
("pat3-1" "sub-assembly2-1" "2")
("pat3-2" "sub-assembly2-1" "3")
("pat2-1" "sub-assembly2-1" "1")
)
) ;_ 结束setq
(defun c:test (/ partnumlst Ap_No p_num partnumlst fname)
(setq partnumlst '())
(foreach n (reverse bomlst)
(setq Ap_No (nth 1 n)
p_num (atoi (nth 2 n))
partnumlst
(cons
(append n
(list (itoa (* (SumPartCounts bomlst Ap_No 0 1 2) p_num)))
) ;_ 结束append
partnumlst
) ;_ 结束cons
) ;_ 结束setq
) ;_ 结束foreach
(setq
fname (getfiled "save list data input filename";
(getvar "dwgprefix")
"txt"
3
) ;_ 结束getfiled
) ;_ 结束setq
(if fname
(progn
(WriteDataFile fname partnumlst)
(alert "The current data has been preserved!");
) ;_ 结束progn
) ;_ 结束if
) ;_ 结束defun
my variant:
(defun test (l / f)
(defun f (a l) (if a (* (atoi (caddr a)) (f (assoc (cadr a) l) l)) 1))
(mapcar (function (lambda (a) (append a (list (itoa (f a l)))))) l)
)
check:
(setq l '(("sub-assembly1-1" "assembly" "2")
("sub-assembly1-2" "assembly" "3")
("sub-assembly1-3" "assembly" "1")
("pat1-1" "assembly" "3")
("pat1-2" "assembly" "2")
("pat1-3" "assembly" "5")
("sub-assembly2-1" "sub-assembly1-1" "2")
("sub-assembly2-2" "sub-assembly1-1" "2")
("sub-assembly2-3" "sub-assembly1-1" "4")
("pat2-1" "sub-assembly1-1" "3")
("pat2-2" "sub-assembly1-1" "4")
("pat1-3" "sub-assembly1-1" "2")
("pat3-1" "sub-assembly2-1" "2")
("pat3-2" "sub-assembly2-1" "3")
("pat2-1" "sub-assembly2-1" "1")
)
)
(test l)
>>
(("sub-assembly1-1" "assembly" "2" "2")
("sub-assembly1-2" "assembly" "3" "3")
("sub-assembly1-3" "assembly" "1" "1")
("pat1-1" "assembly" "3" "3")
("pat1-2" "assembly" "2" "2")
("pat1-3" "assembly" "5" "5")
("sub-assembly2-1" "sub-assembly1-1" "2" "4")
("sub-assembly2-2" "sub-assembly1-1" "2" "4")
("sub-assembly2-3" "sub-assembly1-1" "4" "8")
("pat2-1" "sub-assembly1-1" "3" "6")
("pat2-2" "sub-assembly1-1" "4" "8")
("pat1-3" "sub-assembly1-1" "2" "4")
("pat3-1" "sub-assembly2-1" "2" "8")
("pat3-2" "sub-assembly2-1" "3" "12")
("pat2-1" "sub-assembly2-1" "1" "4")
)
-
Hi, xianaihua! :)
I'm not sure that is true to understand the purpose of the program.
I have done the same result with your code...
-
Hi, xianaihua! :)
I'm not sure that is true to understand the purpose of the program.
I have done the same result with your code...
Hi,Evgeniy
excellent!!!
Thanks you help me!
This is what I wanted the results.You is a true recursion experts, you of the recursive use of magic.
-
Hi,Evgeniy
excellent!!!
Thanks you help me!
This is what I wanted the results.You is a true recursion experts, you of the recursive use of magic.
In 2006, I published an article "Lessons from the creation of recursive functions."
You may be interested in reading this series of lessons...
:-)
Recursion in AutoLISP Lesson 1 (http://translate.google.com/translate?hl=ru&sl=ru&tl=en&u=http%3A%2F%2Fwww.elpanov.com%2Findex.php%3Fid%3D56)
Recursion in AutoLISP Lesson 2 (http://translate.google.com/translate?hl=ru&sl=ru&tl=en&u=http%3A%2F%2Fwww.elpanov.com%2Findex.php%3Fid%3D57)
Recursion in AutoLISP Lesson 3 (http://translate.google.com/translate?hl=ru&sl=ru&tl=en&u=http%3A%2F%2Fwww.elpanov.com%2Findex.php%3Fid%3D58)
Recursion in AutoLISP Lesson 4 (http://translate.google.com/translate?hl=ru&sl=ru&tl=en&u=http%3A%2F%2Fwww.elpanov.com%2Findex.php%3Fid%3D61)
Recursion in AutoLISP Lesson 5 (http://translate.google.com/translate?hl=ru&sl=ru&tl=en&u=http%3A%2F%2Fwww.elpanov.com%2Findex.php%3Fid%3D62)
Recursion in AutoLISP Lesson 6 (http://translate.google.com/translate?hl=ru&sl=ru&tl=en&u=http%3A%2F%2Fwww.elpanov.com%2Findex.php%3Fid%3D63)
Recursion in AutoLISP Lesson 7 (http://translate.google.com/translate?hl=ru&sl=ru&tl=en&u=http%3A%2F%2Fwww.elpanov.com%2Findex.php%3Fid%3D64)
Recursion in AutoLISP Lesson 8 (http://translate.google.com/translate?hl=ru&sl=ru&tl=en&u=http%3A%2F%2Fwww.elpanov.com%2Findex.php%3Fid%3D65)
Recursion in AutoLISP Lesson 9 (http://translate.google.com/translate?hl=ru&sl=ru&tl=en&u=http%3A%2F%2Fwww.elpanov.com%2Findex.php%3Fid%3D66)
Recursion in AutoLISP Lesson 10 (http://translate.google.com/translate?hl=ru&sl=ru&tl=en&u=http%3A%2F%2Fwww.elpanov.com%2Findex.php%3Fid%3D67)
-
ElpanovEvgeniy,
What are the chances that you'd be willing to put that together in a single PDF, available for download?
-
ElpanovEvgeniy,
What are the chances that you'd be willing to put that together in a single PDF, available for download?
in Russian - no problems with quality translation I can not ...
-
Do you want to translate into English?
-
Do you want to translate into English?
I can take a crack at it, as time permits. Unfortunately time is in short supply for me.
-
Thanks Alan. I didn't have too many nested blocks, so I just created a simple one.
Works great for nested xrefs...sexy.
Thanks Tim for sharing it.
-
Do you want to translate into English?
I can take a crack at it, as time permits. Unfortunately time is in short supply for me.
I did a copy & paste to HTML then print to DOC format to get a pretty good document.
Although I lost font colors and some of the code was missing LF CRs but I have edited it into a fairly clean document.
I set all code to red & managed to re-color the first two pages of code but there are some 43 pages so I stopped there.
No more time but I can forward the DOC file if you want to take it to the next level. (with Evgeniy's permission of course)
-
. . .
;;;writie list data to the text file
(defun WriteDataFile (file_name data_lst / _tostring file)
(defun _tostring (x / dimzin)
(cond
((eq 'INT (type x))
(itoa x)
)
((eq 'REAL (type x))
(setq dimzin (getvar 'DIMZIN))
(setvar 'DIMZIN 0)
(setq x (rtos x 2 8))
(setvar 'DIMZIN dimzin)
x
)
((vl-prin1-to-string x))
) ;_ 结束cond
) ;_ 结束defun
(if (setq file (open file_name "w"))
(progn
(foreach x data_lst (write-line (_tostring x) file))
(setq file (close file))
t
) ;_ 结束progn
) ;_ 结束if
) ;_ 结束defun
. . .
(defun NumInc:WriteConfig ( name lst / _tostring file )
(defun _tostring ( x / dimzin )
(cond
( (eq 'INT (type x))
(itoa x)
)
( (eq 'REAL (type x))
(setq dimzin (getvar 'DIMZIN))
(setvar 'DIMZIN 0)
(setq x (rtos x 2 8))
(setvar 'DIMZIN dimzin)
x
)
( (vl-prin1-to-string x) )
)
)
(if (setq file (open name "w"))
(progn
(foreach x lst (write-line (_tostring x) file))
(setq file (close file))
t
)
)
)
:-o
-
Why should (setq file (close file))?
Perhaps just enough (close file)...
-
Why should (setq file (close file))?
Perhaps just enough (close file)...
Because 'close' always returns nil, so I use it to null the 'file' variable. This way I can check for the 'file' variable in my *error* handler.
-
Hi,lee !
sorry!
Forget your copyright :ugly:
This is a good tool!