Login

View Full Version : Help with a Saved View routine, how to handle TileMode



stephen.coff
2007-04-20, 04:55 AM
Guys,
I have made a very simple routine that saves the current view to a number supplied by the user between 1 - 5. I further created lisp routines, 5 of them. I for each possible view saved so i can save them as icons in a toolbar so I just press the number icon I want to recall that saved view. I have tried it and it actually works ok except one thing. If you save a view in one tilemode and then move to another and save a view. It becomes a problem when you try to recall the views, it won't flick between the tilemodes
I wanted to be able to save what tilemode the drawing was in with the saved view. I was thinking that I could save the tilemode view with a variable ?. I just don't know how to do it, I tried multiple things though not successful. Maybe their is a very easy way and open to any suggestions.


This routine was to save the Views


(defun c:VS (/ VAL)
(setvar "cmdecho" 0)
(setq VAL (getint "Number to Save View: 1-5"))
(if (= (command "_view" "s" VAL) nil) (alert "View Saved"))
(setvar "cmdecho" 1)
(princ)
)This routine was one of 5 to restore the individual view


(defun c:V1 ()
(setvar "cmdecho" 0)
(command "_view" "r" "1")
(setvar "cmdecho" 1)
(princ)
)Any suggestions guys ?

Stephen

[ Moderator Action = ON ] What are [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code) [ Moderator Action = OFF ]

kennet.sjoberg
2007-04-20, 09:43 AM
(70 . 1) = paper space view

: ) Happy Computing !

kennet

stephen.coff
2007-04-22, 10:58 PM
Soryy Kennet,
I am not that good with the Lisp. I don't quite understand your responce or how I should use the information you have given me, could you please explain a little further.

Stephen

kennet.sjoberg
2007-04-23, 07:57 AM
Soryy Kennet,
I am not that good with the Lisp. I don't quite understand your responce or how I should use the information you have given me, could you please explain a little further.

Stephen
The views that you save, is saved in the "VIEW" symbol table as dxf code
you can retrieve that information using tblobjname, tblnext or tblsearch.
This time we know that we are looking for a view named "1" so we use tblsearch.
(tblsearch "VIEW" "1" ) that results in nil if the view is not saved, or in a list of dxf code if it exist
((0 . "VIEW") (2 . "1") (70 . 1) (40 . 1368.1) (10 641.426 595.276) (41 . 2279.54) (11 0.0 0..............
the code 70 indicate model or paperspace, so we use (cdr (assoc 70 (tblsearch "VIEW" "1" )) )
or with a variable name instead of "1" (cdr (assoc 70 (tblsearch "VIEW" ViewName_in ) )) to find out ms or ps.

You can only deal with model or paper space views ( no views in current viewport in paperspace, they are model )

Here is a simple SaveView function


(defun SV ( ViewName_in / )
(if (= (getvar "TILEMODE" ) 0 ) (command "_pspace" ) ( ) )
(command "_view" "s" ViewName_in )
(princ)
)

usage Command: (SV "MyViewName" )

and a simple RestoreView function


(defun RV ( ViewName_in / ViewDxf )
(if (setq ViewDxf (tblsearch "VIEW" ViewName_in ))
(progn
(if (= (cdr (assoc 70 ViewDxf )) 0 ) (setvar "TILEMODE" 1 ) (setvar "TILEMODE" 0 ) )
(if (= (getvar "TILEMODE" ) 0 ) (command "_pspace" ) ( ) )
(command "_view" "r" ViewName_in )
)
(princ " ViewName not found " )
)
(princ)
)

usage Command: (RV "MyViewName" )

: ) Happy Computing !

kennet

stephen.coff
2007-04-23, 10:54 PM
Kennet,
That is great. Not just that you have fixed my lisp rather explained it so i can understand better, I really appreiate your effort.

Stephen

kennet.sjoberg
2007-04-24, 07:54 AM
Kennet,
That is great. Not just that you have fixed my lisp rather explained it so i can understand better, I really appreiate your effort.

Stephen

I'm just glad to help.

: ) Happy Computing !

kennet