Table of Contents
Manipulate the datamanager via MineSight® objects.
This module gives you the ability to manipulate the folders and objects located in the datamanager.
Currently the datamanager module is limited to working with Geometry objects. Furthermore, you are unable to modify the materials.
Note
The MineSight® Object is often referred to as a MOB. This comes from having fun with the term '[M]ineSight [O][b]ject'.
With all the datamanager functions, the path refers to the path within the datamanager. Where the datamanager.ROOT refers to the base directory within the datamanager. You can compose paths easily by taking advantage of the Python's os.path.join function. For example, if you wish to construct a path called \phase2\pit1 for a pit1 geometry MSR file, you would do the following,
pit1path = os.path.join(datamanager.ROOT, "phase2", "pit1")
FILTER_GEOMETRY FILTER_MODELVIEW FILTER_ALL
Filter flags, for use with the get_selected function. FILTER_ALL is equivalent to using all the flags. This means,
FILTER_ALL is equal to FILTER_GEOMOBJ | FILTER_MODELVIEW
DEFAULT_GEOMETRY_MATERIAL
The name of the material in the DEFAULT_GEOMETRY_MATERIAL_PATH.
DEFAULT_GEOMETRY_MATERIAL_PATH
The default path for the materials assigned to geometry objects. It should be \materials\geometry.
Creates a new GeometryMob at the given path with the given material. An example of creating a standard geometry file called mygeometry in the MineSight® Resource directory would be,
which will use the Geometry material for your new geometry object. See also Paths in the Datamanager.
The material_path will default to the DEFAULT_GEOMETRY_MATERIAL_PATH.
If the path already exists, then an open geometry object is returned, if the path does not exist, one is created using the material_path. The same concepts apply here as they do in the create_geometry and open_geometry functions.
The material_path will default to the DEFAULT_GEOMETRY_MATERIAL_PATH.
Creates a new ModelViewMob at the given path (see Paths in the Datamanager). The pcfpath is the path to the project control file on the user's file system. The modelname refers to the name of the model file to view. For example,
will create a "mymodelview" within the root directory of the datamanager that uses the msop10.dat found at c:\msop\msop10.dat to create a view of msop15.dat.
Returns a list of paths in the datamanager that are highlighted by the user.
An example of only getting a GeometryMob and a ModelViewMob that were selected by the user,
This will only consider those items selected in the contents portion of the datamanager.
Will cause the object in the datamanager to close and a no longer display in the viewer.
New in version 10.0.
Scans the contents of the given folder and returns a list of all datamanager paths for that folder.
You can use a filter to control what object type paths to return in the same way the get_selected function uses the filter. The default is to return ALL available objects.
If isrecursive is True (1), then the search is done recursively through the given folder. The default is not to recurse through the folder.
The following example will return all geometry objects within the entire project.
See the $(medexe)\scripts\samples\grail.ms3d.datamanager\em-list-filtered.py script for an example of using the list_filtered function.
Creates a new folder if and only if the parent folder already exists. In order to use this function correctly you must specify a parent folder within the path. For example, the following will create a folder off the root directory for the datamanager,
path = os.path.join(datamanager.ROOT, "my_folder")
# path is "\\my_folder"
datamanager.make_folder(path)
In this case, the root directory, "\", is the parent folder. Simply doing the following will not result in a folder being created,
datamanager.make_folder("my_folder")
The make_folder routine is capable of creating folders recursively. In other words, if a portion of the required path does not exist it will be created. For example, if you lack a folder called "phase1", the following will work,
path = os.path.join(datamanager.ROOT, "phase1", "my_folder")
datamanager.make_folder(path)
and result in a "\phase1\my_folder" folder within the datamanager. In the above example the missing folder, "phase1" was created for you.
If the requested path already exists, this will generate a IOError. One trick to create folders if they do not already exist, and to just pass if it already exists is to do the following,
try:
datamanager.create_folder("\\phase1")
except IOError:
pass # folder already exists
open_geometry(path)
Opens a GeometryMob object.
Updates the display of the object pointed to by the path. The object can not have any open references. The following code snippets illustrate a valid and invalid method for refreshing your MineSight® Object.
A valid refresh with a MineSight® Object that has been closed,
An invalid refresh with a MineSight® Object that is still open,
Removes a MineSight® object from the project.
If there exists any MineSight® Objects that are still open (including ones that may have been open prior to script execution), then this function will generate an IOError [1].
Will cause the object in the datamanager to open and display in the viewer.
New in version 10.0.
The following sections discuss the various types of MineSight® Objects you can load up via this module.
Defines a MineSight® Geometry Object.
This object is returned by the datamanager.create_geometry or datamanager.open_geometry functions.
Sets a new material on the GeometryMob object. The material should be specified as a name that exists within the materials folder.
If the material does not exist, and the create_if_not_exist is set to 0, then an IOError will be generated. If you set create_if_not_exist to 1, then a new material will be created in the project's material directory.
Defines a MineSight® Modelview Object.
This object is returned by the datamanager.create_modelview or datamanager.open_modelview functions.
[1] | "Built-in Exceptions" Python Library Reference. 19 December 2001. 31 May 2004. <http://www.python.org/doc/2.2/lib/module-exceptions.html> |