Jump to content

Help, Importing a .txt Table to Cad


NEXTMARCUS

Recommended Posts

Hi everyone!

i'm trying to find a lisp to import tables in a .txt file to autocad but i dont know where to start this task. i had an idea that is :

copy the tables to excel and then paste in autocad.

the problem is that i have lots of tables to import and if I do so, it will take a long time.

 

follows a model of the table :

 

 

 

 

SoI need to fill the fields total weight and profile names

follows a file with the desired results.

i also need to sum the total weight PLUS 10%

any idea that could help me in this task?

 

 

sorry about my english.

example.dwg

table.txt

Link to comment
Share on other sites

  • Replies 21
  • Created
  • Last Reply

Top Posters In This Topic

  • NEXTMARCUS

    11

  • CADWarrior

    5

  • Bill Tillman

    4

  • BIGAL

    2

Top Posters In This Topic

WOW! That will involve a lot of programming, but like most things with LISP it's entirely possible. I'm not sure that your first idea won't be easier and faster until you've got what will be a rather extensive LISP program prepared.

 

A couple of questions, I'm assuming your text file will always be in the same format? Is there any reason the lengths are written in Scientific Notation instead of another format? Someone may be able to tackle this for you but it will require some real coding to parse the file correctly and then place the text in the desired location in a drawing. If it were me, I'd just stick with cutting and pasting from Excel. But that's just me.

Link to comment
Share on other sites

Hi Bill, yes the files will be always in the same format , this file is an output from another program and i can chose the values notation.

 

i made an excel macro to parse the data and now im trying to find a way to make the table in excel and then import to cad. is it easy to do?

here is my code in vb:

 

Sub teste2()
'
' test2 Macro
' Adjust table
'

'
   Columns("A:A").EntireColumn.AutoFit
   Rows("1:7").Select
   Range("A7").Activate
   Selection.ClearContents
   Rows("1:7").Select
   Range("A7").Activate
   Selection.Delete Shift:=xlUp
   Columns("A:A").Select
   Selection.TextToColumns Destination:=Range("A1"), DataType:=xlFixedWidth, _
       FieldInfo:=Array(Array(0, 1), Array(8, 1), Array(26, 1), Array(42, 1), Array(58, 1), _
       Array(74, 1), Array(76, 1), Array(79, 1), Array(88, 1)), TrailingMinusNumbers:=True
   Columns("A:A").Select
   Selection.Delete Shift:=xlToLeft
   Columns("A:A").EntireColumn.AutoFit
   Columns("B:B").EntireColumn.AutoFit
   Columns("C:C").EntireColumn.AutoFit
   Columns("D:D").EntireColumn.AutoFit
   Columns("E:H").Select
   Selection.Delete Shift:=xlToLeft
End Sub

Link to comment
Share on other sites

Not sure if this will help or not, if it will even work, if you understand much about lisp.

 

I dont really have time to explain it right now but this is a scraped and cleaned/stripped/purged/bare minimum from another lisp i have.

 

If you need any help understanding it maybe some of the guys here can help you out.

 

WARNING NOT TESTED MAY CRASH YOUR SYSTEM

(vl-load-com)
;; use c:excel to run


(defun do-Excel ( / )
 (setq valuearray (ExcelArray "Name of Tab" (list "A1" "A2" "A3")))
 ;;enter stuff here
 )

(defun C:excel (/)
(setq excelfile "enter file location, name and extention here")
 (Kill-Excel)
 (if (= (Load-Excel) t)
   (progn
     (Open-Excel excelfile)
     (Save-Excel)
     (Kill-Excel)
     (gc)
     )
   (alert "\n Could not Initiate Symbol Library.\n")
   )
 (princ)
 )
   ))

(defun Load-Excel ( / )
 (setq sysdrv (getenv "systemdrive"))
 (cond
   ((setq tlb (findfile (strcat sysdrv "\\Program Files (x86)\\Microsoft Office\\Office\\Excel8.olb"))) tlb)
   ((setq tlb (findfile (strcat sysdrv "\\Program Files (x86)\\Microsoft Office\\Office\\Excel9.olb"))) tlb)
   ((setq tlb (findfile (strcat sysdrv "\\Program Files (x86)\\Microsoft Office\\Office\\Excel10.olb"))) tlb)
   ((setq tlb (findfile (strcat sysdrv "\\Program Files (x86)\\Microsoft Office\\Office\\Excel.exe"))) tlb)
   ((setq tlb (findfile (strcat sysdrv "\\Program Files (x86)\\Microsoft Office\\Office10\\Excel.exe"))) tlb)
   ((setq tlb (findfile (strcat sysdrv "\\Program Files (x86)\\Microsoft Office\\Office12\\Excel.exe"))) tlb)
   ((setq tlb (findfile (strcat sysdrv "\\Program Files (x86)\\Microsoft Office\\Office14\\Excel.exe"))) tlb)
   ((setq tlb (findfile (strcat sysdrv "\\Program Files\\Microsoft Office\\Office\\Excel8.olb"))) tlb)
   ((setq tlb (findfile (strcat sysdrv "\\Program Files\\Microsoft Office\\Office\\Excel9.olb"))) tlb)
   ((setq tlb (findfile (strcat sysdrv "\\Program Files\\Microsoft Office\\Office\\Excel10.olb"))) tlb)
   ((setq tlb (findfile (strcat sysdrv "\\Program Files\\Microsoft Office\\Office\\Excel.exe"))) tlb)
   ((setq tlb (findfile (strcat sysdrv "\\Program Files\\Microsoft Office\\Office10\\Excel.exe"))) tlb)
   ((setq tlb (findfile (strcat sysdrv "\\Program Files\\Microsoft Office\\Office12\\Excel.exe"))) tlb)
   ((setq tlb (findfile (strcat sysdrv "\\Program Files\\Microsoft Office\\Office14\\Excel.exe"))) tlb)
   )
 (cond
   ((null msxl-xl24HourClock)
    (if (setq tlbfile tlb)
      (progn
 (vlax-import-type-library
   :tlb-filename	tlbfile
   :methods-prefix    "msxl-"
   :properties-prefix "msxl-"
   :constants-prefix	"msxl-"
   )
 (if msxl-xl24HourClock
   (setq out T)
   )
 )
      )
    )
   (T (setq out T))
   )
 out
 )

(defun Open-Excel (excelfile/)
 (cond ((setq file (findfile excelfile))
 (progn(Alert "\nOpening Excel file...") file))
(t
 (progn
   (alert "\n Excel File Not found.")
     )
   )
  )
   (cond
     ((setq fn (findfile file))
      (cond
 ((setq session (vlax-get-or-create-object "Excel.Application"))
  (setq xlworkbook (vlax-invoke-method (vlax-get-property session 'WorkBooks)
		     'Open
		     fn
		     )
	)
  (setq xlsheets (vlax-get xlworkbook "Sheets"))
  (vla-put-visible session 0);; change to 1 and excel will be visible
  )
 )
      )
     (T
      (alert (strcat "\nCannot locate source file: " file)
      )
      )
     )
 (do-excel)
 )


;;kills excel
 (defun Kill-Excel (/)
   (setq session (vlax-get-object "Excel.Application"))
   (while (not (not session))
     (cond
((not (vlax-object-released-p session))(vlax-invoke-method session 'QUIT)(vlax-release-object session))
)
     (setq session nil)
     (gc)
     (gc)
     )
   )

;;saves excel
(defun Save-Excel (/)
 (vl-catch-all-apply
   'vlax-invoke-method
   (list xlworkbook "Save")
   )
 (vl-catch-all-apply
   'vlax-invoke-method
   (list xlworkbook "Close")
   )
 )


;;Use matrix to input mass values
;;(lstinput "Tab1" "A1" (list (list 0,3,5,6,19,200,4994,10)(list 0,4,5,6,1,3,4)(list 0,"","",6,1,3,4)))
;;Output starts at A1
;;0 3 5 6 19 200 4994 10
;;0 4 5 6  1  3   4     
;;0     6  1  3   4     
(defun lstinput (sheet startcell inputlst)
 (setq xlsheet (vlax-get-property xlsheets 'Item sheet))
 (vlax-invoke-method xlsheet 'Activate)
 (setq startrow 1)
 (foreach itm inputlst
   (setq startcol 1)
   (foreach sec itm
     (if (/= sec "")
(msxl-put-formula
  (vlax-variant-value
    (msxl-get-item (msxl-get-cells (msxl-get-Range xlsheet startcell))
      (vlax-make-variant startrow)
      (vlax-make-variant startcol)
      )
    )
  sec
  )
)
     (setq startcol (1+ startcol))
     )
   (setq startrow (1+ startrow))
   )
 )

;;Put Value in cell
;;(scinput tab cell value)
(defun scinput (sheet cell input)
 (setq xlsheet (vlax-get-property xlsheets 'Item sheet))
 (vlax-invoke-method xlsheet 'Activate)
 (setq xlcell (msxl-get-Range xlsheet cell))
 (msxl-put-Formula xlcell input)
 )

;;Moves Tab
;;(move-excel TabToMove TabToMoveBefore)
(defun Move-Excel (sheet before)
 (msxl-move (vlax-get-property xlsheets 'Item sheet) (vlax-get-property xlsheets 'Item before))
 )


;;Copies tab
;;(copy-excel Tab1 Tab2 Rename)
(defun Copy-Excel (sheet before Newname)
 (msxl-copy (vlax-get-property xlsheets 'Item sheet) (vlax-get-property xlsheets 'Item before))
 (setq xlCount (vlax-get-property xlSheets 'Count))
 (setq xlSheet
 (vlax-get-property xlSheets "Item"
   (vlax-get-property
     (vlax-get-property session 'ActiveSheet)
     'Name
     )
   )
)
 (vlax-put-property xlSheet 'Name Newname)
 )

;;Hides Rows
;;(Hide-Row Sheet RowsToHide)
(defun Hide-Rows (sheet rows)
 (setq xlSheet
 (vlax-get-property xlSheets "Item"
   (vlax-get-property
     (vlax-get-property session 'ActiveSheet)
     'Name
     )
   )
)
 (msxl-put-rowheight(msxl-get-Range xlsheet rows) (VLAX-MAKE-VARIANT 0 5))
 )

;;Takes Values from Excel and Stores them into an Lisp Array
;;(ExcelArray Tab1 (list "A1" "A2" "A3"))
(defun ExcelArray (sheet array) 
 (setq xlsheet (vlax-get-property xlsheets 'Item sheet))
 (vlax-invoke-method xlsheet 'Activate)
 (setq excel-values nil)
 (foreach cell array
   (setq xlcell (msxl-get-Range xlsheet cell))
   (setq value (msxl-get-Formula xlcell input))
   (setq excel-values (append excel-values (list values)))
   )
 excel-values
 )

Link to comment
Share on other sites

so i cam parse in excel and then export to cad

 

If you create the table in Excel you can do one of two things with it to get it into your AutoCAD drawing:

 

  1. Copy and paste the table using Windows clipboard. This will bring in an OLE object which you can edit later on.
  2. Create a data link from your AutoCAD drawing to the table in the Excel file. This too can be edited either from Excel or AutoCAD.

It sounds like what you're after though is to skip the Excel step and just use LISP to read and parse the text file. Then by carefully locating the text you parsed from the text file you can create a nice looking table. This is not impossible to do, but I can see that it will take some diligent perseverance to accomplish.

Link to comment
Share on other sites

wait so the information is already in the text file and you are putting it into the excel file?

 

if its a txt file this is what I have so far still have to finish some stuff

 

(defun c:txtTab (/)
 (setq file (getfiled "Select a Txt file" "" "txt" )
 (setq txt (open file "r"))
 (setq linetxt nil)
 (setq linetxtnew nil)
 (while (/= (setq line(read-line txt)) nil)
   (setq linetxt (append linetxt (list line)))
   )
 (foreach line linetxt
   (while (wcmatch line "*>*") (setq line (vl-string-subst "" ">" line)))
   (while (wcmatch line "*<*") (setq line (vl-string-subst "" "<" line)))
   (while (wcmatch line "*  *") (setq line (vl-string-subst " " "  " line)))
   (if (not (or (= line "")(= line " ")(wcmatch line "*Active Units Weight*")(wcmatch line "*Steel Take Off*")(wcmatch line "*and Number*")(wcmatch line "*ACTIVE UNITS WEIGHT KG*")))
     (setq linetxtnew (append linetxtnew (list line)))
     )
   )
 (setq parts 0)
 (setq weights 0)
 (setq partlist nil)
 (setq weightlist nil)
 (foreach line linetxtnew
   (if (wcmatch line "*{ *") (setq number (substr line 4 (- (vl-string-search "}" line) 3))))
   (if (wcmatch line "TOTAL LENGTH,")(setq parts 0))
   (if (= parts 1)
     (progn
;;filter parts 
)
     )
   (if (= weights 1)
     (progn
;;filter weights 
)
     )
   (if (wcmatch line "*Profile Names Total") (setq parts 1))
   (if (wcmatch line "TOTAL LENGTH,")(setq weights 1))
   )
 (princ (strcat "Item Number is: " Number))
 )

Edited by CADWarrior
Link to comment
Share on other sites

Here is a table lisp you are more than welcome to modify it only reads xyz but can be changed for more columns, Hey Bill re WOW to hard have a look at the date when I wrote this

 

                    ;SETOUTBOX.LSP
                   ; program to draw setout details as a co-ord list
                   ; 29/9/04 by alan H
(setvar "menuecho" 0)
(setvar "SNAPMODE" 0)
(SETQ OLDSNAP (GETVAR "OSMODE"))
(setvar "OSMODE" 0)
(defun xyz ()
 (setq ans "")
 (setq char_found "")
 (while (/= char_found ",")
   (setq char_found (substr new_line x 1))
   (setq x (+ x 1))
   (setq ans (strcat ans char_found))
 )                    ;end while
)                    ;end defun 
(setq setsc (/ (getreal "\nEnter Dwg scale 1: ") 1000.0))
(setq stpt (getpoint "\nPick top left point for details "))
(setq xyzfiles (getfiled "\nENTER CO-ORD File name  " "" "" 4))
(setq fopen (open xyzfiles "R"))
(command "zoom" "E")
(command "zoom" "c" stpt (* setsc 100.0))
(setq pt1 stpt)
(setq txtht (* 2.5 setsc))  ; 2.5mm HIGH LETTERING
(setq num 1)
(setq llen (* 84.0 setsc))
(setq ydiff (* 4.5 setsc))  ; 4.5mm line spacing
(setq stptx (car stpt))
(setq stpty (cadr stpt))

(setq txtpt (list (+ stptx (* 42.0 setsc)) (+ stpty (* 2.0 setsc))))
(command "text" "BC" txtpt txtht "" "xxxxx")

(setq txtpt (list (+ stptx (* 42.0 setsc)) (+ stpty (* 7.0 setsc))))
(command "text" "BC" txtpt txtht "" "%%uSETOUT DETAIL")
(setq pt2 (polar stpt 0.0 llen))
(command "line" stpt pt2 "")        ;draw horizontal line
(setq pt1 (polar stpt 4.7124 (* 5.75 setsc)))
(setq txtpt (polar pt1 0.0 (* 9.0 setsc)))
(command "text" "BC" txtpt (* 3.5 setsc) "" "POINT")
(setq txtpt (polar pt1 0.0 (* 34.0 setsc)))
(command "text" "BC" txtpt (* 3.5 setsc) "" "EASTING")
(setq txtpt (polar pt1 0.0 (* 67.0 setsc)))
(command "text" "BC" txtpt (* 3.5 setsc) "" " NORTHING ")
(setq pt1 (polar stpt 4.7124 (* 8.0 setsc)))
(setq pt2 (polar pt1 0.0 llen))
(command "line" pt1 pt2 "")        ;draw horizontal line
(setq pt1 (polar pt1 4.7124 (* 1.0 setsc)))
(setq pt2 (polar pt1 0.0 llen))
(command "line" pt1 pt2 "")        ;draw horizontal line below above
(setq pt1 (polar pt1 4.7124 (* 1.0 setsc)))
(setq pt2 (polar pt1 0.0 llen))
(command "line" pt1 pt2 "")        ;draw horizontal line below above

(setq pt3 pt1)                ; sets pt to last line position
;(setq pt5 (polar pt3 1.5708 (* 1.0 setsc)))      ; 1 mm above line
(setq pt5 pt3)                ; 0.5 mm above line
(SETQ XX 1)
(while (setq new_line (read-line fopen))
(PRINC XX)
 (setq x 1)
 (setq y 5)
 (xyz)
 (setq ptno ans)            ;pull ptno out
 (xyz)
 (setq easting ans)
 (xyz)
 (setq northing ans)

 (setq pt3 (polar pt3 4.7124 ydiff))
 (setq pt4 (polar pt3 0.0 llen))
 (command "line" pt3 pt4 "")
 (setq pt5 (polar pt5 4.7124 ydiff))
 (setq pt6 (polar pt5 0.0 (* 8.0 setsc)))
 (setq pt7 (polar pt5 0.0 (* 28.0 setsc)))
 (setq pt8 (polar pt5 0.0 (* 58.0 setsc)))
 (command "text" "BL" pt6 txtht "" ptno)
 (command "text" "BL" pt7 txtht "" EASTING)
 (command "text" "BL" pt8 txtht "" NORTHING)
(SETQ XX (+ XX 1))
)                    ; end while
(command "line" stpt pt3 "")
(setq pt3 (polar pt3 0.0 (* 18.0 setsc)))
(setq stpt (polar stpt 0.0 (* 18.0 setsc)))
(command "line" stpt pt3 "")
(setq pt3 (polar pt3 0.0 (* 33.0 setsc)))
(setq stpt (polar stpt 0.0 (* 33.0 setsc)))
(command "line" stpt pt3 "")
(setq pt3 (polar pt3 0.0 (* 33.0 setsc)))
(setq stpt (polar stpt 0.0 (* 33.0 setsc)))
(command "line" stpt pt3 "")
(princ setsc )
(setq pt1  nil
     pt2  nil
     pt3  nil
     pt4  nil
     pt5  nil
     pt6  nil
     pt7  nil
     pt8  nil
     stpt nil
     ans  nil
     SETSC NIL
)
(SETVAR "OSMODE" OLDSNAP)
(princ)

Link to comment
Share on other sites

Yes i need to import the information present in that .txt file to autocad.

thanks a lot CADWarrior tomorrow i'll test this routine.

 

NEXTMARCUS this isnt a finished product yet.

Steps needed:

1. Find location of file to extract data from (check)

(setq file (getfiled "Select a Txt file" "" "txt" )
 (setq txt (open file "r"))

 

2. Remove useless characters and lines (check)

(setq linetxt nil)
 (setq linetxtnew nil)
 (while (/= (setq line(read-line txt)) nil)
   (setq linetxt (append linetxt (list line)))
   )
 (foreach line linetxt
   (while (wcmatch line "*>*") (setq line (vl-string-subst "" ">" line)))
   (while (wcmatch line "*<*") (setq line (vl-string-subst "" "<" line)))
   (while (wcmatch line "*  *") (setq line (vl-string-subst " " "  " line)))
   (if (not (or (= line "")(= line " ")(wcmatch line "*Active Units Weight*")(wcmatch line "*Steel Take Off*")(wcmatch line "*and Number*")(wcmatch line "*ACTIVE UNITS WEIGHT KG*")))
     (setq linetxtnew (append linetxtnew (list line)))
     )
   )

 

3. Filter through each array and find the data need (wip)

 (setq parts 0)
 (setq weights 0)
 (setq partlist nil)
 (setq weightlist nil)
 (foreach line linetxtnew
   (if (wcmatch line "*{ *") (setq number (substr line 4 (- (vl-string-search "}" line) 3))))
   (if (wcmatch line "TOTAL LENGTH,")(setq parts 0))
   (if (= parts 1)
     (progn
   ;;filter parts (WIP)
   )
     )
   (if (= weights 1)
     (progn
   ;;filter weights (WIP)
   )
     )
   (if (wcmatch line "*Profile Names Total") (setq parts 1))
   (if (wcmatch line "TOTAL LENGTH,")(setq weights 1))
   )

4. Take arrays from above and input them into the drawing based on insertion point (not started yet)

5. Most coders say to close your variables but I usually dont so you can close them if you like (defun c:txtTab ( / VarNamesHere)

 

 

I have about 45 min before I hit the sack for the night. So, I will see what I can accomplish before the nights out.

 

 

 

 

 

 

I have 48 min before I head to bed I will see

Link to comment
Share on other sites

I know I know double post, I hate me too.... I just hate walls of text more :P

Here is the revised code so far it will output the values taken from the .txt file and show them in the command prompt.

 

(defun c:txtTab (/)
 (setq file (getfiled "Select a Txt file" "" "txt" )
 (setq txt (open file "r"))
 (setq linetxt nil)
 (setq linetxtnew nil)
 (while (/= (setq line(read-line txt)) nil)
   (setq linetxt (append linetxt (list line)))
   )
 (foreach line linetxt
   (while (wcmatch line "*WEIGHT*") (setq line (vl-string-subst "" "WEIGHT" line)))
   (while (wcmatch line "*LENGTH*") (setq line (vl-string-subst "" "LENGTH" line)))
   (while (wcmatch line "*VOLUME*") (setq line (vl-string-subst "" "VOLUME" line)))
   (while (wcmatch line "*>*") (setq line (vl-string-subst "" ">" line)))
   (while (wcmatch line "*<*") (setq line (vl-string-subst "" "<" line)))
   (while (wcmatch line "*=*") (setq line (vl-string-subst "" " = " line)))
   (while (wcmatch line "*  *") (setq line (vl-string-subst " " "  " line)))
   (while (wcmatch line " *") (setq line (vl-string-subst "" " " line)))
   (if (not (or (= line "")(= line " ")(wcmatch line "*Active Units Weight*")(wcmatch line "*Steel Take Off*")(wcmatch line "*and Number*")(wcmatch line "*ACTIVE UNITS KG*")))
     (setq linetxtnew (append linetxtnew (list line)))
     )
   )
 (setq parts 0)
 (setq weights 0)
 (setq partlist nil)
 (setq weightlist nil)
 (foreach line linetxtnew
   (if (wcmatch line "*{ *") (setq number (substr line 3 (- (vl-string-search "}" line) 2))))
   (if (wcmatch line "*SPECIFIED MEMBERS*")(setq parts 0))
   (if (= parts 1)
     (progn
(setq item1 (substr line 1 (vl-string-search " " line)))
(setq line (vl-string-subst "" (strcat item1 " ") line))
(setq item2 (substr line 1 (vl-string-search " " line)))
(setq line (vl-string-subst "" (strcat item2 " ") line))
(setq item3 (substr line 1 (vl-string-search " " line)))
(setq line (vl-string-subst "" (strcat item3 " ") line))
(setq item4 (substr line 1 (vl-string-search " " line)))
(setq line (vl-string-subst "" (strcat item4 " ") line))
(setq item5 (substr line 1 (vl-string-search " " line)))
(setq item2 (distof item2 2))
(setq item3 (distof item3 2))
(setq item4 (distof item4 2))
(setq partlist (append partlist (list (list (list "Profile Name" item1)(list "Total Length" item2)(list "Total Volume" item3)(list "Total Weight" item4)(list "Number of Members" item5)))))
)
     )
   (if (= weights 1)
     (progn
(setq item1 (substr line 1 (vl-string-search " " line)))
(setq line (vl-string-subst "" (strcat item1 " ") line))
(setq item2 (substr line 1 (vl-string-search " " line)))
(setq line (vl-string-subst "" (strcat item2 " ") line))
(setq item3 (substr line 1 (vl-string-search " " line)))
(setq line (vl-string-subst "" (strcat item3 " ") line))
(setq item1 (distof item1 2))
(setq item2 (distof item2 2))
(setq item3 (distof item3 2))
(setq weightlist (append weightlist (list (list (list "Length" item1)(list "Weight" item2)(list "Volume" item3)))))
)
     )
   (if (wcmatch line "*Profile Names Total*") (setq parts 1))
   (if (wcmatch line "*SPECIFIED MEMBERS*")(setq weights 1))
   )
 (princ (strcat "Item Number is: " Number))
 (princ)
 (foreach part partlist
   (print
     (strcat
(nth 0 (nth 0 part))": "(nth 1 (nth 0 part))"*---*"
(nth 0 (nth 1 part))": "(rtos (nth 1 (nth 1 part)))"*---*"
(nth 0 (nth 2 part))": "(rtos (nth 1 (nth 2 part)))"*---*"
(nth 0 (nth 3 part))": "(rtos (nth 1 (nth 3 part)))"*---*"
(nth 0 (nth 4 part))": "(nth 1 (nth 4 part))
)
     )
   )
 (foreach weight weightlist
   (print
     (strcat
(nth 0 (nth 0 weight))": "(rtos (nth 1 (nth 0 weight)))"*---*"
(nth 0 (nth 1 weight))": "(rtos (nth 1 (nth 1 weight)))"*---*"
(nth 0 (nth 2 weight))": "(rtos (nth 1 (nth 2 weight)))
)
     )
   )
 (princ)
 )

 

I will finish the rest of it tomorrow if you still need help. Note the above will account for some changes in the txt file you can add any amout of extra rows just not columns.

 

 

The values that are printed out above are stored in weightlist and partlist

 

As a side note did see an interesting error that I didnt have time to look into using Windows 7 64 bit and AutoCAD 2012 vanilla I noticed that a document saved to your desktop retrieved by using getfiled will only use the file name "blah.txt" instead of "C:\Users\Username\Desktop\blah.txt"

Link to comment
Share on other sites

Thanks again CADWarrior, i developed a vba program to extract the data and make the table but i think ur lisp routine will be more eficient.as I am new to AutoLISP, this will be an enriching experience, I think I'll learn a lot studying this code.

thanks BIGAL i'll try to modify the routine.

Link to comment
Share on other sites

... Hey Bill re WOW to hard have a look at the date when I wrote this

 

That's back when guys like us were still young, and desired by women, eh! :lol:

 

Pretty cool code too. I will snatch this for my uses later. The automated projects I work on here use OLE objects pasted in directly from Excel, but I've always told them that we need some way of drawing up our own tables when the time comes. Thanks BIGAL.

Link to comment
Share on other sites

Hi guys i loaded your program CADWarrior it has filtered correctly the data from the .txt file, now as you said lack placing the arrays in Table. Bad notices, my excel macro started to work bad, the part of the code that parse de data is a recorded macro, so for some reason that i dont know what is sometimes it dont parse correctly :(

 

thanks

 

sorry abot my very bad english :x

Link to comment
Share on other sites

NEXTMARCUS the drawing provided had 14+ items on it but the text file only has 4.... Are multiple txt files being used?

 

Also not 100% sure what all values from the txt file are equivalent to in the Drawing.

 

From Text file => To Drawing

Profile Names = Profile Names

Profile Total Length = ?????

Profile Total Volume = ?????

Profile Total Weight = Total Weight

# of Members = QT

TOTAL LENGTH = ?????

TOTAL WEIGHT = ?????

TOTAL VOLUME = ?????

????? = ÁREA (m²)

????? = ESPECIFICAÇÃO

Link to comment
Share on other sites

No, just one .txt file p/ table

 

there are just 4 equivalent values

 

Profile Names = Profile Names

Profile Total Weight = Total Weight

Profile Total Length=COMPR.(m)/area

# of Members = QT

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...