Getting camera view and restore it

Next
 From:  Samba Oleg (SAMBA_OLEG)
9356.1 
Hello,

maybe I am to stupid, but I just cannot figure out how to read out the camera position of a specific view and restore this view later via a hotkey. I need to restore these views for a documentation project where is use MOI4 beta (since the MOI3 always crashes because of the complexity of my models). I would be grateful if someone could help me out. I have no coding experience at all.

Thanks a lot in advance.

EDITED: 6 May 2019 by SAMBA_OLEG

  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:  Death
9356.2 In reply to 9356.1 
Not sure if this is it, but I'd set these values to whatever you need:




Attachments:

  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
9356.3 In reply to 9356.1 
Hi Samba, MoI does not currently have a view save/restore type function built in, it is something that I want to add in the future though.

In a pinch you could use what is described here:
http://moi3d.com/forum/index.php?webtag=MOI&msg=5981.2

- 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:  Samba Oleg (SAMBA_OLEG)
9356.4 
Thank you Death, but I already tried these settings, but it can't exactly reproduce the viewport settings.

Thank you Michael,

I could solve my problem reading the threads.

My solution now is to

1) Get the Position with a script using a hotkey:

script:var v = moi.ui.mainWindow.viewpanel.getViewport('3D'); moi.copyTextToClipboard( 'Camera=' + v.cameraPt.toString() + '\r\nTarget=' + v.targetPt.toString() );

The result is:

Camera=407,04,-682,82,-230,78
Target=62,01,-44,72,-21,64

2) Replace some commas with points:-(((

Camera=407.04,-682.82,-230.78
Target=62.01,-44.72,-21.64

3) Edit the script for the camera:

script: camPt=moi.VectorMath.createPoint(407.04,-682.82,-230.78);targetPt=moi.VectorMath.createPoint(62.01,-44.72,-21.64);moi.ui.getActiveViewport().reset();moi.ui.getActiveViewport().setCameraAndTarget(camPt,targetPt);

4) Enter the script using TAB.

It works, but is not very comfortable.
  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
9356.5 In reply to 9356.4 
Hi Samba, maybe try this method instead:
http://moi3d.com/forum/index.php?webtag=MOI&msg=6962.13

Is that any better?

- 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:  Samba Oleg (SAMBA_OLEG)
9356.6 In reply to 9356.5 
Hi Michael,

this makes it a lot easier. Thank you very much.
  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
9356.7 In reply to 9356.6 
Hi Samba, you're welcome!

Also if you're going to that particular dialog frequently you can set up a shortcut key for showing it. Put this in as the command part for the shortcut key:

script: moi.ui.createDialog( 'moi://ui/ViewAngleDialog.htm' );

- 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:  Samba Oleg (SAMBA_OLEG)
9356.8 In reply to 9356.7 
Thanks again for this hint!

This will speed it up a lot. I have so many different view in my documentation.

Is there any change to automate the process of converting the given coordinates into a reusable format without changing comma to dots and spaces?


Result of the 1st script:

Camera=407,04,-682,82,-230,78
Target=62,01,-44,72,-21,64

Needed Values for the dialog box:

407.04 -682.82 -230.78
62.01 -44.72 -21.64

Samba
  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
9356.9 In reply to 9356.8 
Hi Samba, do the different fields in the dialog not use commas for the decimal separator when you first open it? It is supposed to if your operating system language settings have that set.

Does this work where the numbers are separated by spaces? :

script: function str(pt) { return moi.ui.formatCoordinate(pt.x,2) + ' ' + moi.ui.formatCoordinate(pt.y,2) + ' ' + moi.ui.formatCoordinate(pt.z,2); } var v = moi.ui.mainWindow.viewpanel.getViewport('3D'); moi.copyTextToClipboard( 'Camera=' + str(v.cameraPt) + '\r\nTarget=' + str(v.targetPt) );

Let me know if that still isn't quite right.

- 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:  Samba Oleg (SAMBA_OLEG)
9356.10 In reply to 9356.9 
Hi Michael,

I always get the commas as the decimal separator. This is the return of the last script:

Camera=10,24 -20,48 10,24
Target=0 0 0

My system is set to German.

Samba
  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
9356.11 In reply to 9356.10 
Hi Samba, and that doesn't work to put in those comma decimal separator values in the dialog?

Here's another version that should make period decimal separators:

script: function str(pt) { return moi.ui.formatCoordinate(pt.x,2).replace(',', '.') + ' ' + moi.ui.formatCoordinate(pt.y,2).replace(',', '.') + ' ' + moi.ui.formatCoordinate(pt.z,2).replace(',', '.'); } var v = moi.ui.mainWindow.viewpanel.getViewport('3D'); moi.copyTextToClipboard( 'Camera=' + str(v.cameraPt) + '\r\nTarget=' + str(v.targetPt) );

- 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:  Samba Oleg (SAMBA_OLEG)
9356.12 In reply to 9356.11 
Hi Michael,


it's a bit funny. The extended view angle dialog shows the camera and target position with commas on my system, but it only accepts the coordinates with a period decimal separator.

So, the last script solved the problem for me.

Thank you very much for spending so much time.


Samba
  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