Author Topic: Finding list of tabs ...  (Read 5464 times)

0 Members and 1 Guest are viewing this topic.

Hangman

  • Swamp Rat
  • Posts: 566
Re: Finding list of tabs ...
« Reply #15 on: January 09, 2007, 04:08:52 PM »
Quote
If you have a specific layout you want it to always go to, then I think you can make a button to do that ...
I would think you would want a new button, and not a reactor (just a thought I wanted to put out there =D).

Actually Tim, I want it to work with the following code.
Code: [Select]
  (setq space (getvar "tilemode"))
;
  (if (= space 1);;; Model space
    (progn
      (command ".zoom" "E")
      (command ".-layer" "thaw" "0" "on" "0" "set" "0" "")
      (command "tilemode" 0)
      (if (/= (getvar "cvport") 1)
        (command ".pspace"))
*** Enter Code to make it go to required tab ***
      (setvar "ltscale" (/ dims 2))
      (command ".zoom" "E")
    )
  )
  (if (= space 0); Paper space
    (progn
      (if (/= (getvar "cvport") 1)
    (command ".pspace"))
*** Enter Code to make it go to required tab ***
      (command ".-layer" "thaw" "0" "on" "0" "set" "0" "")
      (setvar "ltscale" (/ dims 2))
      (command ".zoom" "E")
    )
  )

Usually the required tab is the first tab in any given set of tabs on a drawing.  Sometimes though, that required tab would be second or third.
As I posted initially, the tab would be one of a series of possible names;  S-1, S-11, S1.1, S1.1A, SF101, etc.

My initial thought is to create a conditional,
Code: [Select]
  (setq tab-1 (car (layoutlist)))
  (progn
    (cond ( (= tab-1 "S-1")
               (setvar "ctab" tab-1))
             ( (= tab-1 "S-11")
               (setvar "ctab" tab-1))
             ( (= tab-1 "S1.1")
               (setvar "ctab" tab-1))
  ... etc, etc.

I'm not quite understanding this though,
Code: [Select]
...
(foreach tab (layoutlist)
    (if (not (member tab (list "Model" ctab)))
        (progn
 ...

I should say I don't understand how layoutlist is working here.  From the examples CAB posted above, I'm not following them very well.
And I realize my code for breaking the layoutlist down would be very tedious.  Do you have another way for getting the list broken down to the individual tabs names from within the list ??

*** Edited ***

Quote
Is the preferred tab always the first one after the Model Space Tab?

CAB - 9 times out of 10, Yes.
Quote
Does the preferred tab always have the same name or is the name unique in some way?

It has a unique name as mentioned above (at least I think it's unique).  :-D
« Last Edit: January 09, 2007, 04:14:21 PM by Hangman »
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Finding list of tabs ...
« Reply #16 on: January 09, 2007, 04:45:55 PM »
You could try this:
Code: [Select]
(defun c:test()
   (setq tabs (GetLayouts))
    (cond
      ((setq tab-1 (member "S-1" tabs)))
      ((setq tab-1 (member "S-11" tabs)))
      ((setq tab-1 (member "S1.1" tabs)))
      ((setq tab-1 tabs))
    )
    (setvar "ctab" (car tab-1))
 )


Code: [Select]
;;  Returns the layouts in "Tab Order"
(defun GetLayouts(/ tab-list)
  ;; get tab names, sort in tab order & remove model & flagged tab names
  (vlax-map-collection
    (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object)))
    '(lambda (x) (setq tab-list (cons x tab-list))))
  ;;  sort in tab order just in case it is needed
  (setq tab-list (vl-sort tab-list '(lambda (x y)
                            (< (vla-get-taborder x) (vla-get-taborder y)))))
  ;;  make list of names into strings  remove Model space
  (vl-remove "Model" (mapcar '(lambda (x)(vla-get-name x))tab-list))
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Hangman

  • Swamp Rat
  • Posts: 566
Re: Finding list of tabs ...
« Reply #17 on: January 09, 2007, 05:32:04 PM »
Damn CAB, that is slick !!!  Thanks.

I am curious, I don't understand lambda yet, but I'm thinking it would not cause the list to repeat itself would it ??
This is what I get when typing it in at the command prompt:
Quote
Command: (vlax-map-collection
(_>     (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object)))
(_> '(lambda (x) (setq tab-list (cons x tab-list))))
Quote
#<VLA-OBJECT IAcadLayouts 0c289564>

Command: (setq tab-list (vl-sort tab-list '(lambda (x y)
(('(_>                             (< (vla-get-taborder x) (vla-get-taborder y)))))
Quote
(#<VLA-OBJECT IAcadLayout 0c2a62a4> #<VLA-OBJECT IAcadLayout 0c2a62a4>
#<VLA-OBJECT IAcadLayout 0c2a7c94> #<VLA-OBJECT IAcadLayout 0c2a7c94>
#<VLA-OBJECT IAcadLayout 11085894> #<VLA-OBJECT IAcadLayout 11081574>
#<VLA-OBJECT IAcadLayout 11081524> #<VLA-OBJECT IAcadLayout 110858e4>)

Command: (vl-remove "Model" (mapcar '(lambda (x)(vla-get-name x))tab-list))
Quote
("S1.1A" "S1.1A" "S1.1B" "Add-1 (1)" "Add-1 (2)" "Add-1 (3)")


So I went back and retyped it to the command line without the 'vl-remove' statement,
Quote
Command: (mapcar '(lambda (x)(vla-get-name x))tab-list)
Quote
("Model" "Model" "S1.1A" "S1.1A" "S1.1B" "Add-1 (1)" "Add-1 (2)" "Add-1 (3)")


Notice the repeat of "Model" and "S1.1A".  Anyone know the reasoning behind this phenomenon ??
« Last Edit: January 09, 2007, 05:55:18 PM by Hangman »
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Finding list of tabs ...
« Reply #18 on: January 09, 2007, 06:42:25 PM »
Maybe 'tab-list' was set to something before you ran the routine, since you should be getting more than what is onet he drawing.  I only get three tabs, and all I have is three in the current drawing.  Try this then
Code: [Select]
(progn
 (setq tab-list nil)
 (setq tab-name-list nil)
 (vlax-map-collection
  (vla-get-Layouts (vla-get-ActiveDocument (vlax-get-Acad-Object)))
  '(lambda (x) (setq tab-list (cons x tab-list)))
 )
 (setq tab-list (vl-sort tab-list '(lambda (a b) (< (vla-get-TabOrder a) (vla-get-TabOrder b)))))
 (setq tab-name-list (vl-remove-if '(lambda (x) (= x "Model")) (mapcar 'vla-get-Name tab-list)))
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Finding list of tabs ...
« Reply #19 on: January 09, 2007, 06:56:36 PM »
Maybe 'tab-list' was set to something before you ran the routine, since you should be getting more than what is onet he drawing.  ....  Try this then
Code: [Select]
(progn
 (setq tab-list nil)
 (setq tab-name-list nil)
;;.............
 

That is probably something that code testers should burn into their brain ... make sure your data lists are
uncontaminated.
« Last Edit: January 09, 2007, 06:57:37 PM by Kerry Brown »
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.

Hangman

  • Swamp Rat
  • Posts: 566
Re: Finding list of tabs ...
« Reply #20 on: January 09, 2007, 07:00:54 PM »
Yeah I'm a think'n you're right.
I haven't been able to duplicate my 'double vision' so it must have been a contaminating smudge on my glasses.   :kewl:

Thanks guys.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~