Author Topic: Drawing an Anchor Bolt Plan from Text Files  (Read 997 times)

0 Members and 1 Guest are viewing this topic.

sprunkle

  • Mosquito
  • Posts: 3
Drawing an Anchor Bolt Plan from Text Files
« on: May 25, 2023, 07:17:27 AM »
I am working on an AutoLISP program that will take one user input (a job number--e.g. 23-4817), and then use that you pull data from text documents (reports generated by engineering software) in order to draw an anchor bolt plan for a metal building. I have the start of something that works, but I feel like there may be a better way to do this.

Currently, I am defining points based on extracted data and using entmake to create the geometry. See attached image of the basic layout that shows the boundary lines and rigid frame center lines. I labeled the points to keep track of them.

Here is an example of the data I have to pull from:

LAYOUT:
 -------
    Bay                   Design  ---Lap(ft)--           
     Id     Part          Length   Left  Right   
   ----     --------      ------  -----  -----   
   LExt   8X25Z13     1.17                   
      1    8X25Z13    22.58             3.00     
      2    8X25Z16    23.75   3.00   2.00     
      3    8X25Z16    23.75   2.00   2.00     
      4    8X25Z16    23.75   2.00   3.00   
      5    8X25Z13    23.83   3.00           
  RExt   8X25Z13     1.17                 
 
Here is an example of the code I am using to make this work:

Code - Auto/Visual Lisp: [Select]
  1.        
  2. (setq ofile3
  3.                 (open
  4.                         (strcat "J:/x800/" JobNum "/RoofDes.out") ;reopens first file
  5.                 "r")
  6.         )
  7.         (while
  8.                 (/= b1_line " LAYOUT:");finds a certain line in the file
  9.                         (setq b1_line
  10.                                 (read-line ofile3)
  11.                         )
  12.         )
  13.         (setq b1_line
  14.                 (repeat 6 ;goes down another 6 lines
  15.                         (read-line ofile3)
  16.                 )
  17.         )
  18.         (setq bay1
  19.                 (substr b1_line 22 6);extracts distance from rigid frame offset to first bay of bldg.
  20.         )
  21.         (setq bay1
  22.                 (distof bay1 2)
  23.         )
  24.         (setq bay1
  25.                 (* bay1 12)
  26.         )
  27.         (setq bay1
  28.                 (+ bay1 rfo);redefines bay1 to include rigid frame offset as part of the total bay width
  29.         )
  30.         (setq p7 (list bay1 z z));sets coordinates for first bay line to be drawn
  31.         (setq p8 (list bay1 w z))
  32. ;The next if statement sets it up to draw rigid frame center lines until a certain point, then
  33. ;it will not draw any more. This is to allow for projects that have different numbers of bays.
  34.         (if
  35.                 (/= bay1
  36.                         (- le rfo) ;if bay1 is NOT equal to bldg length - rigid frame offset then...
  37.                 )
  38.                                 (entmake ;make the next line
  39.                                         (list
  40.                                                 (cons 0 "LINE")
  41.                                                 (cons 8 "RF_Lines")
  42.                                                 (cons 10 p7)
  43.                                                 (cons 11 p8)
  44.                                         )
  45.                                 )
  46.         )
  47.  

The IF statement near the end is what I think needs some work. Some projects will have more or less bays and different spacings, so I need to have a way to stop reading lines and making entities. This way of doing it all feels to bulky and messy. I am open to any thoughts or suggestions!

BIGAL

  • Swamp Rat
  • Posts: 1430
  • 40 + years of using Autocad
Re: Drawing an Anchor Bolt Plan from Text Files
« Reply #1 on: May 26, 2023, 09:53:51 PM »
Need a dwg to really compare a txt file to. A couple would be good.

Rather than use substr 22 6 you can split a text string into a list using the space as the separator. changing  "space space space" may be needed.

OK 1st go
(setq str "LExt   8X25Z13     1.17                   ")
(CSV->LST str)
("LExt" "" "" "8X25Z13" "" "" "" "" "1.17" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "")
We can though reorganize to ("LExt" "8X25Z13" "1.17") pretty easily. Then convert the (atof "1.17") to a real.

You mention more values so maybe in a dwg show as stages building to full dwg.

I would read all the lines for the bays making a list then draw the bays, do bay one, 2-(last-1), then last bay. Need 1st and last done separate as image shows different line color. This solves the how many bays.

A man who never made a mistake never made anything