Script - Calculation of the center of mass coordinates

Pavel Yakovlev (Moderator (RUS)) 9 years ago in Scripting 0
Hi colleagues,

The following script was created to save coordinates of polygons center of mass to a separated DAT file. The window of the script is below:

Image 663

Specify STR file as an input file and fill X, Y, Z, Join and Polygon fields. The first four fields are familiar to users, so I will say a few words about Polygon value. This is needed to join number of strings to one polygon in case the polygon has holes inside.

Image 664

In the picture above we see that two separated strings must have different polygon value. Polygon 1 consists of two strings so its center of mass coordinates will be calculated for the polygon with the hole.

Specify a point file as an output where coordinates will be saved.
Good luck!

Download script here: GUI - Center of mass.py

Before running the script on your machine, ensure that you have Python installed because it uses Tkinter module that is not built in Micromine. You can download Python using one of the following links:
  • Micromine 2013 – download Python here.
  • Micromine 2014 32bit – download Python here.
  • Micromine 2014 64bit – download Python here.
  • Not recommended to install several versions of Python on one machine
  • Restart Micromine when instalation process is finished.
If you have any problems, feel free to ask.