Programmatic modeling by script?

Next
 From:  chippwalters
7176.1 
Is it possible to do all this in one script?

1. create a cube of set dims. (say 100mm x 130mm x200mm)
2. Fillet the top of it with a suitable radius (15mm)
3. generate a smaller cube which intersects the original cube and then boolean delete it from the original cube.
4. assign a name to the newly formed object? (Fred)
5. create 5 more like this.
6. Answer "Done!"

IOW, can one write a program which generates unique MoI model scripts which then can be executed in MoI to generate finished models?

Also, is there a plugin with a getfile requestor which can run external scripts?

TIA!

EDITED: 13 Jan 2015 by CHIPPWALTERS

  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:  bemfarmer
7176.2 In reply to 7176.1 
In my opinion, the Fred script could be done.
The placement of the smaller cube is a bit vague.
Also, fillets and Booleans may not work for all parameters(?)
Depending on the programmer, writing the script would take a lot longer than creating Fred interactively(?)

- Brian

EDITED: 13 Jan 2015 by BEMFARMER

  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
7176.3 In reply to 7176.1 
Hi Chipp,

> Is it possible to do all this in one script?

It should be theoretically possible, but MoI is not currently oriented around creating procedural geometry by script like that, so there are various difficulties involved not the least of which is a lack of documentation on how to do scripts. In the future at some point I do expect to work on making MoI more friendly for doing stuff like that, but for now the learning curve is high enough that you will save a lot of time just doing those steps directly in the regular way.


> IOW, can one write a program which generates unique MoI model scripts
> which then can be executed in MoI to generate finished models?

It's theoretically possible, basically the same comment from above applies.



> Also, is there a plugin with a getfile requestor which can run external scripts?

I don't remember any existing plug-in like that, but you can prompt for a file name using:

var filename = moi.filesystem.getOpenFileName( 'Choose a script file', '*.js;Script files' );
if ( filename = '' )
return; // user canceled dialog

Then it should be possible to open the file and read its contents in using moi.filesystem.openFileStream - you can see how it's used in some of the CustomUI mechanisms.

Then once you have read it in, there is a JavaScript function eval() that can execute script from a string.

- 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:  chippwalters
7176.4 
Thanks for the feedback.

I was thinking about creating an algorithmic design tool which, when given input (number and kind of controls, profile rect, iteration level, mutation index, etc.) would automatically create a variety of geometry previews which could then generate MoI scripts which are then processed. The technique would be easier to build as a 2D depth map for a voxel modeler like 3D-Coat, but it would be much cooler to create reusable geometry directly in MoI.

Given time, I plan to continue to work on creating an app which creates a z-depth preview 2D (2.5D actually) first and see what I can come up with. Once I have something running and able to show, I may ask for some basic help porting the data, in a direct and simple way, to MoI as a POC. FWIW, a few years ago I programmed a set of CAD tools in Python for e-on's Vue software (VueTools), so I hope with a small bit of direction (and some time) I may be able to create a very basic form generation tool (fingers crossed).

FWIW, I believe the next big breakthrough in 3D is automated form generation. Too many people do not have the design nor technical skills to create functional, high quality 3D models, and with the 3D Printing revolution well under way, there is a serious void in the ability to allow 'everyman' to play in this field. Humans are much better at critiquing than creating OR put another way it's easier to select what you like from a series of choices rather than start with a blank canvas. There are attempts at this already at places like Thingiverse with OpenSCAD. Grasshopper is also cool, but at this time it focuses on more abstract than real solutions.

I've often thought (and spoken a couple times to anyone who would listen) about using genetic algorithms and neural nets to help generate lots of high quality design choices-- where the algorithms eventually become design personalities based upon a subject matter experts and some judicious knowledge engineering. I was in fact talking about this to some board members from the Foundry today and as an aside, did mention to them to check out MoI and how Michael has done such a marvelous job at hiding the hundreds of possible commands and icons from users and instead giving them an elegant and extremely usable interface with unsurpassed learning curve and surprising power. The Foundry's products are all but impossible to 'casually use'-- which isn't a huge problem now as their current market is mostly professional.

I believe the ability for users to be able to 'casually' use 3D will become more and more important as skills like 3D printing along with product and idea visualization allow for a broader skill set base for average folks. The CGI and VFX industry is only just so large-- and not really growing. MoI, Keyshot and SketchUp are a few of the products with a super fast learning ramp time along with retentionability (???) --> the ability for one to come back to a tool months later and remember how to get something done. Both criteria, IMHO, are most important for success in the next generation of 3D software.
  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
7176.5 In reply to 7176.4 
Hi chipp, yeah unfortunately MoI is still fairly immature in that area of user scripting. It's something that I want to enhance more in the future but so far the focus in MoI (like you note) has been very much on "regular user experience" and not so much on things that are specific only to advanced users...

If you do want to dig into it anyway, you can find some initial info here: http://moi3d.com/wiki/scripting - that has the moi.idl file which lists the basic object model that shows what properties and objects are available to scripts.

Then the main way to see how it works is to examine the existing command scripts and UI code which you will find inside the \commands and \ui sub-folders inside of the main MoI installation (if you're on a mac, right-click and choose "Show package contents" and inside there go to drive_c/moi to find the commands and ui subfolders).

But like I mentioned expect to have a high learning curve with a lot of exploration and testing required, things in that area have just not been a big target area for MoI as of yet, there are plenty of things that I want to do in the future to make something like what you are describing somewhat easier to accomplish, right now there would be a lot of work and time involved.

- 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:  chippwalters
7176.6 In reply to 7176.3 
Thanks again. Another question. Is it possible to launch an executable from MoI's Javascript? I expect to create my application as an app or exe file and it would be great if I could launch it from a button inside MoI.
  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
7176.7 In reply to 7176.6 
Hi chipp, you can launch an external program from a MoI script by calling moi.filesystem.shellExecute( 'c:\\somedir\\someprogram.exe', 'parameters' );

That will call the system shell execute, same as if you had typed it into the Windows "Run" dialog box. If you give it an .exe file it will open the .exe

- 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:  chippwalters
7176.8 In reply to 7176.7 
Thanks! Much appreciated.
  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