TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: lovecraft on October 17, 2008, 10:13:50 AM

Title: choose display window
Post by: lovecraft on October 17, 2008, 10:13:50 AM
Good evening,

often working on two screens and often more drawings open in the same session autocad, I wish I could when viewing drawings select designs that I want to put in a mosaic vertical or horizontal.

I know the fensyst, but using this command if I have 6 files open and I chose vertical mosaic, I put the 6 files alongside each other. what I was able to choose only 2 files for example.

Thank you to guide me in this task.

@ more

LB

ps: sorry for my English
I'm french
Title: Re: choose display window
Post by: T.Willey on October 17, 2008, 11:26:04 AM
I have something that is old.  Let me see if I can redo it so it's better coded.

Welcome to theSwamp, and no problem with the language.  You're english is better than my french.   :-)
Title: Re: choose display window
Post by: CAB on October 17, 2008, 06:21:35 PM
Welcome to TheSwamp LB
Title: Re: choose display window
Post by: T.Willey on October 20, 2008, 11:57:09 AM
This should do what you want.  The dcl file is attached, so just place it in the search path.

Code: [Select]
(defun c:TileSelect (/ AcObj ActDoc DocCol DocList DiaRtn RtnLen HorOpt tempDoc cDocSel oWinStList)
    ; Tile selected drawings.
   
    (setq AcObj (vlax-get-Acad-Object))
    (setq ActDoc (vla-get-ActiveDocument AcObj))
    (setq DocCol (vla-get-Documents AcObj))
    (vlax-for i DocCol
        (setq DocList (cons (cons (vla-get-Name i) i) DocList))
        (setq oWinStList (cons (cons (vla-get-WindowState i) i) oWinStList))
        (while (not (equal (vlax-get i 'WindowState) 2))
            (vlax-put i 'WindowState 2)
        )
    )
    (setq DocList (vl-sort DocList '(lambda (a b) (< (car a) (car b)))))
    (if
        (and
            (> (length DocList) 1)
            (setq DiaRtn (MultiSelect (mapcar 'car DocList) "Check to tile horizontal." T))
            (if (equal (type (car DiaRtn)) 'INT)
                (> (setq RtnLen (length DiaRtn)) 1)
                (progn
                    (setq HorOpt T)
                    (setq DiaRtn (cdr DiaRtn))
                    (> (setq RtnLen (length DiaRtn)) 1)
                )
            )
        )
        (progn
            (setq HorOpt
                (if HorOpt
                    "_Horizontal"
                    "_Vertical"
                )
            )
            (foreach i DiaRtn
                (setq tempDoc (cdr (nth i DocList)))
                (if (equal tempDoc ActDoc)
                    (setq cDocSel T)
                )
                (vlax-put tempDoc 'WindowState 1)
            )
            (vlax-put ActDoc 'WindowState 1)
            (if (not cDocSel)
                (vlax-put ActDoc 'WindowState 2)
            )
            (vla-Activate ActDoc)
            (command "_.syswindows" HorOpt)
        )
        (foreach i oWinStList
            (while (not (equal (vla-get-WindowState (cdr i)) (car i)))
                (vla-put-WindowState (cdr i) (car i))
            )
        )
    )
    (princ)
)
Title: Re: choose display window
Post by: gile on October 20, 2008, 01:08:56 PM
Hi Tim,

MultiSelect sub routine is missing.

I found it here (http://www.theswamp.org/index.php?topic=25353.msg305492#msg305492).
Title: Re: choose display window
Post by: T.Willey on October 20, 2008, 01:12:46 PM
Hi Tim,

MultiSelect sub routine is missing.

I found it here (http://www.theswamp.org/index.php?topic=25353.msg305492#msg305492).
Thanks gile.  Here it is so people don't have to go looking for it ( it is the same still ).

Code: [Select]
(defun MultiSelect (Listof Message Toggle / DiaLoad tmpStr tmpTog tmpList)

(setq DiaLoad (load_dialog "MyDialogs.dcl"))
(if (new_dialog "MultiSelect" DiaLOad)
(progn
(start_list "listbox" 3)
(mapcar 'add_list Listof)
(end_list)
(if Message
(set_tile "text1" Message)
)
(if (not Toggle)
(mode_tile "toggle1" 1)
)
(mode_tile "listbox" 2)
(action_tile "accept"
"(progn
(setq tmpStr (get_tile \"listbox\"))
(if Toggle
(setq tmpTog (get_tile \"toggle1\"))
)
(done_dialog 1)
)"
)
(action_tile "cancel" "(done_dialog 0)")
(if (= (start_dialog) 1)
(progn
(if tmpStr
(setq tmpList (read (strcat "(" tmpStr ")")))
)
(if (= tmpTog "1")
(cons T tmpList)
tmpList
)
)
)
)
)
)
Title: Re: choose display window
Post by: lovecraft on October 20, 2008, 03:50:05 PM
Thank you very much Tim and Gile
that's exactly what I wanted
It is still too difficult for me to make this code

@+

LB


Title: Re: choose display window
Post by: Bob Wahr on October 20, 2008, 04:59:11 PM
Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn
Title: Re: choose display window
Post by: T.Willey on October 20, 2008, 04:59:58 PM
You're welcome LB.