Exchange Forum > Dcl Dialogs
W-Shapes dat file for dialog
W-Shapes dat file for dialog

#1

Trevor
Join Date:
07-29-2007
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)
)

Attachments  W-shapes.dat  
W-Shapes dat file for dialog

#2

J Briggs
Join Date:
07-25-2007
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.
W-Shapes dat file for dialog

#3

Trevor
Join Date:
07-29-2007
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.
Code:
Wshapes : dialog {
  label = "W-Shapes";
  spacer;
  : row { fixed_width = true;
    : column { width = 15; spacer;
      : text { key = "DepthText"; }
    }
    : popup_list { width = 10;
      key = "DepthList";
    }
  }
  : row { fixed_width = true;
    : column { width = 15; spacer;
      : text { key = "WeightText"; }
    }
    : popup_list { width = 10;
      key = "WeightList";
    }
  }
  : row { fixed_width = true;
    : column { width = 15; spacer;
      : text { key = "AngleText"; }
    }
    : edit_box { edit_width = 8;
      key = "AngleEdit";
    }
  }
  spacer;
  : row { fixed_width = true; alignment = centered;
    : ok_button { width = 11; }
    : cancel_button { width = 11; }
  }
}
W-Shapes dat file for dialog

#4

Trevor
Join Date:
07-29-2007
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



Attachments  W-shapes.gif    W-shapes.dcl    W-shapes.lsp  
W-Shapes dat file for dialog

#5

J Briggs
Join Date:
07-25-2007
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.
W-Shapes dat file for dialog

#6

Theodorus Winata
Join Date:
11-15-2007
Trevor and J Briggs, well done! Are you going to write Angles and C Shapes program? Looking forward to seeing it.
 
Thanks,
 
Theodorus Winata
W-Shapes dat file for dialog

#7

Trevor
Join Date:
07-29-2007
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

Attachments  W-shapes.lsp