Jump to content

FInd a tablestyle by name and assign to a variable


Recommended Posts

Posted

Starting with this code that I found from Tharwat

 

(defun c:foo ()
 (setq StyleName "MyTableStyle") ; Prompt user for table style name
 (setq dic (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_TABLESTYLE"))))  ; Get the TableStyle dictionary
  (if (dictsearch dic StyleName)  ; Search for the specified Table Style in the dictionary
    (prompt "\nTable Style exists.")  ; If found, display this message
    (prompt "\nTable Style does not exist.")  ; If not found, display this message
  )
  (princ)
)

 

How can I assign all the tables that meet that criteria to a selection set?
I was hoping it would be as easy as

 

(setq ss (ssget "_x" '((0 . "ACAD_TABLE") (302."MyTableStyle"))) )

 

but that does not work.

I do not know how to incorporate extended entity data

 

I would like to replace this 

 

(prompt "\nTable Style exists.")  ; If found, display this message
(prompt "\nTable Style does not exist.")  ; If not found, display this message

 

with if found make a selection set else exit.

 

 

How can I also find tables located inside of blocks and make part of the selection set?
(which I would also like to incorporate but only secondary)

QSelect does not find tables within blocks either..
 

 

 

Posted

I am not sure that you can get a table using a style name with ssget, but you can get all tables and look inside at the table name. two ways dxf or VL. Then make a new selection set or list of entities.

 

(setq sty (cdr (assoc 3 (entget (cdr (assoc 342 (entget (ssname ss X ))))))))

(setq obj (vlax-ename->vla-object (ssname ss x)))
(setq sty (vlax-get obj 'StyleName))

 

Inside blocks much harder need to use entnext and find the table inside the block, will leave that to some one else.

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