TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: HasanCAD on April 13, 2010, 02:08:35 PM

Title: How to but this list in a table
Post by: HasanCAD on April 13, 2010, 02:08:35 PM
Hi all

I have a list and want to but it in a table

How is this?

Code: [Select]
(setq curStr (strcase (strcat num:Pref(itoa num:Num)num:Suf)))  ; point number in sequence
(setq Tbl:ins (getpoint "\nPick Table insertion point "))       ; table insertion point
(setq tLst (list (1 0 "Point")   ; 1st column  has athe point number
(1 1 "X")       ; 2nd
                 (1 2 "Y")       ; 3rd
                 (1 3 "Remarks") ; 4th
                 )       ;I dont know if this list strucutre correct or not.
       )                 ; end setq
Title: Re: How to but this list in a table
Post by: alanjt on April 13, 2010, 03:16:07 PM
Quick and crude...

Code: [Select]
(or *AcadDoc* (setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
(and (setq p (getpoint "\nTable placement point: "))
     (setq tab (vla-AddTable
                 (if (or (eq acmodelspace (vla-get-activespace *AcadDoc*))
                         (eq :vlax-true (vla-get-mspace *AcadDoc*))
                     ) ;_ or
                   (vla-get-modelspace *AcadDoc*)
                   (vla-get-paperspace *AcadDoc*)
                 )
                 (vlax-3d-point p)
                 4
                 4
                 5.
                 5.
               )
     )
     (foreach x (list '(1 0 "Point")
                      '(1 1 "X")
                      '(1 2 "Y")
                      '(1 3 "Remarks")
                )
       (vla-SetText tab (car x) (cadr x) (caddr x))
     )
)
Title: Re: How to but this list in a table
Post by: HasanCAD on April 20, 2010, 07:41:28 AM
table is ok but empty
Title: Re: How to but this list in a table
Post by: alanjt on April 20, 2010, 08:13:14 AM
Based on the information provided, it's as full as it can be.
Title: Re: How to but this list in a table
Post by: Kerry on April 20, 2010, 08:15:00 AM

 :-)
Title: Re: How to but this list in a table
Post by: Lee Mac on April 20, 2010, 08:18:27 AM
Based on the information provided, it's as full as it can be.

 :-D
Title: Re: How to but this list in a table
Post by: HasanCAD on April 20, 2010, 09:13:33 AM
I cant get the relation between the picked points and the text inserted in table
when table added inside the loop each time picked point creats a table

I created the table as a function and this function called in error function

Code: [Select]
(defun *error* (msg)
    (tbleInsert)
    (princ))

table
Code: [Select]
(setq Pnt:Lst (cons(list (curStr (car NumPnt) (cadr NumPnt))) Pnt:Lst))

(defun tbleInsert ()
(and ;(setq p (getpoint "\nTable placement point: "))
     (setq tab (vla-AddTable
                 (if (or (eq acmodelspace (vla-get-activespace *AcadDoc*)) (eq :vlax-true (vla-get-mspace *AcadDoc*))) ;_ or
                   (vla-get-modelspace *AcadDoc*) (vla-get-paperspace *AcadDoc*)) ;if
                 (vlax-3d-point Tbl:ins) (1+ num:Num) 4 (* 10 (getvar "DIMTXT")) (* 10 (getvar "DIMTXT"))))
     (foreach tLst (list '(0 0 "Coordenate")
      '(1 0 "Point")
                      '(1 1 "X")
                      '(1 2 "Y")
                      '(1 3 "Remarks")
                )
       (vla-SetText tab (car tLst) (cadr tLst) (caddr x))
     )
)
)

Thanks
Title: Re: How to but this list in a table
Post by: Lee Mac on April 20, 2010, 09:15:29 AM
Why call it in the error function?

Title: Re: How to but this list in a table
Post by: HasanCAD on April 20, 2010, 12:37:09 PM
Why call it in the error function?



This idea came to my mind.
OK, How to stop the loop then call the table?
Title: Re: How to but this list in a table
Post by: Lee Mac on April 20, 2010, 03:20:31 PM
You need to have a test expression that evaluates to nil when you wish the loop to end.