Get Attrbute and coordinates from block and creat Table

Get Attrbute and coordinates from block and creat Table

C.Utzinger
Collaborator Collaborator
3,387 Views
13 Replies
Message 1 of 14

Get Attrbute and coordinates from block and creat Table

C.Utzinger
Collaborator
Collaborator

HI

 

I have the attached Block and I was trying to modify the following code to extract the one Attribute, get the coordinates and create a table.

 

(defun c:<Test7 (/ *error* :sortlst acapp acol acsp adoc atable attdata attitem atts blkdata blkname blkobj col
                   column colwidth datalist en headers pt row ss swap  tabledata tags total txtheight widths x) 
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (command-s "_.UCS" "_P")
    (princ))

  ;; Lee Mac
  ;; http://www.lee-mac.com/attributefunctions.html
  
  (defun LM:vl-getattributes ( blk )
    (mapcar '(lambda (att) (cons (vla-get-tagstring att) (vla-get-textstring att)))
            (vlax-invoke blk 'getattributes)))
  
  ;; ObjectID  -  Lee Mac
  ;; Returns a string containing the ObjectID of a supplied VLA-Object
  ;; Compatible with 32-bit & 64-bit systems
  
  (defun LM:objectid ( obj )
    (eval (list 'defun 'LM:objectid '(obj)
                (if (and (wcmatch (getenv "PROCESSOR_ARCHITECTURE") "*64*")
                         (vlax-method-applicable-p (vla-get-utility (LM:acdoc)) 'getobjectidstring))
                  (list 'vla-getobjectidstring (vla-get-utility (LM:acdoc)) 'obj ':vlax-false)
                  '(itoa (vla-get-objectid obj)))))
    (LM:objectid obj))
  
  ;; Active Document  -  Lee Mac
  ;; Returns the VLA Active Document Object
  
  (defun LM:acdoc nil
    (eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object))))
    (LM:acdoc))


  
  
  ; ----------------------------------------------------------------------------------------------------------------------------
  ; ----------------------------------------------------------------------------------------------------------------------------  

  (command "_.UCS" "_W")

  (setq flt "SPI-Datenextraktionspunkt-CM*")

  (if (setq ss (ssget (list '(0 . "INSERT") (cons 2 flt) '(66 . 1))))
    (progn
      (repeat (setq i (sslength ss))
        (setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i))))
              tabledata (cons (LM:vl-getattributes obj) tabledata)))
      
      (setq tabledata (vl-remove nil tabledata)
            headers (mapcar 'car (car tabledata))
            tags    headers
            tabledata (mapcar '(lambda (x) (mapcar 'cdr x))
                              tabledata))
      
      ;; sort by "A1" :
      
      (setq tabledata (vl-sort tabledata '(lambda (a b)(< (car a)(car b)))))
      
      (if (= tabledata nil)(progn (alert "Keine Daten gefunden!")(exit)))

      (setq total 0)
      (foreach i datalist (setq total (+ total (cdr i))))
      
      (setq txtheight (if (= btog10 1)(* 15 0.01) 15))
      
      (or adoc (setq adoc (vla-get-activedocument (setq acapp (vlax-get-acad-object)))))
      (or acsp (setq acsp (vla-get-block (vla-get-activelayout adoc))))
      (setq acCol (vla-GetInterfaceObject acapp(strcat "AutoCAD.AcCmColor." (itoa (atoi (getvar "acadver"))))))
      
      (setq pt (getpoint (strcat "\n" Typ. " Tabelle einfügen:"))
            atable (vla-addtable
                     acsp
                     (vlax-3d-point pt)
                     (+ 2 (length tabledata))
                     (length headers)
                     (* txtheight 1.2)
                     (* txtheight 20)))
      
      (vla-put-regeneratetablesuppressed atable :vlax-true)
      
      ;; calculate column widths :
      (setq swap (append (list headers) tabledata)
            widths nil)
      (while (car swap)
        (setq column (mapcar 'car swap)
              colwidth (* 1.2 (apply 'max (mapcar 'strlen column)) txtheight)
              widths (cons colwidth widths)
              swap (mapcar 'cdr swap)))
      
      (setq widths (reverse widths))
      ;; set column widths
      (setq col 0)
      
      (foreach wid widths
        (vla-setcolumnwidth atable col wid)
        (setq col (1+ col)))

      (vla-put-colorindex acCol 8)
      (vla-setgridcolor atable 61 7 acCol)
      
      (vla-put-horzcellmargin atable (* txtheight 0.5))
      (vla-put-vertcellmargin atable (* txtheight 0.3))
      (vla-setTextheight atable 1 (* txtheight 0.8))
      (vla-setTextheight atable 2 (* txtheight 1.2))
      (vla-setTextheight atable 4 (* txtheight 0.9))
      (vla-setText atable 0 0 "Koordinaten")
      (vla-SetCellAlignment atable 0 0 acMiddleCenter)
      (vla-put-colorindex acCol 3)
      (vla-setcellcontentcolor atable 0 0 acCol)
   
      (setq col -1)
      (foreach descr headers
        (vla-SetTextStyle atable (+ acHeaderRow acDataRow acTitleRow) "Simplex7-12.5")
        (vla-setText atable 1 (setq col (1+ col)) descr)
        (vla-SetCellAlignment atable 1 col acMiddleCenter)
        (vla-setcellcontentcolor atable 1 col acCol))
      
      (vla-put-colorindex acCol 4)  

      (setq row 2)
      
      (foreach record tabledata
        (setq col 0)
        (foreach item record
          (vla-setText atable row col item)
          (if (= 1 col)
            (vla-SetCellAlignment atable row col acMiddleCenter)
            (vla-SetCellAlignment atable row col acMiddleCenter))
          (vla-setcellcontentcolor atable row col acCol)
          (setq col (1+ col)))
        (setq row (1+ row)))
     



      (vla-put-width atable (apply '+ widths))
      (vla-put-height atable (* 1.2 (vla-get-rows atable)txtheight))
      (vla-put-regeneratetablesuppressed atable :vlax-false))

    (progn (alert "Keine Objekte gewählt!")(exit)))
 
  (command "_.UCS" "_P")
  
  (if  acCol (vlax-release-object acCol))
  (if  acapp (vlax-release-object acapp))

  (princ)
  )

 

The table I will get:

 

 KoordNr.             x                            y

     001        000000,000           000000,000

     002        000000,000           000000,000

     003        000000,000           000000,000

 

Can you help me get to this?

 

BeekeeCZ: If you read this... Yes I was trying to modify your code from the last month :)...

 

 

Kind regards...

0 Likes
Accepted solutions (1)
3,388 Views
13 Replies
Replies (13)
Message 2 of 14

C.Utzinger
Collaborator
Collaborator

Now it works, but i need to get the coordinates...

 

 

(vl-load-com)

(defun c:<Test6 (/ :sortlst acapp acol acsp adoc atable attdata attitem atts blkdata blkname blkobj col
                   column colwidth  datalist en headers pt row ss swap  tabledata tags total txtheight widths x flt)
  
  ;; Lee Mac
  ;; http://www.lee-mac.com/attributefunctions.html
  
  (defun LM:vl-getattributes ( blk )
    (mapcar '(lambda (att) (cons (vla-get-tagstring att) (vla-get-textstring att)))
            (vlax-invoke blk 'getattributes)))
  
  ;; ObjectID  -  Lee Mac
  ;; Returns a string containing the ObjectID of a supplied VLA-Object
  ;; Compatible with 32-bit & 64-bit systems
  
  (defun LM:objectid ( obj )
    (eval (list 'defun 'LM:objectid '(obj)
                (if (and (wcmatch (getenv "PROCESSOR_ARCHITECTURE") "*64*")
                         (vlax-method-applicable-p (vla-get-utility (LM:acdoc)) 'getobjectidstring))
                  (list 'vla-getobjectidstring (vla-get-utility (LM:acdoc)) 'obj ':vlax-false)
                  '(itoa (vla-get-objectid obj)))))
    (LM:objectid obj))
  
  ;; Active Document  -  Lee Mac
  ;; Returns the VLA Active Document Object
  
  (defun LM:acdoc nil
    (eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object))))
    (LM:acdoc))
  
  
  ; ----------------------------------------------------------------------------------------------------------------------------
  ; ----------------------------------------------------------------------------------------------------------------------------
  
  (setq flt "SPI-Datenextraktionspunkt-CM*")
  
  (if (setq ss (ssget (list '(-4 . "<OR")
			    '(-4 . "<AND") '(0 . "INSERT") (cons 2 flt) '(66 . 1) '(-4 . "AND>")
			     '(-4 . "OR>"))))
    (progn
      (repeat (setq i (sslength ss))
        (setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i))))
              tabledata (cons (LM:vl-getattributes obj) tabledata)))
  
      (setq tabledata (vl-remove nil tabledata)
            headers (mapcar 'car (car tabledata))
            tags    headers
            tabledata (mapcar '(lambda (x) (mapcar 'cdr x))
                              tabledata))
      
      ;; sort by "A1" :
      
      (setq tabledata (vl-sort tabledata '(lambda (a b)(< (car a)(car b)))))
      
      (setq total 0)
      (foreach i datalist (setq total (+ total (cdr i))))
      
      
      (setq txtheight 15)
      
      (or adoc (setq adoc (vla-get-activedocument (setq acapp (vlax-get-acad-object)))))
      (or acsp (setq acsp (vla-get-block (vla-get-activelayout adoc))))
      (setq acCol (vla-GetInterfaceObject acapp(strcat "AutoCAD.AcCmColor." (itoa (atoi (getvar "acadver"))))))
      
      (setq pt (getpoint "\nSpecify table location:")
            atable (vla-addtable
                     acsp
                     (vlax-3d-point pt)
                     (+ 2 (length tabledata))
                     (length headers)
                     (* txtheight 1.2)
                     (* txtheight 20)))
      
      (vla-put-regeneratetablesuppressed atable :vlax-true)
      
      ;; calculate column widths :
      (setq swap (append (list headers) tabledata)
            widths nil)
      (while (car swap)
        (setq column (mapcar 'car swap)
              colwidth (* 1.2 (apply 'max (mapcar 'strlen column)) txtheight)
              widths (cons colwidth widths)
              swap (mapcar 'cdr swap)))
      
      (setq widths (reverse widths))
      ;; set column widths
      (setq col 0)
      
      (foreach wid widths
        (vla-setcolumnwidth atable col wid)
        (setq col (1+ col)))

      (vla-put-colorindex acCol 8)
      (vla-setgridcolor atable 61 7 acCol)
      
      (vla-put-horzcellmargin atable (* txtheight 0.5))
      (vla-put-vertcellmargin atable (* txtheight 0.3))
      (vla-setTextheight atable 1 (* txtheight 0.8))
      (vla-setTextheight atable 2 (* txtheight 1.2))
      (vla-setTextheight atable 4 (* txtheight 0.9))
      (vla-setText atable 0 0 "Koordinaten")
      (vla-SetCellAlignment atable 0 0 acMiddleCenter)
      (vla-put-colorindex accol 3)
      (vla-setcellcontentcolor atable 0 0 accol)
      
      (setq col -1)
      (foreach descr headers
        (vla-SetTextStyle atable (+ acHeaderRow acDataRow acTitleRow) "Simplex7-12.5")
        (vla-setText atable 1 (setq col (1+ col)) descr)
        (vla-SetCellAlignment atable 1 col acMiddleCenter)
        (vla-setcellcontentcolor atable 1 col accol))
      
      (vla-put-colorindex accol 4)
      
      (setq row 2)
      
      (foreach record tabledata
        (setq col 0)
        (foreach item record
          (vla-setText atable row col item)
          (if (= 1 col)
            (vla-SetCellAlignment atable row col acMiddleCenter)
            (vla-SetCellAlignment atable row col acMiddleCenter))
          (vla-setcellcontentcolor atable row col accol)
          (setq col (1+ col)))
        (setq row (1+ row)))
      
      (vla-put-width atable (apply '+ widths))
      (vla-put-height atable (* 1.2 (vla-get-rows atable)txtheight))
      (vla-put-regeneratetablesuppressed atable :vlax-false)))
  
  (if  accol (vlax-release-object accol))
  (if  acapp (vlax-release-object acapp))
  (princ)
  )

(princ)
0 Likes
Message 3 of 14

SeeMSixty7
Advisor
Advisor

Since you need the insertion points, it would make sense to get that data as you retrieve the attribute tags and values.

 

Try something like this to build your table data instead. I created a function to get the attributes tags, value and insertion point for you below.

 

(defun GetInsPointOfAttAndValue (blockobj)
  	  (setq returnlist (list))
  	  (foreach attobj (vlax-safearray->list (vlax-variant-value (vla-getattributes blockobj)))
  	  	  (setq returnlist (append returnlist (list 
  	  	  			  (list (vla-get-TagString attobj) (vla-get-TextString attobj) (vlax-safearray->list (vlax-variant-value (vla-get-insertionpoint attobj))))))
  	  	  )
  	  )
  	  returnlist
)
....Your Code...
(setq tabledata (list))
(repeat (setq i (sslength ss))
        (setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i))))
              ;tabledata (cons (LM:vl-getattributes obj) tabledata));your previous method
              tabledata (append tabledata (list (getinspointofattandvalue obj)));new format
         )
)

...rest of your code
You will need to update how you handle the list since it will be a different format now though.

 

Good luck,

Message 4 of 14

SeeMSixty7
Advisor
Advisor

Question: Are you wanting the cords of the attribute or the block insertion?

 

I was continuing some effort on this then realized you might want the block insertion and not the attribute insertion points.

 

 

0 Likes
Message 5 of 14

C.Utzinger
Collaborator
Collaborator

I just wanted to write you 🙂

 

I fixed the code and saw it. I Need the insert point, not the Attribute!

 

Thank you...

 

(vl-load-com)

(defun c:<Test6 (/ :sortlst acapp acol acsp adoc atable attdata attitem atts blkdata blkname blkobj col
                   column colwidth  datalist en headers pt row ss swap  tabledata tags total txtheight widths x flt)
  
  ;; Lee Mac
  ;; http://www.lee-mac.com/attributefunctions.html
  
  (defun LM:vl-getattributes ( blk )
    (mapcar '(lambda (att) (cons (vla-get-tagstring att) (vla-get-textstring att)))
            (vlax-invoke blk 'getattributes)))
  
  ;; ObjectID  -  Lee Mac
  ;; Returns a string containing the ObjectID of a supplied VLA-Object
  ;; Compatible with 32-bit & 64-bit systems
  
  (defun LM:objectid ( obj )
    (eval (list 'defun 'LM:objectid '(obj)
                (if (and (wcmatch (getenv "PROCESSOR_ARCHITECTURE") "*64*")
                         (vlax-method-applicable-p (vla-get-utility (LM:acdoc)) 'getobjectidstring))
                  (list 'vla-getobjectidstring (vla-get-utility (LM:acdoc)) 'obj ':vlax-false)
                  '(itoa (vla-get-objectid obj)))))
    (LM:objectid obj))
  
  ;; Active Document  -  Lee Mac
  ;; Returns the VLA Active Document Object
  
  (defun LM:acdoc nil
    (eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object))))
    (LM:acdoc))
  


(defun GetInsPointOfAttAndValue (blockobj)
  	  (setq returnlist (list))
  	  (foreach attobj (vlax-safearray->list (vlax-variant-value (vla-getattributes blockobj)))
  	  	  (setq returnlist (append returnlist (list 
  	  	  			  (list (vla-get-TagString attobj) (vla-get-TextString attobj) (vlax-safearray->list (vlax-variant-value (vla-get-insertionpoint attobj))))))
  	  	  )
  	  )
  	  returnlist
)
  

(defun :sortlst ( lst / mlst nlst)

    (foreach item lst
	(setq nlst (cons (assoc "01" item) nlst)))

    (foreach e nlst
	(setq mlst (cons (list(cons (car e)(cadr e))(cons "x" (rtos(car(last e))))(cons "y" (rtos(cadr(last e))))) mlst)))
)


  ; ----------------------------------------------------------------------------------------------------------------------------
  ; ----------------------------------------------------------------------------------------------------------------------------
  
  (setq flt "SPI-Datenextraktionspunkt-CM*")
  
  (if (setq ss (ssget (list '(-4 . "<OR")
			    '(-4 . "<AND") '(0 . "INSERT") (cons 2 flt) '(66 . 1) '(-4 . "AND>")
			     '(-4 . "OR>"))))
    (progn
  
	(setq tabledata (list))
	(repeat (setq i (sslength ss))
 	       (setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i))))
 	             tabledata (append tabledata (list (getinspointofattandvalue obj)))
 	        )
	)

      (setq tabledata (vl-remove nil tabledata)
            tabledata (:sortlst tabledata)
            headers (mapcar 'car (car tabledata))
            tags    headers
            tabledata (mapcar '(lambda (x) (mapcar 'cdr x))
                              tabledata))
      
      ;; sort by "A1" :
      
      (setq tabledata (vl-sort tabledata '(lambda (a b)(< (car a)(car b)))))
      
      (setq total 0)
      (foreach i datalist (setq total (+ total (cdr i))))
      
      
      (setq txtheight 15)
      
      (or adoc (setq adoc (vla-get-activedocument (setq acapp (vlax-get-acad-object)))))
      (or acsp (setq acsp (vla-get-block (vla-get-activelayout adoc))))
      (setq acCol (vla-GetInterfaceObject acapp(strcat "AutoCAD.AcCmColor." (itoa (atoi (getvar "acadver"))))))
      
      (setq pt (getpoint "\nSpecify table location:")
            atable (vla-addtable
                     acsp
                     (vlax-3d-point pt)
                     (+ 2 (length tabledata))
                     (length headers)
                     (* txtheight 1.2)
                     (* txtheight 20)))
      
      (vla-put-regeneratetablesuppressed atable :vlax-true)
      
      ;; calculate column widths :
      (setq swap (append (list headers) tabledata)
            widths nil)
      (while (car swap)
        (setq column (mapcar 'car swap)
              colwidth (* 1.2 (apply 'max (mapcar 'strlen column)) txtheight)
              widths (cons colwidth widths)
              swap (mapcar 'cdr swap)))
      
      (setq widths (reverse widths))
      ;; set column widths
      (setq col 0)
      
      (foreach wid widths
        (vla-setcolumnwidth atable col wid)
        (setq col (1+ col)))

      (vla-put-colorindex acCol 8)
      (vla-setgridcolor atable 61 7 acCol)
      
      (vla-put-horzcellmargin atable (* txtheight 0.5))
      (vla-put-vertcellmargin atable (* txtheight 0.3))
      (vla-setTextheight atable 1 (* txtheight 0.8))
      (vla-setTextheight atable 2 (* txtheight 1.2))
      (vla-setTextheight atable 4 (* txtheight 0.9))
      (vla-setText atable 0 0 "Koordinaten")
      (vla-SetCellAlignment atable 0 0 acMiddleCenter)
      (vla-put-colorindex accol 3)
      (vla-setcellcontentcolor atable 0 0 accol)
      
      (setq col -1)
      (foreach descr headers
        (vla-SetTextStyle atable (+ acHeaderRow acDataRow acTitleRow) "Simplex7-12.5")
        (vla-setText atable 1 (setq col (1+ col)) descr)
        (vla-SetCellAlignment atable 1 col acMiddleCenter)
        (vla-setcellcontentcolor atable 1 col accol))
      
      (vla-put-colorindex accol 4)
      
      (setq row 2)
      
      (foreach record tabledata
        (setq col 0)
        (foreach item record
          (vla-setText atable row col item)
          (if (= 1 col)
            (vla-SetCellAlignment atable row col acMiddleCenter)
            (vla-SetCellAlignment atable row col acMiddleCenter))
          (vla-setcellcontentcolor atable row col accol)
          (setq col (1+ col)))
        (setq row (1+ row)))
      
      (vla-put-width atable (apply '+ widths))
      (vla-put-height atable (* 1.2 (vla-get-rows atable)txtheight))
      (vla-put-regeneratetablesuppressed atable :vlax-false)))
  
  (if  accol (vlax-release-object accol))
  (if  acapp (vlax-release-object acapp))
  (princ)
  )

Kind regards

0 Likes
Message 6 of 14

SeeMSixty7
Advisor
Advisor

Great, Did you get it working the way you wanted then?

 

0 Likes
Message 7 of 14

C.Utzinger
Collaborator
Collaborator

NO 😞

 

Just what you asked me. I need the Block insertpoint!!!

 

Can you fix this?

 

Kind regards

0 Likes
Message 8 of 14

SeeMSixty7
Advisor
Advisor

Yes I can, but I have to ask, why do you have a multiline attribute for that attribute?

 

0 Likes
Message 9 of 14

C.Utzinger
Collaborator
Collaborator
Because I have a shadow (i don't know if that is the correct word in English) behind. With a normal Text it is not possible (or is it?)
0 Likes
Message 10 of 14

SeeMSixty7
Advisor
Advisor

Ok, and just to verify we are sorting on the value of the attribute and not the x or y coordinate, right?

 

Will all the attribute values be a unique coordinate number? 1,2,3,4,5... seems like they should, but just want to make sure.

 

Thanks,

0 Likes
Message 11 of 14

C.Utzinger
Collaborator
Collaborator
Yes exactly. Every Block his number and coordinates.
0 Likes
Message 12 of 14

SeeMSixty7
Advisor
Advisor
Accepted solution

Try this. I had to rush through the end as I re-wrote most of it. I'll check back Monday.

 

Good Luck,

(defun GetAttAndValue (blockobj)
  	  (setq returnlist (list))
  	  (foreach attobj (vlax-safearray->list (vlax-variant-value (vla-getattributes blockobj)))
  	  	  (setq returnlist (append returnlist (list 
  	  	  			  (list (vla-get-TagString attobj) (vla-get-TextString attobj))))
  	  	  )
  	  )
  	  returnlist
)
(defun c:quick( / :sortlst acapp acol acsp adoc atable attdata attitem atts blkdata blkname blkobj col
                   column colwidth  datalist en pt row ss swap tabledata header tags total txtheight widths x flt)
	(setq flt "SPI-Datenextraktionspunkt-CM*")
    (if (setq ss (ssget (list '(-4 . "<OR")
			    '(-4 . "<AND") '(0 . "INSERT") (cons 2 flt) '(66 . 1) '(-4 . "AND>")
			     '(-4 . "OR>"))))
        (progn
			(setq KoordNumList (list)
				  xydata (list)
				  header  (list "KoordNr." "x" "y")
			)
			
			(repeat (setq i (sslength ss))
				(setq ent (ssname ss (setq i (1- i)))
					  entdata (entget ent)
					  inspt (cdr (assoc 10 entdata))
					  attdata (GetAttAndValue (vlax-ename->vla-object ent))
					  attvalue (nth 1 (nth 0 attdata))
					  attvalue (substr attvalue 10) ; get rid of default formatting
					  koordnumlist (append koordnumlist (list attvalue))
					  xydata (append xydata (list (list attvalue (list (car (cdr (assoc 10 entdata))) (cadr (cdr (assoc 10 entdata))))))) 
				)
			)
			(setq koordnumlist (acad_strlsort koordnumlist)
			      total (sslength ss)
			      txtheight 15
			)
			(or adoc (setq adoc (vla-get-activedocument (setq acapp (vlax-get-acad-object)))))
			(or acsp (setq acsp (vla-get-block (vla-get-activelayout adoc))))
			(setq acCol (vla-GetInterfaceObject acapp(strcat "AutoCAD.AcCmColor." (itoa (atoi (getvar "acadver"))))))
			(setq pt (getpoint "\nSpecify table location:")
				  atable (vla-addtable
						 acsp
						 (vlax-3d-point pt)
						 (+ 2 total)
						 (length header)
						 (* txtheight 1.2)
						 (* txtheight 20))
		    )
		    (vla-put-regeneratetablesuppressed atable :vlax-true)
		    (setq cnt 0
		    	  tabledata (list)
		    )
		    (foreach koord koordnumlist
		    	(setq xy (assoc koord xydata)
		    		  tabledata (append tabledata (list (list koord (rtos (car (cadr xy)) 2 1) (rtos (cadr (cadr xy)) 2 1))))
		    	)
		    )
		    (setq swap (append (list header) tabledata)
				  widths nil)
		  (while (car swap)
			(setq column (mapcar 'car swap)
				  colwidth (* 1.2 (apply 'max (mapcar 'strlen column)) txtheight)
				  widths (cons colwidth widths)
				  swap (mapcar 'cdr swap)))
		  
		  (setq widths (reverse widths))
		  ;; set column widths
		  (setq col 0)
		  
		  (foreach wid widths
			(vla-setcolumnwidth atable col wid)
			(setq col (1+ col))
		  )
	
		  (vla-put-colorindex acCol 8)
		  (vla-setgridcolor atable 61 7 acCol)
		  
		  (vla-put-horzcellmargin atable (* txtheight 0.5))
		  (vla-put-vertcellmargin atable (* txtheight 0.3))
		  (vla-setTextheight atable 1 (* txtheight 0.8))
		  (vla-setTextheight atable 2 (* txtheight 1.2))
		  (vla-setTextheight atable 4 (* txtheight 0.9))
		  (vla-setText atable 0 0 "Koordinaten")
		  (vla-SetCellAlignment atable 0 0 acMiddleCenter)
		  (vla-put-colorindex accol 3)
		  (vla-setcellcontentcolor atable 0 0 accol)
		  
		  (setq col -1)
		  (foreach descr header
			(vla-SetTextStyle atable (+ acHeaderRow acDataRow acTitleRow) "Simplex7-12.5")
			(vla-setText atable 1 (setq col (1+ col)) descr)
			(vla-SetCellAlignment atable 1 col acMiddleCenter)
			(vla-setcellcontentcolor atable 1 col accol)
		  )
		  
		  (vla-put-colorindex accol 4)
		  
		  (setq row 2)
		  
		  (foreach record tabledata
			(setq col 0)
			(foreach item record
			  (vla-setText atable row col item)
			  (if (= 1 col)
				(vla-SetCellAlignment atable row col acMiddleCenter)
				(vla-SetCellAlignment atable row col acMiddleCenter))
			  (vla-setcellcontentcolor atable row col accol)
			  (setq col (1+ col)))
			(setq row (1+ row)))
		  
		  (vla-put-width atable (apply '+ widths))
		  (vla-put-height atable (* 1.2 (vla-get-rows atable)txtheight))
		  (vla-put-regeneratetablesuppressed atable :vlax-false)
		)
	)	  
	(if  accol (vlax-release-object accol))
	(if  acapp (vlax-release-object acapp))
	(princ)
)
0 Likes
Message 13 of 14

C.Utzinger
Collaborator
Collaborator
Thank you... I will try tomorrow
0 Likes
Message 14 of 14

C.Utzinger
Collaborator
Collaborator

Just what I was looking for 🙂

 

 

Thank you very much. 

 

 

Kindregards