Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

problem Field row table

13 REPLIES 13
Reply
Message 1 of 14
andresep82
673 Views, 13 Replies

problem Field row table

hello again¡¡¡¡

 

I continue with my problems.....

 

I get attribute value from block and put it in a list:

 

(repeat (setq cnt (sslength sset))
      (setq attValue (GetAttributeValue (ssname sset i) "tag1"))
       (setq attValue2 (GetAttributeValue (ssname sset i) "tag2"))

    (setq tlst (list  attValue attValue2))

      (setq lst (cons tlst lst))
       (setq i (1+ i))
      )

 

When I try to put them in a table...

 

 

 (foreach item lst
        (vla-setText mytable
                     row 0
                      (last item)
                    )
        (setq row (1+ row))
      )   

 

 

only put  one ( attValue2) at column, and i like  put 2 values, each one in a column in the same row

 

some help?

 

 

sorry for my english.....

 

13 REPLIES 13
Message 2 of 14
pbejse
in reply to: andresep82


@andresep82 wrote:

 

 

 only put  one ( attValue2) at column, and i like  put 2 values, each one in a column in the same row 

 


The table only have one column? and you need to put two strings on the same column?  [strcat function]

 

or a table with 2 colums and tag1 coulmn 1 tag2 column 2 same row?

 

 

Message 3 of 14
andresep82
in reply to: andresep82

the second opcion.

 

a table with 2 colums and tag1 coulmn 1 tag2 column 2 same row

Message 4 of 14
pbejse
in reply to: andresep82


@andresep82 wrote:

the second opcion.

 

a table with 2 colums and tag1 coulmn 1 tag2 column 2 same row


And the exisitng table object row count will depend on the number of items of the list  "lst" or is it a pre-existing table with enough row count to accomodate the values?

 

Waht does your list look like anyway? [lst varialbe content]

 

Message 5 of 14
andresep82
in reply to: andresep82

 

 

table object row count will depend on the number of items of the list  "lst"

 

the list is that (i think tha y make it ok.....)

 

(setq tlst (list  attValue attValue2))

      (setq lst (cons tlst lst))

 

it that the corret form to make the list?

 

[lst varialbe variable]

Message 6 of 14
pbejse
in reply to: andresep82


@andresep82 wrote:

 

the list is that (i think tha y make it ok.....)

 

(setq tlst (list  attValue attValue2))

      (setq lst (cons tlst lst))

 

it that the corret form to make the list?

 

[lst varialbe variable]


From the looks of the code on your first post

 

(foreach item lst
(vla-setText mytable ;<--- the table is already existing

row 0  <-- and for every item on the list you are changing header title 

(last item)<--- with this on every loop

 

I cant make sense of it andresep82. that is why i'm asking those questions. 

 

If the exisitng table [mytable] only have two rows and your list is 10 long. you may need to add more rows before processing the list [lst] put the setting of text of the header and compare the row count and lenght of list before processing the lst variable at foreach

 

That is why i'm asking you what is the format of your lst. 

 

Got it?

Message 7 of 14
andresep82
in reply to: pbejse

ok...all the code

(vl-load-com)
(defun C:tablasup ( / *MS* attValue attValue2 CNT I LST MYTABLE PT1 ROW SSET TLST)



  (setq lst '()
 i 0
 *ms* (vla-get-modelspace
             (vla-get-activedocument
             (vlax-get-acad-object)))
  )
  ; prompt the user to select closed polylines
  (princ "\n Seleciona bloques ")
  (if (setq sset (ssget '((0 . "INSERT"))))
    ; if a valid selection set was generated, then proceed.
    (progn
    

	 (repeat (setq cnt (sslength sset))
      (setq attValue (GetAttributeValue (ssname sset i) "tag1"))
         (setq attValue2 (GetAttributeValue (ssname sset i) "tag2"))
	(setq tlst (list  attValue attValue2 ))

 
        (setq lst (cons tlst lst))
        (setq i (1+ i))
      )
      
      (setq pt1 (getpoint "\nPoint table: "))
      ; add the new table
      (setq myTable (vla-AddTable 
                    *ms* 
                    (vlax-3d-point pt1)
                    (+ 3 cnt)
                    2               
                    0.5            
                    4))         





      
      (vla-setText mytable 0 0 "title")
      (vla-setText mytable 1 0 "tag1")
      (vla-setText mytable 1 1 "tag2")
      (setq row 2)
      

       (vla-put-Vertcellmargin myTable 0.05) 
       (vla-put-Horzcellmargin myTable  0.05) 

(vla-setTextheight myTable acTitleRow 0.25) 
(vla-setTextheight myTable acHeaderRow 0.15) 
(vla-setTextheight myTable acDataRow 0.15) 

(vla-SetRowHeight myTable 0 2) 
(vla-SetRowHeight myTable 1 2) 

(vla-SetColumnWidth myTable 0 0.5)


(vla-SetColumnWidth myTable 1 1)

;;;;(vla-SetColumnWidth myTable 2 10.0)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

      ; loop through the list of polyline properties
      ; adding a line to the table that contains the
      ; area and the ObjectID
      (foreach item lst
        (vla-setText mytable
                     row
                     1 
			(strcat "attValue"

                     
                     	(last item))
                    

						)

       ; (vla-setText mytable row 0 (last item))
        (setq row (1+ row))
      )      
      
     
      (vlax-release-object myTable)      
      (vlax-release-object *ms*)      
    ); end progn

   
  ); end if
  (princ)
); end defun


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Get Attribute Value  -  Lee Mac
;; Returns the value held by the specified tag within the supplied block, if present.
;; Arguments:
;; blk - [ent] Block (Insert) Entity Name
;; tag - [str] Attribute TagString
;; Returns: [str] Attribute value, else nil if tag is not found.


(defun GetAttributeValue (blk tag / val enx)
    (while
      (and
        (null val)
        (= "ATTRIB"
           (cdr (assoc 0 (setq enx (entget (setq blk (entnext blk))))))
        )
      )
       (if (= (strcase tag) (strcase (cdr (assoc 2 enx))))
         (setq val (cdr (assoc 1 enx)))
       )
    )
  )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

                          

 when i selec 3,6,1000 block create a table  with 3,6,1000 row automatic,but the 1 column is empy,  i need tag1 coulmn 1 tag2 column 2 same row.

Message 8 of 14
pbejse
in reply to: andresep82


@andresep82 wrote:
 when i selec 3,6,1000 block create a table  with 3,6,1000 row automatic,but the 1 column is empy,  i need tag1 coulmn 1 tag2 column 2 same row.

 

(foreach item lst    
        (vla-setText mytable row  0 (strcat "AttValue: " (Car item)))
        (vla-setText mytable row  1 (strcat "AttValue: " (Cadr item)))
        (setq row (1+ row)) 
            )

 

Message 9 of 14
andresep82
in reply to: andresep82

yeah¡¡¡¡¡¡¡¡¡ work¡¡¡¡¡ thanks¡¡¡¡¡¡¡¡¡ thanks¡¡¡¡¡¡

 

and.....one more thing

 

when insert table.....It is inserted vertical stretched,It does not adjust to the texts, I  have to fit manually.Some to fix it?

Message 10 of 14
pbejse
in reply to: andresep82


@andresep82 wrote:
when insert table.....It is inserted vertical stretched,It does not adjust to the texts, I  have to fit manually.Some to fix it?

Adjust column width to length of text <---- here andresep82

Message 11 of 14
andresep82
in reply to: pbejse

hummmm.... this lips adjust column widtch,but not row widtch

 

 

(setq myTable (vla-AddTable
                    *ms*
                    (vlax-3d-point pt1)
                    (+ 3 cnt)
                    2               ;nunmer column
                    0.5            ; row height
                    4))         ; column widtch

 

always draw row height which 9 and i like 0.5 so I stretch manuality.    Smiley Sad

Message 12 of 14
pbejse
in reply to: andresep82


@andresep82 wrote:

hummmm.... this lips adjust column widtch,but not row widtch 

 


andresep82 .. width is column. row is height.

 

Here's what you do. capture the longest string and pass that to textbox function + margis.. for both columns [tag1 tag2]

 

Use the link i posted to figure out the coding. 

 

Holler if you need help

 

Message 13 of 14
andresep82
in reply to: andresep82

yeah¡¡¡¡¡¡¡¡¡¡¡¡¡

 

 

;;;;;;;;;;;;;;;;;;;

(setq i2 (+(length lst) 3))

(setq n 0)

(if 
	(< 3 i2)
(progn 

(repeat i2 

(vla-SetRowHeight myTable n 0.5)


(setq n (1+ n))

);end repeat

);end progn 
);end if

;;;;;;;;;;;;;;;;;;;

 Rudimentary, but work¡¡¡¡¡¡¡    

Message 14 of 14
pbejse
in reply to: andresep82


@andresep82 wrote:

yeah¡¡¡¡¡¡¡¡¡¡¡¡¡

 

 Rudimentary, but work¡¡¡¡¡¡¡    


Good for you.... Not sure how your table looks now... but on your orignal code you have this

 

(vla-SetRowHeight myTable 0 2)
(vla-SetRowHeight myTable 1 2)

 

Thinking you want it that way on purpose so you use a larger text size 

Your addition can very well be added here:

 

(foreach item lst    
        (vla-setText mytable row  0 (strcat "AttValue: " (Car item)))
        (vla-setText mytable row  1 (strcat "AttValue: " (Cadr item)))
        (vla-SetRowHeight myTable row 0.5);<----- Row height
        (setq row (1+ row)) 
            )

And move the modification of Header and Title height after that.

 

Maybe i'm missing something but what i thought you want is to adjust the width?

 

<<hummmm.... this lips adjust column widtch,but not row widtch>>

 

Anyways.. glad you had it sorted.

 

Cheers

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost