Author Topic: multiple layuot tabs - 1 instance of title block inserted on some layouts  (Read 3303 times)

0 Members and 1 Guest are viewing this topic.

adalea03

  • Guest
Can I map an instance of a block to the layout it resides on?
If so, point me in the right direction, please.
What little I have so far is listed below.

Code: [Select]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; conditions: * multiple layuot tabs                                                 
;;;             * (1) instance of title block inserted on some but not all layuot tabs 
;;; goal : associate each title block (entity or object) with its respective layout     
;;;        so the end user can select the target title block by its associated         
;;;        layout name from a dialog list_box ragardless of the 'current' layuot status
;;; assumed info requirements:                                                         
;;;        * list of layouts and/or layout blocks                                       
;;;        * list of entity names or object IDs of each instance of title block         
;;;        * etc. , etc. , ...                                                         
;;; problem : how to develop and report the assoiations so correct selection           
;;;           can be made by the end user                                               
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun map-titleblocks-2-layouts (/ current-doc current-layout layout-list ps-layouts)
  (setq current-doc (vla-get-activedocument (vlax-get-acad-object)))
  (setq current-layout (vlax-get-property current-doc 'ActiveLayout))
  (setq layout-list nil)
  (vlax-for xi (vla-get-layouts current-doc)
    (setq layout-list (cons (list
                              (vlax-get-property xi 'TabOrder)
                              (vlax-get-property xi 'Name)
                              (vlax-get-property xi 'Block)) layout-list)))
  (setq ps-layouts nil)
  (foreach xi (cdr (vl-sort (mapcar 'car layout-list) '<))
    (foreach ix layout-list
      (if (= xi (car ix))
        (setq ps-layouts (append ps-layouts (list ix))) nil)))
;;;   I'm stuck
  )

Thank you,
Tony



Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Have you played with dictionaries or Xrecords ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Just to expand the idea.

Each insert has a unique immutable handle.
You may be able to add a dictionary to each layout referencing the handle < or Name > of it's designated block instance. [ depending on the setup, this may be able to be automated ]

The layouts could then be iterated, extracting the referenced handle < or Name > which could then be programmatically selected.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

FengK

  • Guest
maybe i didn't understanding the question. is there only one title block in each layout? if so, (ssget "X" (list (cons 0 "INSERT") (cons 2 blkName) (cons 410 layoutName)) should select that block, right?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Kelie, I wasn't too sure either ...

could even select if the blocks were different but similarly named.

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

adalea03

  • Guest
While not 'fluent' in X-records I have had success using that tecnique.

I will try
"...(ssget "X" (list (cons 0 "INSERT") (cons 2 blkName) (cons 410 layoutName)) ..."
first.

Thank you, Kerry, Kelly.
Tony

adalea03

  • Guest
Oh, by the way Kelie, it was
one instance of the title block on some but not all layouts.
Tony

adalea03

  • Guest
The solution was much simpler than I had expected.

Code: [Select]
 
  (setq my-tblks (ss2lst (ssget "X" (list (cons 0 "INSERT") (cons 2 "A-1117PP-3")))))
  (setq my-tblk-lst
    (mapcar '(lambda (x) (list (cdr (assoc 410 (entget x))) x)) my-tblks))

Thank you for all for your suggestions.
Tony

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
I thought that may have been what you wanted.

My answer was aimed at the original question ; ie
Quote
.. map an instance of a block to the layout it resides on?
which in itself is also an interesting idea if the block names were unique.

.. good to see your problem resolved.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.