I'm trying to convert that W-shape.dat file mentioned in the AutoCAD Chat forum/AutoCad LispWiki thread into a usable list for a dialog without using the dat file and I'm having some problems. I know it's been a long weekend, but it seems like my function should work. It writes the info to NotePad, but then when I save it and test it, I get an error message like "bad function: 4", whatever that means. It looks right, even the NotePad version. If you have any ideas, I'd appreciate your help.
Thanks,
Trevor
Here is what I've got so far.
Code:
(defun c:WshapeDat2List (/ Data DataList Filename FileName Num Start Text Textfile)
(setq Filename (open (findfile "W-shapes.dat") "r"))
(setq Data (read-line Filename));Skip the first line info.
(setq DataList (list "(defun WshapeLists ()" " (setq DataList (list"))
(while (setq Data (read-line Filename))
(setq Data (vl-string-trim " " Data))
(while (/= Text Data)
(setq Text Data Start 1)
(while (setq Num (vl-string-search " " Data Start))
(setq Data (vl-string-subst " " " " Data Num))
(setq Start (1+ Num))
)
)
(setq Data (strcat " (" Data ")"))
(setq DataList (append DataList (list Data)))
)
(close Filename)
(setq DataList (append DataList (list " )" " )" ")")))
(setq Textfile (strcat (vl-filename-directory (findfile "W-shapes.dat")) "\\W-shapes.txt"))
(setq Filename (open Textfile "w"))
(foreach Data DataList
(write-line Data Filename)
)
(close FileName)
(startapp "NotePad" Textfile)
(princ)
)
Trevor,
You just missed putting in the "list" part on the following line. It sounds like you have the start of a very useful function.
I looked into the dat file and I think the last line of information is bogus. It's not a standard in the manual of Steel Construction.
i.e. (list 8 18.40 8.00 0.271 4.001 0.426).
Code:
;Change this line,
(setq Data (strcat " (" Data ")"))
;to either of these.
(setq Data (strcat " (list " Data ")"))
(setq Data (strcat " '(" Data ")"))
;They both work the same.
J Briggs,
Thanks for the tip! That's what I missed. I've been working on the rest of the program and now I'm designing the dialog. I'm mostly using popup lists and edit boxes. Here's what I've got so far.
It's taken me a while writing this, but here it is. I had help with an engineer verifying and updating the data per the manual of Steel Construction. And Bennett thank you for your coaching and examples. I left your comments in the dcl dialog file for others to benefit from. I know the engineers and drafters at work are going to love this one.
Trevor
I checked out your program and it's going to come in very handy drawing W-flanges. I noticed you removed that line of data that I was referring to that must have been a test case at the end of the dat file. Nice work! Looking forward to your next creation.
Theodorus,
I changed the first two items in the Wshapes DataList to strings instead of numbers, as I mentioned in your thread on C-Shapes. I think it's easier to work with, since the lists are already in a sorted order.
Trevor