Author Topic: Group "tblsearch"  (Read 4220 times)

0 Members and 1 Guest are viewing this topic.

Coder

  • Swamp Rat
  • Posts: 827
Group "tblsearch"
« on: June 24, 2011, 01:16:36 PM »
Hello .  :-)

I could not find the tblsearch which is belong to group entities , things like for layer e.g (tblsearch "LAYER" "MYLAYER") .

Many thanks.

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: Group "tblsearch"
« Reply #1 on: June 24, 2011, 01:22:23 PM »
Groups are stored in the ACAD_GROUP Dictionary within the Named Object Dictionary, and may be accessed using the following:

Code: [Select]
(dictsearch (namedobjdict) "ACAD_GROUP")
Or, through Visual LISP using the Groups property of the Document object:

Code: [Select]
(vla-get-Groups <Document Object>)

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: Group "tblsearch"
« Reply #2 on: June 24, 2011, 01:35:10 PM »
Some related functions I quickly put together just now:

Code: [Select]
(defun _getgroup ( group / dic )
  (if (setq dic (dictsearch (namedobjdict) "ACAD_GROUP"))
    (dictsearch (cdr (assoc -1 dic)) group)
  )
)

Code: [Select]
(_getgroup "MyGroup")
Code: [Select]
(defun _getallgroups ( / dic item lst )
  (if (setq dic (reverse (dictsearch (namedobjdict) "ACAD_GROUP")))
    (while (setq item (assoc 3 dic))
      (setq lst (cons (cons (cdr item) (cdr (assoc 350 dic))) lst)
            dic (cdr (member item dic))
      )
    )
  )
  lst
)

Code: [Select]
(_getallgroups)
Code: [Select]
(defun _getgroupdata ( / dic item lst )
  (if (setq dic (dictsearch (namedobjdict) "ACAD_GROUP"))
    (while (setq item (dictnext (cdr (assoc -1 dic)) (null item)))
      (setq lst (cons item lst))
    )
  )
  (reverse lst)
)

Code: [Select]
(_getgroupdata)
Code: [Select]
(defun _getgroupentities ( group / dic ent lst )
  (if
    (and
      (setq dic (dictsearch (namedobjdict) "ACAD_GROUP"))
      (setq dic (dictsearch (cdr (assoc -1 dic)) group))
    )
    (while (setq ent (assoc 340 dic))
      (setq lst (cons (cdr ent) lst)
            dic (cdr  (member ent dic))
      )
    )
  )
  lst
)

Code: [Select]
(_getgroupentities "MyGroup")
Or in VL:

Code: [Select]
(defun _getallgroups ( doc / lst )
  (vlax-for grp (vla-get-groups doc)
    (setq lst (cons (cons (vla-get-name grp) grp) lst))
  )
  (reverse lst)
)

Code: [Select]
(_getallgroups (vla-get-activedocument (vlax-get-acad-object)))
Code: [Select]
(defun _getgroupobjects ( doc group / grp lst )
  (if
    (not
      (vl-catch-all-error-p
        (setq grp
          (vl-catch-all-apply 'vla-item (list (vla-get-groups doc) group))
        )
      )
    )
    (vlax-for obj grp (setq lst (cons obj lst)))
  )
  lst
)

Code: [Select]
(_getgroupobjects (vla-get-activedocument (vlax-get-acad-object)) "MyGroup")
« Last Edit: June 24, 2011, 01:46:05 PM by Lee Mac »

Jeff H

  • Needs a day job
  • Posts: 6151
Re: Group "tblsearch"
« Reply #3 on: June 24, 2011, 01:53:34 PM »
Sorry for Hijacking the thread

So looking at this real quick it looks like posted earlier for groups
Code: [Select]
(dictsearch (namedobjdict) "ACAD_GROUP")
So Layouts?
Code: [Select]
(dictsearch (namedobjdict) "ACAD_LAYOUT")
So Plot Settings?
Code: [Select]
(dictsearch (namedobjdict) "ACAD_PLOTSETTINGS")

for tblsearch

9 Symbol Tables
BlockTable
DimStyleTable
LayerTable
LinetypeTable
RegAppTable
TextStyleTable
UcsTable
ViewTable
ViewportTable

(tblsearch "style" "standard") = Text Style Table?
I have seen "layer" & "LAYER" so I guess it is not case sensitive.

Is there a list of the strings to use for each Symbol Table when using tblsearch?


Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: Group "tblsearch"
« Reply #4 on: June 24, 2011, 01:57:33 PM »
Is there a list of the strings to use for each Symbol Table when using tblsearch?

Look at the VLIDE Help Documentation for the tblnext function, it should have a list of valid table names there.

As for the Dictionaries, you can get an overview the contents of the Named Object Dictionary by a quick call to:

Code: [Select]
(entget (namedobjdict))
A list of Dictionaries contained therein could be obtained perhaps through:

Code: [Select]
(mapcar 'cdr (vl-remove-if-not '(lambda ( x ) (= 3 (car x))) (entget (namedobjdict))))
Or, in Vanilla, maybe:

Code: [Select]
(
  (lambda ( dic / item lst )
    (while (setq item (assoc 3 dic))
      (setq lst (cons (cdr item) lst)
            dic (cdr  (member item dic))
      )
    )
    (reverse lst)
  )
  (entget (namedobjdict))
)
« Last Edit: June 24, 2011, 02:01:55 PM by Lee Mac »

Jeff H

  • Needs a day job
  • Posts: 6151
Re: Group "tblsearch"
« Reply #5 on: June 24, 2011, 05:45:00 PM »
Thanks Lee,

Quote
A string that identifies a symbol table. Valid table-name values are "LAYER", "LTYPE", "VIEW", "STYLE", "BLOCK", "UCS", "APPID", "DIMSTYLE", and "VPORT". The argument is not case sensitive.

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: Group "tblsearch"
« Reply #6 on: June 24, 2011, 05:47:21 PM »
You got it  :wink: