Set/Restore viewport

Next
 From:  Michael T. (MICTU_UTCIM)
2891.1 
Hi all!

Hope I am not asking somethinng that has already been answered (if so, please re-direct me :-) )

Is there a way to set a view and restore it without changing the aspect ratio? In other words, if I want to set up a series of steps for generating an animated GIF. If I remember correctly I was able to do this in Rhino.

I don't know if my terminology is correct, but I want to be able to restore a view withou zooming etc.

Maybe this is more simplistic than I am making it out to be.

Thanks for any advise available.

Michael T.
Michael Tuttle a.k.a. mictu http://www.coroflot.com/fish317537
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Ralf-S
2891.2 In reply to 2891.1 
Hi Michael,

Please have a look: http://kyticka.webzdarma.cz/3d/moi/#CaptureScreenToFile

CaptureScreenToFile – you can use this script to save a screenshot out to an image file by using a shortcut key, without needing to run any other program.

- Ralf
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael T. (MICTU_UTCIM)
2891.3 In reply to 2891.2 
Thanks Ralf,


This is a great help, but I was looking for something that wouls set a view port that I can restore in case I by accident zoom in/out rotate/pan in the view when I did not mean to.

Thanks again.

Michael T.
Michael Tuttle a.k.a. mictu http://www.coroflot.com/fish317537
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Nick (BODINI)
2891.4 In reply to 2891.3 
Maybe this can help. I got this script off the forum here somewhere. Its resets the perspective view to a set angle. You can change the angle in the script. Set it up with a shortcut key.


script: /* 3d preset */ var v = moi.ui.mainWindow.viewpanel.getViewport('3D'); v.leftRightAngle = 45; v.upDownAngle = -45; v.tiltAngle = 0;
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael T. (MICTU_UTCIM)
2891.5 In reply to 2891.4 
Thanks Nick.

Still not quite what I'm looking for.

Thanks,

Michael T.

Michael Tuttle a.k.a. mictu

http://www.coroflot.com/fish317537

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
2891.6 In reply to 2891.1 
Hi Michael T, it sounds like you're looking for something like the "named views" mechanism in Rhino.

MoI does not currently have anything set up for that, but it is on the todo / wishlist to add in the future though.

I can probably cook up some scripts that may help get something similar now though, I'll take a look.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
2891.7 In reply to 2891.1 
Hi Michael T, here are some scripts that may be useful - set these up on some shortcut keys.


Save view:

script: /* Save snapshot of current view into view stack */ var vp = moi.ui.mainWindow.viewpanel.getViewport('3D'); var data = new Object; data.camera = vp.cameraPt; data.target = vp.targetPt; var cm = moi.command; var views = new Array(); try { v = cm.getOption( 'views' ); if ( v ) views = v; } catch(e) {} views.push( data ); cm.setOption( 'views', views );


Restore view:

script: /* Restore the next view in the saved view stack */ var cm = moi.command; var views = null; try { views = cm.getOption( 'views' ); } catch(e) {} if ( views ) { var lastrestored = -1; try { lastrestored = cm.getOption( 'last_restored_view' ); } catch(e) {} var i = lastrestored + 1; if ( i >= views.length ) i = 0; var data = views[i]; var vp = moi.ui.mainWindow.viewpanel.getViewport('3D'); vp.setCameraAndTarget( data.camera, data.target ); cm.setOption( 'last_restored_view', i ); }


Clear saved views:

script: /* Clear the saved view stack */ moi.command.setOption( 'views', 0 );



Paste in each of those scripts for the command part of a new keyboard shortcut.

You might try setting up something like the saved view one on Shift+V, the restore view one on just plain V, and the clear saved views one on Alt+V (or whatever keys you wish).


So the way it works is that each time you press the "Save view" one, it will record a new saved view in an internal list so you can record one, then adjust the view a bit, record another one, etc... You can hit the "Restore view" key to cycle through those saved views one by one. If you want to start over again, hit the "Clear saved views" key and the saved stack will be removed.


The saved view stack in this case is only a runtime thing, it is not saved with your file and there isn't any method for fine tuning or replacing a view in the middle of the stack so it is fairly crude but it might give you at least the basic mechanism to set up several steps and "replay" them.

- Michael

EDIT: updated scripts to work with v3 as well now.

EDITED: 26 Jun 2013 by MICHAEL GIBSON

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael T. (MICTU_UTCIM)
2891.8 In reply to 2891.7 
This is great Michael G! Just what I was looking for!

Thanks again,

Michael T.

Michael Tuttle a.k.a. mictu

http://www.coroflot.com/fish317537

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Marc (TELLIER)
2891.9 In reply to 2891.7 
I've wished for something like this a couples of times, thanks Michael!

Marc
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Mike K4ICY (MAJIKMIKE)
2891.10 
Michael... Just noticed:

Upon using the "Clear saved views:" (in Beta V3) I get the following Script error whenever any of the above scripts are used afterwords:

TypeError: Result of expression 'views' [undefined] is not an object.

MoI has to be restarted to continue using the above scripts.

Aside from that, very useful set of scripts!
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
2891.11 In reply to 2891.10 
Hi Mike, I've updated the scripts above (all 3 of them) so that they should now work ok with v3. There is a slight difference with how 'null' in script is interpreted between v2 and v3.

The updated ones should now work in both v2 and v3, at least I think so. Please let me know if you still see any problems with them.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  Mike K4ICY (MAJIKMIKE)
2891.12 
Works great now Michael!

This is really useful!
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All