Jump to content

Recommended Posts

Posted

If the list contains only strings and numbers, perhaps use:

 

_$ (equal 
 (reverse (mapncar 1 (lambda (x / n) (if (numberp (setq n (read x))) n x)) lst))
 l
 1e-1
)
T

; Lee Mac
; https://www.theswamp.org/index.php?topic=52935.msg577618#msg577618
(defun mapncar ( n f l ) 
 (if (< 0 n)
   (mapcar '(lambda ( x ) (mapncar (1- n) f x)) l)
   (mapcar 'f l)
 )
)  

 

Its hard to help you without having a sample table to test on.

  • Replies 25
  • Created
  • Last Reply

Top Posters In This Topic

  • aloy

    11

  • Lee Mac

    9

  • Grrr

    4

  • BIGAL

    2

Top Posters In This Topic

Posted

Grrr,

Here's a drawing with a table. Column No 1 is integer, 2 is string so are p200 and p250. SideEntry1PE and Total PE have been edited to give numbers. All others are numbers. I need a list like the list 'l' in post No. 19.

 

Thanks.

 

Aloy

DrawingCopy.dwg

Posted
I'll put together an example if I find some time.

 

Try the commands SETTAB & GETTAB:

(defun c:settab ( / col ins lst row tab )
   (setq lst
      '(
           (4 "MH- 4" 1097.01  88.8977 0.0  6.49583 29.8119  0.0 0.0 "p200" 0.0 0.0 "p250" 0.0 0.0 0.0 0.0 0.0)
           (3 "MH- 3" 1091.32  92.0437 0.0 13.693   23.316   0.0 0.0 "p200" 0.0 0.0 "p250" 0.0 0.0 0.0 0.0 0.0)
           (2 "MH- 2" 1079.4   98.7786 0.0  9.62301  9.62301 0.0 0.0 "p200" 0.0 0.0 "p250" 0.0 0.0 0.0 0.0 0.0)
           (1 "MH-1"  1083.56 107.455  0.0  0.0      0.0     0.0 0.0 "p200" 0.0 0.0 "p250" 0.0 0.0 0.0 0.0 0.0)
       )
   )
   (if (setq ins (getpoint "\nInsertion point: "))
       (progn
           (setq tab
               (vla-addtable
                   (vlax-get-property
                       (vla-get-activedocument (vlax-get-acad-object))
                       (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace)
                   )
                   (vlax-3D-point (trans ins 1 0))
                   (1+ (length lst))
                   (length (car lst))
                   0.4
                   2.5
               )
           )
           (vla-put-regeneratetablesuppressed tab :vlax-true)
           (vla-deleterows tab 0 1)
           (setq row 0)
           (foreach sub lst
               (setq col 0)
               (foreach itm sub
                   (vla-setcellvalue tab row col itm)
                   (setq col (1+ col))
               )
               (setq row (1+ row))
           )
           (vla-put-regeneratetablesuppressed tab :vlax-false)
       )
   )
   (princ)
)
(defun c:gettab ( / sel )
   (if (setq sel (ssget "_+.:E:S" '((0 . "ACAD_TABLE"))))
       (mapcar 'print (cellvalues (vlax-ename->vla-object (ssname sel 0))))
   )
   (princ)
)
(defun cellvalues ( obj / col lst row tmp )
   (repeat (setq row (vla-get-rows obj))
       (repeat (setq row (1- row) col (vla-get-columns obj))
           (setq tmp (cons (vlax-invoke obj 'getcellvalue row (setq col (1- col))) tmp))
       )
       (setq lst (cons tmp lst) tmp nil)
   )
   lst
)
(vl-load-com) (princ)

Posted (edited)

Thanks very much Lee. This is beautifully done. With a minute variation to the parameters I was able to do the same thing I did via the excel route. So now we have a method to edit an autocad table and prepare a list out of it with all data types in it, intact!.

 

Thanks again Lee for your time.

 

Aloy.

Edited by aloy
Posted

You're very welcome Aloy, I'm glad that the code will prove useful.

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...