Delete a table style

Delete a table style

Lott99
Enthusiast Enthusiast
1,924 Views
11 Replies
Message 1 of 12

Delete a table style

Lott99
Enthusiast
Enthusiast

I would like to delete a table style with a command

0 Likes
Accepted solutions (1)
1,925 Views
11 Replies
Replies (11)
Message 2 of 12

pbejse
Mentor
Mentor
Accepted solution

Here you go.

DeleteTable.gif

or

(defun _DeleteTAble (TableNme / aDoc dicts)
  (setq aDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
  (setq dicts (vla-get-Dictionaries aDoc))
  (Vlax-for tb (vla-Item dicts "acad_tablestyle")
    (if	(and
	  (eq (Strcase (Vla-get-name tb)) (Strcase TableNme))
	  (vlax-write-enabled-p tb)
	)
      (Vla-delete tb)
    )
  )
  (princ)
)

HTH

 

 

Message 3 of 12

Lott99
Enthusiast
Enthusiast

Thank you! I appreciate your time. Hopefully I can repay the favor some day.

0 Likes
Message 4 of 12

Anonymous
Not applicable
I have a question about the code, particularly because I'm not a coder and don't want to screw it up.... 😛
with the command above, would I insert the table name that I accidently created in the CAPS LOCK highlighted below?

(defun _DeleteTAble (TABLENME / aDoc dicts) <<<<<<<<<(HERE?)
(setq aDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
(setq dicts (vla-get-Dictionaries aDoc))
(Vlax-for tb (vla-Item dicts "acad_tablestyle")
(if (and
(eq (Strcase (Vla-get-name tb)) (Strcase TABLENME)) <<<<<<<<<(HERE?)
(vlax-write-enabled-p tb)
)
(Vla-delete tb)
)
)
(princ)
)

I'm nervous to code anything because I don't want to change something else I don't know how to fix.... 😛

If you could give me the code for this specific table I need to delete, that would be great!!!!!!!

TABLE NAME IS:

please delete

^^^^^^^^^^
actual table name above 😕
0 Likes
Message 5 of 12

Lott99
Enthusiast
Enthusiast

@Anonymous Hello, is your table not purgeable? Or can you use command TABLESTYLE to select and delete the table?

 

If not, then to use the code you need to load the function into CAD and then call it forth and tell it what table to delete. So you actually don't need to change the code at all. Do you need help loading the function into CAD and calling it?

0 Likes
Message 6 of 12

Anonymous
Not applicable

It will bring up the Table Style Box but won't the Delete box is not highlighted. Set Current, New..., Modify.... are but Delete is dark grey and not a clickable option. 

 

0 Likes
Message 7 of 12

Lott99
Enthusiast
Enthusiast

@Anonymous You've made sure its not the current table style and that its not being used in the drawing?

 

 

0 Likes
Message 8 of 12

Anonymous
Not applicable

yes, I accidentally created a new table under the table icon. I am using someone else's AutoCAD and don't want this table as an option when you try to create a new table. 

0 Likes
Message 9 of 12

Lott99
Enthusiast
Enthusiast

@Anonymous 

To use the code, make sure your table you want to delete is not set as the current table.

 

Copy and paste the original code from   into the command line and hit enter.

 

You should see it give feedback in the command line after you hit enter:

_DELETETABLE

 

Then type this in the command line:

(_deletetable "please delete") 

 

Now check to see if your table is gone. If you want to use the code in future sessions, you will have to paste it in or tell CAD to load it in automatically every time you open. If you didn't make sure it wasn't set to the current table style, then your CAD might crash.

0 Likes
Message 10 of 12

Anonymous
Not applicable

oh man.... I'll just ask one of the guys here to see if anyone might know before I accidentally crash anything. 
Thanks a million tho!

0 Likes
Message 11 of 12

Lott99
Enthusiast
Enthusiast

@Anonymous You already told me it wasn't set to the current table style, so whats the issue? Just make sure when you open TABLESTYLE that another table is set to current. Click another table and hit the "Set Current" button. Then run the code as I showed you before. I just ran several tests on my system and I found it crashed when the table you are trying to delete was set to current. 

0 Likes
Message 12 of 12

Sea-Haven
Mentor
Mentor

No code, I agree use -purge.

 

-PURGE
Purge [BAtch all/purge All/Blocks/DEtail view styles/Dimension styles/Groups/LAyers/LineTypes/MAterials/MLine styles/MUltileader styles/Plot styles/Regapps/SEction view styles/SHapes/Table styles/text STyles/Visual styles/Zero-length geometry/Empty text entities/Orphaned data]:T  <-- enter T
Enter name(s) to purge <*>: 
Verify each name to be purged? [Yes/No] <Yes>:
Purge table style "Legend"? [Yes/No/yes to All] <No>:

 

It will not allow you to remove anything if it is being used.

0 Likes