Jump to content

lisp to unlock table cells (the whole table at once)


Recommended Posts

Posted

Greetings everyone ..

i have a tables inserted to autocad from excel and these tables are locked for editing ... is there a method to unlock these tables and remove their data links using lisp routine ?

 

 

thanks for reading

best regards..

Posted (edited)

I have found a few lisps on the net (because I rarely use tables my self) and combined them but its slow ...

 

 

 
; [url]http://adndevblog.typepad.com/autocad/2012/04/autolisp-example-create-a-table-using-activex.html[/url]
; By Wayne Brill
(defun c:addMyTable ( / ActiveDocument mSpace pt 
             myTable nRows nCols row cell ) 
 (vl-load-com) 
 (setq ActiveDocument (vla-get-activedocument 
            (vlax-get-acad-object))) 
 (setq mSpace(vla-get-modelspace ActiveDocument)) 
 (setq pt (vlax-make-safearray vlax-vbDouble 
                                  '(0 . 2))) 
 ;insertion point for the table 
 (vlax-safearray-fill pt '(2.0 2.0 0.0)) 
 (setq myTable 
    (vla-addtable mSpace pt 5 5 10 30)) 
 (vla-setcelltextheight myTable 0 0 5) 
 (vla-settext myTable 0 0 "myTable") 
 
 ;rows and columns zero based 
 (setq nRows(- (vla-get-rows myTable) 1)) 
 (setq nCols(- (vla-get-columns myTable) 1)) 
 
 ; rows and columns after row 0, column 0 
 (setq row 1) 
 (setQ cell 0) 
 
 ; loop through cells 
 (while (<= row nRows) 
   (while (<= cell nCols) 
  (vla-setCelltextHeight myTable row cell 5.0) 
       (vla-settext myTable row cell "test") 
       ; make cell alignment middle center 
       (vla-setCellAlignment myTable row cell 5)      
  (setq cell (1+ cell)) 
  );while 
 (setq row (1+ row)) 
 (setq cell 0)  
);while 
(princ) 
);defun

; [url]https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/unlocking-a-cell-in-a-table-via-lisp/td-p/3600226[/url]
; by Tharwat :
; (setq s (car (entsel "\n Select table :")))
; (vla-setcellstate (vlax-ename->vla-object s) <Number_of_Row> <Number_of_Cell> 0)


; above code is for credits only , code below is the actual function
; combined by me me me :-)
(defun Unlock_Table_Cells ( / myTable nRows nCols row cell)
 (if (setq myTable (car (entsel "\n Select table :")))
   (progn
     (setq myTable (vlax-ename->vla-object myTable))
     (setq nRows (- (vla-get-rows myTable) 1))
     (setq nCols (- (vla-get-columns myTable) 1))
     (setq row 1) 
     (setq cell 0)
     (princ (strcat "\n\nNumers : " (itoa nRows) " rows , " (itoa nCols) " columns\nPress any key to continue"))
     (grread)
     ; thank you Grrr/Lee/Tharwat
     ; [url]http://www.cadtutor.net/forum/showthread.php?101239-lisp-to-unlock-table-cells-(the-whole-table-at-once[/url])
     (vla-put-RegenerateTableSuppressed myTable :vlax-true)
     (while (<= row nRows)
(while (<= cell nCols)
  (vla-setcellstate  myTable row Cell 0)
  (setq cell (1+ cell))
  (princ (strcat "\nRow : " (itoa row) " , cell " (itoa cell)))
);while
(setq row (1+ row))
(setq cell 0)
     )
     
     (vla-put-RegenerateTableSuppressed myTable :vlax-false)
   )
 )
 (princ)
)


so say thank you Wayne Brill , say thank you Tharwat and say thank me:D

 

p.s. or just explode it :ouch:

p.p.s. for the datalink maybe this link may-B of interest : http://www.cadtutor.net/forum/showthread.php?48655-How-to-completely-delete-a-table-data-link

 

 

 

:beer:

 

gr. Rlx

Edited by rlx
Posted
I have found a few lisps on the net (because I rarely use tables my self) and combined them but its slow ...

 

Rlx you have to wrap it like this:

(vla-put-RegenerateTableSuppressed ACADTableObj :vlax-true)
; < Manipulate the table here >
(vla-put-RegenerateTableSuppressed ACADTableObj :vlax-false)

Posted (edited)
Rlx you have to wrap it like this:

(vla

 

 

 

 

Makes sense Grrr , don't (didn't) know any of these commands but they are self explanatory.

I have updated code above.

 

:beer:

 

 

gr.Rlx

Edited by rlx
Posted
Makes sense Grrr , don't (didn't) know any of these commands but they are self explanatory.

 

 

:beer:

 

 

gr.Rlx

 

No problem, I didn't knew about this either so I had to wait 5 minutes to generate a sorted room table for 90 different rooms, until one day I learned about this on the forums from Lee or Tharwat (don't really remember who was), and now its immediately created or manipulated. So shout outs to them!

 

:beer:

Posted

thank you all ... your contributions are greatly appreciated ... thanks again :)

Posted
Rlx you have to wrap it like this:

(vla-put-RegenerateTableSuppressed ACADTableObj :vlax-true)
; < Manipulate the table here >
(vla-put-RegenerateTableSuppressed ACADTableObj :vlax-false)

 

this is The Missing Piece Puzzle that solved a lot of table processing functions that i made before ... thanks ,Grrr

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