Import STL to MoI
All  1-6  7-20

Previous
Next
 From:  Michael Gibson
7046.7 In reply to 7046.5 
Hi dune1982 - one more round of optimizing attached. This one uses Loft instead, so it only has to create 2 lines, and does more of the factory setup stuff out of the loop.

It might not get much better than this one until sometime in the future when there's more methods for creating geometry from scripts.

- Michael
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:  bemfarmer
7046.8 In reply to 7046.7 
From the clara.io site, downloaded the dragon in .Stl and .Obj formats, to try out import of the two formats to Moi.

Results were similar. Joining took numerous seconds.
Stl had 37 joined surfaces, 450 naked edges in head/neck.
Obj had 39 joined surfaces, 394 naked edges in head/neck.

https://clara.io/view/b64d1057-9b13-4381-9674-4d91dd127f7f#

- Brian

(Still trying to puzzle out the 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:  dune1982
7046.9 In reply to 7046.7 
Thank you Michael, with your optimizations the script is about 3 times faster now on my computer.
It takes about 9sec to import my testfile with 23760 triangles.

Last thing would be to make it read bin stl too.
  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
7046.10 In reply to 7046.7 
Michael,

Downloaded P_ImportSTL.htm and installed in commands folder on Mac.
Didn't show up in Max's ExtScripts button. Tried <tab> and "P_ImportSTL.htm" and "P_ImportSTL" from command bar and still nothing.

Any special sauce on how to use this?
  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:  BurrMan
7046.11 In reply to 7046.10 
Did you get the JS file from the original post?

That's here:

http://moi3d.com/forum/index.php?webtag=MOI&msg=7046.5

EDITED: 31 Oct 2015 by BURRMAN

  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
7046.12 In reply to 7046.10 
(Windows 7)
Scripts that start with _ are listed before scripts starting with alphabetical letters.
P_******* would occur near the tail end of the ext. scripts list.
I deleted the P, and translated the Alert to English: alert("Import complete. " + a + " triangles imported.");

- Brian

There was a recent post about the proper directory for a Mac...
  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
7046.13 In reply to 7046.10 
Hi Chipp yeah Burr's got it - you need the .js file from the earlier post to go along with the .htm file, the .htm file that I posted was just an optimized version of that one file it still needs the other file for the command to be complete.

- 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
7046.14 In reply to 7046.13 
Thanks.

Interesting. I thought the .js would be the business logic and the .html the GUI. So, I figured out you somehow forced the biz logic into the HTML as you said you had changed it. Apparently biz logic can reside in the HTML- and I dunno then what the legacy .js was.
  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
7046.15 
Well, I finally did get the script to run, but I ended up with this dialog:



1) Message saying (I believe) 0 triangles imported
2) Simple STL model (as shown in Mac Preview app)

for this file. FWIW, the STL file I used was a simple file exported directly from MoI3D.
  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
7046.16 In reply to 7046.14 
Hi Chipp,

> Interesting. I thought the .js would be the business logic and the .html the GUI.

It is set up to be like that, but the .js code runs out of process so that it can be canceled at any time by tearing down the worker process, while any code in the .htm GUI side runs in-process. Any calls to MoI from the out of process code run through inter-process marshaling and so have a higher overheard per call into MoI code. This doesn't really come into any significance for regular MoI commands because their business logic just acts at a high level as glue logic, not doing heavier computation directly in the script itself.

So anyway, wedging the code into the in-process GUI side can have some performance improvements for more calculation heavy type code like in this case.

I'm going to attempt to change the threading model in the next version of MoI to make the .js code to run on its own dedicated in-process thread instead of out of process, which will have the downside of losing the automatic canceling (right now anything that runs in the .js can automatically be canceled without any cooperation of the script), but should make the call-into-MoI performance to be equivalent.


re: STL exported from MoI doesn't work - that's probably because your STL file was a binary STL file and this import script only supports ascii STL files currently. In MoI if you go to Options > Import/Export > STL options > File Type and set it to "File type = Ascii" that should then make a file that will work with this importer.

- 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

Message 7046.17 deleted 31 May 2016 by BEMFARMER

Previous
Next
 From:  chippwalters
7046.18 In reply to 7046.16 
Michael,

Thanks for the clear explanation. Didn't know about the ascii vs binary switch in MoI. Thanks for the tip!
  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:  dune1982
7046.19 In reply to 7046.16 
Is there any one that could help me improve the script to read binary stl files too? I have no idea how to parse the binary stl file.
  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:  Michael Gibson
7046.20 In reply to 7046.19 
Hi dune1982 - it will difficult to try and read in a binary file because the method currently set up for scripts to access files (moi.filesystem.openFileStream) is currently only focused on reading text files line by line, and does not have anything set up in it for reading binary files which would be more like reading in a certain number of bytes rather than scanning for carriage returns or newline characters.

- 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
 

Reply to All Reply to All

 

 
 
Show messages: All  1-6  7-20