MoI discussion forum
MoI discussion forum

Full Version: Scripting and Node Editor in Moi3D V5

Show messages:  1-20  21-28

From: NaN
16 Apr 2023   [#1]
On first sight Moi3D isn't really made for parametric designs - which is ok.
But on second sight it has everything on board to make parametric designs that even go beyond what most other parametric UI-driven tools can do - via scripting and the node editor!
Same thing with Rhino - Making Grashopper and Rhino-Python first class citizens were imho two of the most impactful features in V7.

Would such a step also make sense for Moi3d V5? I mean, both a scripting interface and a node editor already exist. They are currently just not very documented in the case of scripting and/or separate hobby-maintained plugins in the case of the node editor. Making them an integral part of Moi3D, moving them in the spotlight and providing a way for the community to exchange their modules and templates could be a BIG thing for the new version here also!

Is Moi3D internally generating scripts for all UI user interactions already? If yes, it might be great to provide this script representation - so one could copy out the auto generated "macro" and just replace some of the constants with parameters. An approach that could also be interesting for people without much programming experience to make parametric models in Moi3D.

And further down the line, perhaps it might also make sense to think about a convenience layer on top of the current scripting api - like e.g. build123d is a layer on top of the OCP wrapper around OpenCascade that mainly makes it much more comfortable to use. (On the other hand keeping a 1:1 mapping between UI interactions and scripting would also have it's merrit, so one can even "round-trip" between UI and code to some degree.)
But as a first step just making what already exists more visible and polished could be a big thing!

Edit: Just came across the amazing extension of the node-editor by nkallen that allows to auto-generate nodes when constructing in the UI and vice versa to change the parameterization of the nodes and regenerate the geometry. This is really impressive! Having this in the main application would be really great!
Perhaps even some mapping between node editor schemas and scripts - so one could edit a larger node schema in a text editor and auto-layout it in the node editor again for people who prefer the graphical representation. Full UI<->node editor<->scripting roundtrip!
From: pressure (PEER)
17 Apr 2023   [#2] In reply to [#1]
Hi NaN,

There's some info about scripting at http://moi3d.com/forum/index.php?webtag=MOI&msg=10889.2

Re:
> Is Moi3D internally generating scripts for all UI user interactions already?

Basically everything comes from static .js and .htm that you can inspect and modify. Look at the program files / package contents associated with MoI for these.

- Peer
From: NaN
17 Apr 2023   [#3] In reply to [#2]
Thanks for the pointers!

I understand that scripting was an "under the radar" feature for several releases. Even though one can find all the informations, a central documentation with examples would certainly help to move these features more into the spotlight! And I guess the majority of the MoI users don't even know that there is a capable node editor plugin that they could install and use. And then, a guide how to actually use it.
Official support would also add certainty that this is not potentially incompatible with the next MoI version, like it could happen as long as it is "just" an external fan plugin.
From: Frenchy Pilou (PILOU)
17 Apr 2023   [#4] In reply to [#3]
About nodes! ;)
https://moiscript.weebly.com/biblio-elephant.html
From: NaN
17 Apr 2023   [#5] In reply to [#4]
Thank you, great overview!
The examples are pretty awesome! Could something like this be integrated into the node editor? Like in Max(MSP) where you can click on any object to get a description and a usage example.
From: NaN
17 Apr 2023   [#6] In reply to [#5]
Is there a tutorial how to build a design from scratch with the node editor?
So building a parametric sketch. Then applying parametric features to that, etc. (On first sight most examples for graphic primitives like Polyline etc. in the overview from Pilou start with existing, "selected" geometry.)
Something really basic that can act as how-to cookbook, like the introductory examples from this code cad: https://build123d.readthedocs.io/en/latest/introductory_examples.html
From: NaN
17 Apr 2023   [#7] In reply to [#6]
Some features don't seem to work with MoI V4? E.g. when clicking on "Macro" I get:

Image Attachments:
Screenshot 2023-04-18 003630.png 


From: NaN
17 Apr 2023   [#8] In reply to [#7]
The nkallen extension that automatically generates node trees from UI interactions is probably the best "node editor howto tutorial" one can have.
These node graphs get pretty involved quickly... :) (From a certain complexity on one probably would have to structure node graphs like programs. My guess is that the (currently non functioning(?) macro feature would provide that - kind of sub-patches that allow to structure larger graphs?)
From: bemfarmer
17 Apr 2023   [#9] In reply to [#8]
The nodeeditor Macro feature IS functioning.

MoI wiki has section on nodeeditor, and link to some Macro documentation.

- Brian
From: NaN
17 Apr 2023   [#10] In reply to [#9]
Thank you for writing this macro documentation!
Hm, then something is wrong with my installation. I don't even get to the Create etc. menu when clicking on the Macro entry in the top menu - I get the error message from the screenshot above right away.
From: Michael Gibson
17 Apr 2023   [#11] In reply to [#10]
Which version of the node editor are you using when getting the macro error?

Does it happen if you use the version from James here:
http://moi3d.com/forum/index.php?webtag=MOI&msg=9358.1
?

- Michael
From: Michael Gibson
17 Apr 2023   [#12] In reply to [#1]
Hi NaN,

in reply to your first message in this thread:

re:
> Would such a step also make sense for Moi3d V5?

I'm reluctant to do so because it would signal that those areas would be core first class supported features when that is not the case currently.

The main reason for that is the amount of work required - as you note documentation would need to be created which is very time consuming and also just general support of other developers is also very time consuming.

I don't mind the current support load which comes with the implicit understanding that you need to be quite a bit on the "self starter" side to work in these areas. But it could get pretty hard for me to find the time for it if it was advertised as a core area.

- Michael
From: NaN
17 Apr 2023   [#13] In reply to [#12]
Hi Michael,

thanks for the feedback. Even though that is not the answer I was hoping for I can understand that support effort would increase and that you have to manage your time.

So my last plead in this regard would be to at least consider to ensure that the node editor stays compatible with new Moi3d versions and to continue offering scripting capabilities for new features. Then people who want to spend the effort can work with what is there and rely on it staying functional without overboarding support effort.
From: NaN
17 Apr 2023   [#14] In reply to [#11]
^^Yes, I used the node editor version from James with the recent version of MoI V4. I can retry with the V5 beta when at home again.

Edit: I just installed the Moi3D V5 beta (this time on a M2 Mac instead of a Windows machine) and am getting exactly the same error message when clicking on "Macro".
I placed the uncompressed node editor under "Moi v5 beta Apr-13-2023.app/Resources/ui" and added this start script to the shortcuts: moi.ui.createDialog( 'nodeeditor/index.html', 'resizeable,defaultWidth:680,defaultHeight:420', moi.ui.mainWindow )
From: Michael Gibson
17 Apr 2023   [#15] In reply to [#14]
Hi NaN, re: Macro error message - looking at the error it kind of looks like the macro code is assuming that the node editor is installed in the appdata folder instead of in the ui folder.

On Mac the appdata folder is at "~/Library/Application Support/Moi", note that the Library folder is hidden by default, you can show it by holding down Shift+Cmd+. (period), or from the menu use Go > Go to Folder

On Windows open the Start menu and type %AppData%\Moi and push Enter, which will expand to something like C:\Users\<Your user name>l\AppData\Roaming\Moi

It's actually generally better to install stuff in the appdata folder since it's a centralized location outside of any one version's app bundle, so new versions will find things there without needing to copy files into each new version's individual .app bundle.

So put it in a folder like: ~/Library/Application Support/Moi/nodeeditor , and then for the launching script on a shortcut key you'll need to have moi://appdata at the start of the URL like this:

script: moi.ui.createDialog( 'moi://appdata/nodeeditor/index.html', 'resizeable,defaultWidth:680,defaultHeight:420', moi.ui.mainWindow );

If that solves it let me know, I'll update the wiki. Probably the wiki install information is from Moi version 3 which was before there was appdata folder support.

- Michael
From: NaN
17 Apr 2023   [#16] In reply to [#15]
Yay, thanks, that works!
From: bemfarmer
21 Apr 2023   [#17]
AFAIK, nodeeditor does not have any Group related nodes?

- Brian
From: NaN
21 Apr 2023   [#18] In reply to [#17]
I have been experimenting with "macro" as group. Seems to do the job!
Edit: Oh, you probably mean selecting existing geometry and grouping it via nodes, not grouping nodes? Hm, no idea in that case. (Still only scratching on the surface)
From: wayne hill (WAYNEHILL5202)
21 Apr 2023   [#19] In reply to [#18]
Hi NaN,

Not quite clear on node groupings, but holding down the shift key while selecting nodes will group them to drag around the screen and select menu options.

Wayne
From: c3g (LONG)
16 Jun 2023   [#20] In reply to [#13]
There is no case for Nodeeditor, I am very interested in Nodeeditor modeling

Show messages:  1-20  21-28