Table of Contents
Create and manipulate MineSight® elements via this module. Elements are the standard means of communicating data within the MineSight®-3D environment.
Standard definitions for this module:
- Points:
- A list of co-ordinates, defined as: [x, y, z].
- Point Lists:
- A list of points, defined as: [[x0, y0, z0], ..., [xN, yN, zN]].
- Planes:
- A tuple of floats, defined as: (A, B, C, D) where A, B, C & D are the co-efficients of a plane equation
- Face Lists:
All face lists are described such that the first index indicates how many faces are in the face. For example,
[3, 1, 2, 3, 3, 4, 5, 6]States that there are 3 vertexes in the first face, and those vertexes are 1, 2, 3. Then the next face contains 3 vertexes, which are 4, 5, 6. This may seem a bit confusing, but using this structure buys us some definite efficiencies.
Note
All faces in MineSight® products have 3 vertexes.
- Matrix:
This is a list of lists. Each list will contain 4 elements of the form,
[ [e00, e01, e02, e03], [e10, e11, e12, e13], [e20, e21, e22, e23], [e30, e31, e32, e33] ]A modeling matrix, which indicates the transformation applied to a label starting at point P. The transformation matrix typically has rotation and translation data stored in it. Consult a Graphics Programming book for more information on transformation matrices.
All matrices are right-multiplied. The standard is shown in the book Computer Graphics by Foley [1].
- Vectors:
- A list of x, y, and z components, defined as [x, y, z].
- Orientation Vector:
Used to specify the position and orientation of a text element (for example with semi/non-transform labels). The Orientation Vector is comprised of three points: the origin, an up vector, and a right vector. As in,
[[Xo, Yo, Zo], [Xu, Yu, Zu], [Xr, Yr, Zr]]where "o" implies origin, "u" implies up vector, and "r" implies right vector.
The up and right vectors are specified as unit vectors that generate a triangle. The following diagram helps to explain,
![]()
Picture of an orientation vector.
In most cases if you only supply a single point, as in,
[Xo, Yo, Zo]a default up and right vector will be provide for you.
An Element object defines one of the possible geometry types that can be found within MS-3D.
Whenever you create shell (surface/solid), polyline, polygon or marker, you will get Element as a return value.
Typically Geometry MSR files consist of a collection of Elements.
Returns a list of points that define the element (see Point List in Definitions). The values within the point list are with respect to the project's coordinates. If you wish to get the raw point values you will need to subtract the projects x, y and z minimum values (see get_xmin, get_ymin and get_zmin in grail.ms3d.project).
If the Element is a element.NonTransformLabelType (upright label) or element.SemiTransformLabelType (forward label), then this will return the list of points corresponding to the label's location, up vector and right vector.
Returns a facelist that defines the element (see Face Lists in Definitions).
This is only applicable for element.ShellType elements. All other elements will return an empty list ([]).
Returns the label text block alignment around the insertion point.
Call is_label_alignment_block_set() first to see if there is a block alignment set on the label. The return value if not set is meaningless.
This will return one of the following values.
Returns the label line alignment. The longest line in a label defines the label block width. All other, shorter lines will adjust left, center, or right based on this longest line.
This will return one of the following values.
Returns the label color.
Call is_label_color_set() first to see if there is a color set on the label. The return value if not set is meaningless.
Values are between 0.0 and 1.0.
Returns the label font.
Call is_label_font_set() first to see if there is a font definition set on the label. The return value if not set is meaningless.
Returns the font size of the label.
Call is_label_size_set() to see if there is a size set on the label. The return value if not set is meaningless.
Call is_label_size_relative() to determine if the value returned is a percent value from 0.0 to 100.0 or a project unit value.
Returns the character spacing of the label.
This will return one of the following values.
Returns the type of label.
This will return one of the following values.
Element.LABEL_TYPE_FIXED, Element.LABEL_TYPE_FORWARD, Element.LABEL_TYPE_UPRIGHT
Returns the name of the MineSight® Resource (MSR) file that this element belongs too.
For example, if you loaded a shell from a datamanager object found at \myfolder\myshellobject, then this function will return,
If this element has not been "rooted" into a MSR file yet, this method will return a blank string ("").
Returns the path relative to the datamanager for the MSR file. The path will lack the MSR extension.
For example, if you loaded a shell from a datamanager object found at \myfolder\myshellobject, then this function will return,
If this element has not been "rooted" into a MSR file yet, this method will return a blank string ("").
Returns the physical path to the MineSight® Resource (MSR) file on the disk.
For example, if you Resource directory was at c:\myproject\_msresource, and you loaded a shell from a datamanager object found at \myfolder\myshellobject, then this function will return,
Returns the type of the element.
All types are defined in the Data section and are typically named as element.<type>Type. For example a polygon would be a element.PolygonType.
Returns True if the font is bold. False otherwise.
Call is_label_font_set() to see if there is a font set on the label. The return value if not set is meaningless.
Returns True if the font is italic. False otherwise.
Call is_label_font_set() to see if there is a font set on the label. The return value if not set is meaningless.
Returns True if the font size is a 5 size of the screen. False if the size in project units.
Call is_label_size_set() to see if there is a size set on the label. The return value if not set is meaningless.
Set a per label block alignment.
Block alignment is where the origin point for the label is positioned with respect to the text block of the label.
set should be True to set the size. False to remove the setting.
alignment is one of the following.
Returns True on success. False otherwise.
Set a label line alignment.
Line alignment is how each line in the label is position with respect to the longest line in the label text block.
alignment is one of the following.
Returns True on success. False otherwise.
Set a per label color. r, g, and b must be numbers between 0.0 and 1.0 (inclusive).
set should be True to set the size. False to remove the setting.
Returns True on success. False otherwise.
Set a per label font.
set should be True to set the size. False to remove the setting.
fontName is the name of the font you will find in the font picker in MineSight. If it is misspelt or can not be found then this operation will return False and do nothing.
isBold and isItalic will indicate how the font should be rendered. Note, not all fonts have a bold representation.
Returns True on success. False otherwise.
Set a per label size.
set should be True to set the size. False to remove the setting.
size should be larger than 0.0.
isRelative will indication that the provided size is a percent value.
Returns True on success. False otherwise.
Set the label character spacing.
spacing is one of the following.
Monospace will space the letters such that the widest letter also fits in the space provided.
Monospace Number will space the letters based on the widest number character. If you asked to print a 'W' using this option, the W may overlap neighboring characters as there may not be enough space.
Returns True on success. False otherwise.
Set the label type.
type is one of the following.
Returns True on success. False otherwise.
Set a FIXED label to be also locked. This means the label will not flip the rendering of the text when viewed upside down or from behind.
This function will fail if the label type is not set to FIXED.
Returns True on success. False otherwise.
Sets a materialName for the Element, where the materialName is a material defined within the project's materials folder.
If the material does not exist in the project's material folder this function will generate an IOError by default. If you set the create_if_not_exist to 1, then this function will create a new material object within the project.
For example, to set a material on an object, and have that material be created if it does not already exist you can do the following,
Now your Element will have a "SampleMaterial" associated with it, as well as, the project will have a new "SampleMaterial" added to it.
Warning
If your element does not have a name, the set_material function will generate a IOError. Any Element object that lacks a name can not have a material. In order to avoid the potential error, you can use the set_name_and_material to set a name and material in one step.
Sets the name and material on an object in one step. With an Element object you need to specify a name in order to set a material, this convience function lets you do it in one step.
If the material does not exist in the project's material folder this function will generate an IOError by default. If you set the create_if_not_exist to 1, then this function will create a new material object within the project.
In cases where you want to just use the existing name and continue to take advantage of this method, you can do the following,
See also set_material.
Generates a shape based on the shapetype and specified dimensions. All Shapes are defined in this module and are prefixed with SHAPE_. For example, the dump truck shape is defined as, element.SHAPE_DUMP_TRUCK.
Generates a new marker element of type element.MarkerType.
Creates a label at the given position.
Creates a non-transform label at the given position.
Position of the label defined by a point (see Orientation Vectors in Definitions).
In earlier versions of this function you could just supply a single point and a default up and right vector would be supplied for you. This behaviour is still available.
Warning
DEPRECATED (as of MineSight® v8.00) Use create_label() instead. This funtion will still work so old scripts will continue to run.
Create a polygon element.
If the last point on the polygon is not the same as the first, it will be duplicated upon creation. The difference between a polygon and a polyline is that a polygon is a closed segment.
Creates a polyline element.
Creates a semi-transform label at the given position.
Warning
DEPRECATED (as of MineSight® v8.00) Use create_label() instead. This funtion will still work so old scripts will continue to run.
Creates a transform label at the given at the position.
This is a string representing the text you wish to display. For multi-line text use the n within the string. For example,
multiLine = "Line1\nLine2"
Warning
DEPRECATED (as of MineSight® v8.00) Use create_label() instead. This funtion will still work so old scripts will continue to run.
Creates a shell (surface or solid) defined by the point list and face list. Point list and face list is as defined in grail.ag.
Elements that are text.
Warning
DEPRECATED (as of MineSight® v3.50-04). Prefer to use the exact 'Label' type instead (i.e. SemiTransformLabelType, also known as a Forward Label).