Reset Table cell border lineweights

Reset Table cell border lineweights

m_beach89
Participant Participant
462 Views
4 Replies
Message 1 of 5

Reset Table cell border lineweights

m_beach89
Participant
Participant

I have been looking all over for a .lsp or some code I can tweak to make work for me to no avail.  I found this from another forum, but it is for changing the text style of each cell:

(defun c:Test ( / sty tbl obj row col r c)
 ;;	Tharwat - Date:  11.Jul.2017	;;

 (setq sty "Standard") ;; Change the Text Style to suit your desired one.
 (if (and (or (tblsearch "STYLE" sty)
            (alert (strcat "Text style <" sty "> is not found in drawing <!>"))
            )
        (princ "\nPick on Table :")
        (setq tbl (ssget "_+.:S:E:L" '((0 . "ACAD_TABLE"))))
        (setq obj (vlax-ename->vla-object (ssname tbl 0))
              row (vla-get-rows obj)
              col (vla-get-columns obj)
              r 0 c 0
              )
        )
   (repeat row
     (repeat col
       (vla-setcelltextstyle obj r c sty) (setq c (1+ c))
       )
     (setq r (1+ r) c 0)
     )
   )
 (princ)
 ) (vl-load-com)

 I would like to tweak this to simply set all cell grid lineweights of the table to a specified variable (in my case ByBlock).  I already tweaked it to this, but it doesn't work and I don't know what else to do:

(defun c:Test ( / lwt tbl obj row col r c)

 (setq lwt ByBlock) ;; Change the table cell lineweight to suit your desired one.
        (princ "\nPick on Table :")
        (setq tbl (ssget "_+.:S:E:L" '((0 . "ACAD_TABLE"))))
        (setq obj (vlax-ename->vla-object (ssname tbl 0))
              row (vla-get-rows obj)
              col (vla-get-columns obj)
              r 0 c 0
              )
        )
   (repeat row
     (repeat col
       (vla-setcellgridlineweight obj r c lwt) (setq c (1+ c))
       )
     (setq r (1+ r) c 0)
     )
   )
 (princ)
 )

Here are a couple screenshots of what I need to do, change all lineweights to be the same, while keeping all other formatting the same, especially removed (invisible) borders:

mbeachRCJ54_0-1709226661867.png

Please help, even if simply pointing to another forum post that can help would be appreciated.

0 Likes
Accepted solutions (2)
463 Views
4 Replies
Replies (4)
Message 2 of 5

ВeekeeCZ
Consultant
Consultant
Accepted solution

Possibly like this

 

(defun c:Test ( / lwt tbl obj row col r c)
  
  (setq lwt acLnWtByBlock) ;; Change the table cell lineweight to suit your desired one.
  ;; https://help.autodesk.com/view/ACD/2024/ENU/?guid=GUID-84954C42-12E8-4729-8276-2B3B77AB24B2
  
  (princ "\nPick on Table :")
  (setq tbl (ssget "_+.:S:E:L" '((0 . "ACAD_TABLE"))))
  (setq obj (vlax-ename->vla-object (ssname tbl 0))
	row (vla-get-rows obj)
	col (vla-get-columns obj)
	r 0 c 0
	)
  
  (repeat row
    (repeat col
      (foreach mask (list acBottomMask acLeftMask acRightMask acTopMask)
	(vla-setcellgridlineweight obj r c mask lwt))
      (setq c (1+ c)))
    (setq r (1+ r) c 0))
  (princ)
  )

 

0 Likes
Message 3 of 5

m_beach89
Participant
Participant

OMG thank you so much!!!  Works perfectly.

 

Just out of curiosity, how hard would it be to make it so I can select multiple tables at once?

0 Likes
Message 4 of 5

ВeekeeCZ
Consultant
Consultant
Accepted solution
(defun c:Test ( / lwt tbls i obj row col r c)
  
  (setq lwt acLnWtByBlock) ;; Change the table cell lineweight to suit your desired one.
  ;; https://help.autodesk.com/view/ACD/2024/ENU/?guid=GUID-84954C42-12E8-4729-8276-2B3B77AB24B2
  
  (princ "\nSelect tables,")
  (setq tbls (ssget ":L" '((0 . "ACAD_TABLE"))))
  (repeat (setq i (sslength tbls))
    (setq obj (vlax-ename->vla-object (ssname tbls (setq i (1- i))))
	  row (vla-get-rows obj)
	  col (vla-get-columns obj)
	  r 0 c 0
	  )
    
    (repeat row
      (repeat col
	(foreach mask (list acBottomMask acLeftMask acRightMask acTopMask)
	  (vla-setcellgridlineweight obj r c mask lwt))
	(setq c (1+ c)))
      (setq r (1+ r) c 0)))
    (princ)
    )
Message 5 of 5

m_beach89
Participant
Participant

You are a god.  Thank you so much!

0 Likes