Volume calculator
 1-20  21-40  41-60  61-76

Next
 From:  Moier (STARDUST)
7421.1 
Hi Moi'ers

Is there an available script for volume calculation of an object?

Thanks
Stardust
  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
7421.2 In reply to 7421.1 
Hi Stardust, sorry no there's not, it would be difficult to do by script alone. I do want to add a volume calculation in the future but currently your best bet would be to import your model into a different CAD program and do the volume calculation there.

- 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:  wastzzz
7421.3 
It could be possible with an intricate script using some integral in the 3d space.. Like creating a grid of boxes and then sum up the volume of every of them. But its gonna be approximated.
Max
  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:  Frenchy Pilou (PILOU)
7421.4 
You can use the marvelous free DesignSpark Mechanical! (export from Moi in STEP file format)
http://moi3d.com/forum/index.php?webtag=MOI&msg=6186.27
Read all the thread for some vital info! ;)
You can also take some volumic mass!

EDITED: 29 May 2015 by PILOU

  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:  Marbleman
7421.5 
Does Onshape have a Volume Calculator?
  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:  Frenchy Pilou (PILOU)
7421.6 In reply to 7421.5 
---
Pilou
Is beautiful that please without concept!
My Gallery
  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:  Max Smirnov (SMIRNOV)
7421.7 
This script can approximately calculate a volume of selected solid object (I told about it in this thread: http://moi3d.com/forum/index.php?webtag=MOI&msg=3746.7 ).
It can't calculate volume exactly, because it doesn't use any mathematical method (as Michael said above, it's very difficult task).
This script just creates a grid of lines and cut them with surface of the solid object.

Anyway it works :)
I used this object to test the script.


I use it because we can calculate exact volume of this shape:
Box (20x20x5) - Box (12x12x3) + Half sphere (R=5) - Cylinder(R=3,h=5) =
20*20*5 - 12*12*3 + 4*Pi*5*5*5/6 - Pi*3*3*5 = 1688,4277183876

And now script results:
Grid density: 10, time: 0.1s, result: 1570,999037, accuracy: >92%
Grid density: 50, time: 0.6s, result: 1659,717703, accuracy: >98%
Grid density: 100, time: 1.7s, result: 1686,79025, accuracy: >99.9%
Grid density: 300, time: 14.8s, result: 1688,279379, accuracy: >99.99%

Good enough! :)

Default value of the grid density is 100. You can set other values as command line parameters. Example: _CalcVolume 150
To increase performance I put all code in htm file. Be careful, this script can really hang up MoI. Don't set density values more than 300-350.

EDITED: 7 Mar 2022 by SMIRNOV

  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:  dinos
7421.8 
I did a volume calculation script some time ago, but i didn't post it as it could use some more polishing.
Even so, it works fine for my needs (3D printing).

It uses a different method from Max's script (BTW, cool script & idea Max!).

This script works by exporting the selected solid to an STL file and then loads it back and calculates the volume from the STL data.
Accuracy is adjustable by editing the Angle value at line 12. I've settled on 3 degrees as a nice compromise between speed and accuracy.
Overall its is really fast unless you go too crazy with the angle.

Its biggest limitation is that you have to manually set the STL export format to Ascii. Reading the binary format without typed arrays would be too slow and complicated i think.

That can be easily fixed if there is a way to set the STL export options to Ascii during export, but nothing that i tried worked.
Perhaps Max or Michael can help!


Dinos
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:  Marbleman
7421.9 
Thank you Max, just tried it out and it works well, I will try it out on a project on Monday....
  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:  Frenchy Pilou (PILOU)
7421.10 
Cool new tools! max Moi calculate default is 10 second on my computer result: 1686790,25
(free DesignSpark mechanical gives with Step volume exported from moi) in 0 second! ;)
1688427,718mm³ against theoric 1688427,718 3876

EDITED: 30 May 2015 by PILOU

  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:  Max Smirnov (SMIRNOV)
7421.11 
Dinos
Great work!
I didn't knew about this method.
http://research.microsoft.com/en-us/um/people/chazhang/publications/icip01_ChaZhang.pdf
This algorithm is much faster than all moi calculations in my script.
I have some ideas:
1. Add line: moi.copyTextToClipboard(volume);
2. Add line: file.close(); moi.filesystem.deleteFile( fileName );
3. Obj file smaller than Stl. Script will be faster with export to Obj.

Marbleman
Thank you!
But Dinos's script is much better. :)

Pilou
>>free DesignSpark mechanical gives with Step volume exported from moi) in 0 second!
It's incompartable things. :) Of course the C++ compiled code will be faster than thousands calculations of moi factories, or exporting and reading stl files from harddisk.
But it's better than nothing.

P.S. We need to add data about densities of various materials.

EDITED: 30 May 2015 by SMIRNOV

  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:  Frenchy Pilou (PILOU)
7421.12 
About the Dino script
<< This script works by exporting the selected solid to an STL file and then loads it back and calculates the volume from the STL data.

Where I load it back ? In Moi there is not Import STL ! ???
---
Pilou
Is beautiful that please without concept!
My Gallery
  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:  dinos
7421.13 In reply to 7421.11 
Thanks Max! Really appreciated. :-)

I was looking for an efficient way calculate volume and hit upon this http://stackoverflow.com/questions/6518404/how-do-i-calculate-the-volume-of-an-object-stored-in-stl-files

Really nice ideas, BTW!
I think that using obj is a good solution and it can improve things a lot. Also, materials!

I'll be away from my computer until monday night, but in the meantime feel free to improve this script any way you like!
I really like the idea of the mini open source scripts that are created on this forum by 2 or more people. That was the case with the LightOptions script. It was Mike's idea and helped a lot during its development. Then you included it in your UI and it was improved once again.
Cool stuff.

Dinos
  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
7421.14 In reply to 7421.8 
Hi Dinos, re:

> That can be easily fixed if there is a way to set the STL export options to Ascii
> during export, but nothing that i tried worked.

That should be something like:

var OldSTLExportType = moi.settings.stlExportFileType;
moi.settings.stlExportFileType = 'Ascii';


<....>


// Reset original STL export type when finished.
moi.settings.stlExportFileType = OldSTLExportType;


- 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:  Max Smirnov (SMIRNOV)
7421.15 
Updated version of Dinos's CVolume.
Now it uses obj file. Performance boost +50~100%
Defaut angle = 3. You can use command line parameter to change it. Example: _CVolume 10 or _CVolume 1

EDITED: 7 Mar 2022 by SMIRNOV

  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:  Frenchy Pilou (PILOU)
7421.16 In reply to 7421.15 
How it works ? Inside Moi ? You import an OBJ file ?

Ok , I have found the method : Now 1 second on my computer! :)

But same time and result when adding a number! (little or big)
1685.156253 When importing an OBJ

With the normal file
1688,220446 in 2 seconds by default _Cvolume

1668, 250237 in 1 Second with _Cvolume 10

1561,334244 in 0 second with _Cvolume 100

EDITED: 31 May 2015 by PILOU

  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:  Max Smirnov (SMIRNOV)
7421.17 In reply to 7421.16 
Pilou, forget about obj :)
It's internal script mechanics. The script exports solids to an obj-file, then loads them back as polygonal model, and calculates volume.

P.S. I have great ideas about this script. ;))
  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:  Frenchy Pilou (PILOU)
7421.18 In reply to 7421.17 
:=)

Yet existing is now some speedy : just maybe the precision can be improved a little! :)

EDITED: 31 May 2015 by PILOU

  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
7421.19 In reply to 7421.17 
The script requires running MoI with elevated privileges to work in Windows default installs. If you can look at how you are writing the objects to avoid that would be good.
  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:  Max Smirnov (SMIRNOV)
7421.20 In reply to 7421.19 
Hi BurrMan
new version of the script will use system temp dir instead of moi dir.
  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:  1-20  21-40  41-60  61-76