Jump to content

Recommended Posts

Posted (edited)

After this discussion it was determined that a table style cannot be replaced in a simple step like you with blocks.

 

Replace Table Style

 

I was attempting to write a routine to rename three table styles so that I can bring in "new and improved" versions of those tables from a template.

Given Tablestyles: Style1, Style2 & Style3

I'd like to rename to OLD1, OLD2 & OLD3 respectively...

 

I do not know what I'm doing. This does not work at all.

 

(defun C:RTS2 (/ oldname newname tbllist);;;
  (setq oldname "STYLE1" 
        newname "OLD1")
  (setq tbllist (tblstyle))
  (if (member oldname tbllist)
      (progn
        (command "tablestyle" oldname "rename" newname)
        (princ (strcat "Table style " oldname " renamed to " newname))
      )
    (princ (strcat "Table style " oldname " not found"))
  )
  (princ)
)

 

I found some code by Lee for deleting a Tablestyle but way over my head to modify to suit..

 

(defun c:deltab ( / dic sty )
;;;Lee Mac
   (if (setq dic (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_TABLESTYLE"))))
       (progn
           (while
               (not
                   (or (= "" (setq sty (getstring t "\nSpecify Table Style to Delete: ")))
                       (dictsearch dic sty)
                   )
               )
               (princ "\nTable Style not found.")
           )
           (if (/= "" sty) (dictremove dic sty))
       )
       (princ "\nTable Styles not present in this version.")
   )
   (princ)
)

 

Lee says this is dangerous but may have some value for my use

 

(defun c:deltab ( / dic )
   (if (setq dic (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_TABLESTYLE"))))
       (foreach sty '("Style1" "Style2" "Style3")
           (dictremove dic sty) ;;I'm not wanting to delete them but rename them...
       )
       (princ "\nTable Styles not present in this version.")
   )
   (princ)
)

 

 

 

Edited by ILoveMadoka
Posted

Ok.. So I'm stupid...

 

(command "_.rename" "T" "style1" "old1")

 

I'd still like to see what a lisp routine using a different function would look like..

 

 

Posted
6 hours ago, ILoveMadoka said:

Ok.. So I'm stupid...

 

(command "_.rename" "T" "style1" "old1")

 

I'd still like to see what a lisp routine using a different function would look like..

 

 

(defun _rnt (old new / dic)
  ;; RJP » 2023-02-08
  (and (setq dic (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_TABLESTYLE"))))
       (setq dic (dictsearch dic old))
       (vl-catch-all-apply 'vla-put-name (list (vlax-ename->vla-object (cdr (assoc -1 dic))) new))
  )
)
;; usage
(_rnt "Standard" "Testing123")

 

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