MoI discussion forum
MoI discussion forum

Full Version: View Manager Script

Show messages:  1-14  15-34  35-45

From: Michael Gibson
23 Mar 2022   [#15] In reply to [#12]
Hi Jörg, can you also please post an example .3dm file and the .views.json file that ViewManager saved?

Maybe it's an issue with the ViewManager script only saving out 2 decimal places when it writes out coordinate information to the .view.json file.

Or it could be a localization problem when commas are used for the decimal places. If I can see the output that it generated on your system maybe that will help me to figure out the problem.

- Michael
From: Teddy Lindsey (TEDDYLINDSEY)
23 Mar 2022   [#16] In reply to [#15]
Michael: thanks for jumping in and fixing the issue with the View Manager Script not handling the "up direction"!

It sounds like it might be helpful to separate out the X, Y and Z values for the camera, target and up Idirection into separate fields in the JSON to avoid localization issues with how commas are handled. I'd be happy to refactor script to handle this as well as a bug I've found that can cause duplication of views when renaming them.

Since it's been a while since I wrote this, I wanted to consult some documentation on scripting for Moi, but it looks like the sites I've used in the past are no longer around, e.g., http://moi.maxsm.net/api/

Can you point me to another site where I might be able to reacquaint myself with the API?
From: Michael Gibson
23 Mar 2022   [#17] In reply to [#16]
Hi Teddy, I think the Internet Archive snapshot of Max's API page might work:
https://web.archive.org/web/20200218200812/http://moi.maxsm.net:80/api/

re: Localization issue - I'm not really sure yet if that's why it's not working for some people. Maybe that can be confirmed or ruled out by checking out an example saved view file.

- Michael
From: Michael Gibson
23 Mar 2022   [#18] In reply to [#16]
Ok, I think it is a comma as decimal separator locale problem. The problem is the MoI point's toString() method uses a locale dependent method for making UI presentable text and the View Manager script is using that.

Here's a quick fix putting in a ptToString() function using built in toFixed() Javascript number to string conversion which shouldn't be locale dependent.

- Michael

EDIT: removed this version, there is a newer one right below.
From: Teddy Lindsey (TEDDYLINDSEY)
23 Mar 2022   [#19]
I've attached an update (View Manager v.0.2.1) that incorporates the latest fixes from Michael for the locale-specific comma problem in addition to the following improvements:
- Fixed a bug where renaming a view might cause duplicate views.
- Improved logic for creating new View names to avoid duplicating an existing View name.

- Teddy

Attachments:
View Manager 0.2.1.zip


From: Michael Gibson
23 Mar 2022   [#20] In reply to [#19]
Thanks Teddy!

- Michael
From: pixelhouse
23 Mar 2022   [#21]
Hi Michael,

I use the V4 Dec. 22 2020
I have saved a small scene in which there are 3 saved views.
I have tested the saved views and the problem still exist.

Thanks for your help!


Jörg

Hi TEDDY,

the new version seems to be good! I will test it out more and in the next hours.

Thanks a lot!

---Edit---

hmm, I still have problems. I have create 3 different views, have try to rename one of this, by clicking "save" all views are lost.
I don't understand, why we have only a "cancel" button and no "OK" button to save the views they are in the list. After Cancel the created views are lost, without click cancel, I can't select objects in the scene.

the positions of the saved views are now correct :)

Hope I can describe it clear to you :)

Attachments:
View Manager.zip


From: coi (MARCO)
23 Mar 2022   [#22]
yyaha..that is working now. tnx.
one tiny thing: if i delete a view, the drop down displays 'select a view'. but if i keep on pressing the delete button - without choosing a view - it silently keeps on deleting views starting with the oldest entry. maybe it would be possible to disable(and greying out) the delete button, if there is no actual view selected.
From: Michael Gibson
23 Mar 2022   [#23] In reply to [#21]
Hi Jörg, it looks like that .views.json file was created by the old script. You'll need to delete it and make a new one with the latest script and then that should be working.

- Michael
From: pixelhouse
23 Mar 2022   [#24] In reply to [#23]
Hi Michael,

yes, the file was created with the old script. Please take a look to my edit in my last post.

Greetings
Jörg
From: Michael Gibson
23 Mar 2022   [#25] In reply to [#19]
Hi Teddy, for renaming there is an "Edit name" dialog that you can use if it would be more convenient.

That goes like this:

code:
    var dlg = moi.ui.createDialog( 'EditNameDialog.htm', 'resizeable,defaultWidth:26em,fixedHeight' );

    /* If you want to initialize the starting name text do this: */
    dlg.htmlWindow.nameval = 'initname';

    var result = dlg.window.doModal();
    if ( result !== -1 ) /* return value of -1 means canceled */
    {
          /* new name in result */
    }


- Michael
From: Michael Gibson
23 Mar 2022   [#26] In reply to [#24]
Hi Jörg,

re:
> Please take a look to my edit in my last post.

So it sounds like the main function of the proper view being restored is ok now. For now if you have problems renaming the views inside the command you should be able to do it by editing the .json file in a text editor.

- Michael
From: Teddy Lindsey (TEDDYLINDSEY)
24 Mar 2022   [#27]
Thanks for the feedback everyone!

Michael: thanks for the tip on using the EditNameDialog! I didn't realize that was possible. I'm sure you're really busy but I would love to see a scripting guide that goes over the various capabilities of the underlying API and object model. It would be super helpful! Also, how would I go about changing the "Cancel" button to an "OK" or "Close" button?

I've attached a new version (v0.2.2) that incorporates the following changes based on the feedback and bugs reported:
- Delete and Rename buttons are only enabled when a view is selected (thanks Marco).
- Renaming now uses a dialog prompt which is much better.

Attachments:
View Manager 0.2.2.zip


From: Michael Gibson
24 Mar 2022   [#28] In reply to [#27]
Hi Teddy, thanks for your updates!

re:
> I'm sure you're really busy but I would love to see a scripting guide that goes over the various
> capabilities of the underlying API and object model. It would be super helpful!

Unfortunately that's a very time consuming area of work, both in generating the documentation itself as well as the time intensive nature of supporting developers.

It's just not an area that I am able to focus on as of yet, not until more stuff is finished up in base MoI itself.


> Also, how would I go about changing the "Cancel" button to an "OK" or "Close" button?

Do you mean on the edit name dialog? It should be showing an OK button on it already.

- Michael
From: Teddy Lindsey (TEDDYLINDSEY)
24 Mar 2022   [#29] In reply to [#28]
Michael: I completely understand having too much on your plate to keep the docs up to date. Hopefully someone in the community could pick that up again at some point.

For the Cancel button, I want to change the one that appears in the sidebar panel. I'm using a commandDialog for my script. Maybe I should be using a different type of component?

Image Attachments:
view_manager_cancel_button.jpg 


From: Michael Gibson
24 Mar 2022   [#30] In reply to [#29]
Hi Teddy,

re:
> For the Cancel button, I want to change the one that appears in the sidebar panel.

For that at the bottom of your ViewManager.htm file, replace this:

code:
<moi:CommandCancel />


with this:

code:
<moi:CommandDoneCancel />


There is no MoI command that puts "OK" or "Close" in that command ui area so if you want it to have one of those you would need to do it manually instead of using a control template.

You can see what <moi:CommandDoneCancel> and other controls expand to by finding the file CommandDoneCancel.htm in the ui folder. When the parser finds a control name with the moi: prefix, it looks if there is an .htm file with that name and if there is it takes the contents of that and inserts it.

- Michael
From: Teddy Lindsey (TEDDYLINDSEY)
24 Mar 2022   [#31] In reply to [#30]
Michael: Thanks for the tip about how the UI components work. I was able to put a Done button inline and it looks better now.

I've attached an update (v.0.2.3) with the following changes:
- Now displaying a "Done" button to close the panel instead of "Cancel".
- View Manager now checks if the 3DM file has been saved before activating so that it knows where to save the "filename.views.json" file which is saved alongside the 3DM file and contains the view settings.

Attachments:
View Manager 0.2.3.zip


From: pixelhouse
24 Mar 2022   [#32]
Hi TEDDY,

now it works like a charme!
Many thanks for your support :)
I love this script and it helps a lot to work together wit Illustrator to create outputs out of the same view.

Best regards
Jörg
From: pressure (PEER)
11 Aug 2022   [#33]
Attached is a version of ViewManager that loads the first saved view (if a saved view exists) as soon as the script is run. It's good for going back to a single view again and again. It will be annoying if that's not part of your workflow.

April 4, 2023: a script with this feature is now at http://moi3d.com/forum/index.php?webtag=MOI&msg=11036.1

- Peer
From: Don (DON_CHEKE)
21 Sep 2022   [#34]
I am running MoI v3 and trying to get the view manager script running but I am having errors and issues.

I have placed the script here: C:\Program Files (x86)\MoI 3.0\commands



I get a error when I try and run the script after using the shortcut keys.



This is my shortcut.



Can someone tel me what I am doing wrong?

Also. which is the latest? View Manager 0.2.1 or View Manager 0.2.3. It was kind of hard to tell from the order in this thread. Sorry?

Image Attachments:
Screen-0003.jpg  Screen-0004.jpg  Screen-0005.jpg 


Show messages:  1-14  15-34  35-45