### Python Remote Debugging Setup with debugpy Source: https://help.maptek.com/mapteksdk/1.9/topics/key-concepts/how-to-run-python-scripts This snippet demonstrates how to initialize the debugpy library in a Python script to enable remote debugging. It listens on a specified port and waits for a client to attach before proceeding. Ensure debugpy is installed (`pip install debugpy`). ```python import debugpy # Unless a host and port are specified, host defaults to 127.0.0.1 debugpy.listen(5678) print("Waiting for debugger attach") debugpy.wait_for_client() debugpy.breakpoint() print('break on this line') ``` -------------------------------- ### Check Box Parameter Example Source: https://help.maptek.com/workflows/2021.4/Content/Workflows/Workflows/Running_Workflows/Registering_Executables_and_Scripts_TocPath=Appendices%7CRunning+Workflows%7C_____3 Provides an example of a 'Check' parameter, which creates a standard checkbox. It can have an associated 'Pattern' that is applied when the checkbox is selected. ```xml ``` -------------------------------- ### Pick an Edge Primitive using mapteksdk Source: https://help.maptek.com/mapteksdk/1.9/api-reference/mapteksdk.geologycore.operations Prompts the user to select an edge primitive and then generates a report detailing the start and end points of the selected edge. This example utilizes 'primitive_pick' and 'write_report' from 'mapteksdk.operations' and the 'Project' class from 'mapteksdk.project'. ```python from mapteksdk.operations import ( primitive_pick, SelectablePrimitiveType, write_report ) from mapteksdk.project import Project project = Project() primitive = primitive_pick(SelectablePrimitiveType.EDGE) with project.read(primitive.path) as read_object: edge = read_object.edges[primitive.index] start = read_object.points[edge[0]] end = read_object.points[edge[1]] write_report("Selected Edge", f"{start} to {end}") ``` -------------------------------- ### Example: Set Orientation of a New Block Model (Python) Source: https://help.maptek.com/mapteksdk/1.9/api-reference/mapteksdk.data.primitives.block_properties Demonstrates how to create a new DenseBlockModel and set its orientation using dip, plunge, and bearing angles converted from degrees to radians. This example utilizes the `math.radians` function for conversion and the `Project` and `DenseBlockModel` classes from the Maptek SDK. ```python >>> import math >>> from mapteksdk.project import Project >>> from mapteksdk.data import DenseBlockModel >>> project = Project() >>> with project.new("blockmodels/model_1", DenseBlockModel( ... x_res=1, y_res=1, z_res=1, ... x_count=3, y_count=3, z_count=3)) as new_model: >>> new_model.set_orientation(math.radians(45), \ ... math.radians(30), \ ... math.radians(-50)) ``` -------------------------------- ### Two-Point Raster Registration Example with Maptek Python SDK Source: https://help.maptek.com/mapteksdk/1.9/topics/object-types/rasters This Python code snippet demonstrates how to use the RasterRegistrationTwoPoint class from the Maptek SDK. It initializes a project, defines points and facets for a cube, and sets up parameters for raster registration. This example is foundational for applying the two-point registration algorithm. ```python from mapteksdk.project import Project from mapteksdk.data import Surface, Raster, RasterRegistrationTwoPoint from mapteksdk.pointstudio.operations import open_new_view project = Project() points = [[-1, -1, -1], [1, -1, -1], [1, 1, -1], [-1, 1, -1], [-1, -1, 1], [1, -1, 1], [1, 1, 1], [-1, 1, 1]] facets = [[0, 1, 2], [2, 0, 3], [4, 5, 6], [6, 4, 7], [0, 1, 5], [5, 4, 0], [1, 2, 5], [5, 6, 2], ``` -------------------------------- ### Install Maptek Python SDK using pip Source: https://help.maptek.com/mapteksdk/1.9/topics/getting-started This command installs the Maptek Python SDK into your Python environment using pip. Ensure you have a compatible Python interpreter installed. ```bash pip install mapteksdk ``` -------------------------------- ### Command Line Argument Examples for Python Scripts Source: https://help.maptek.com/mapteksdk/1.9/api-reference/mapteksdk.workflows.parser Demonstrates how to pass various data types (string, boolean, integer, float, datetime, list) as arguments to Python scripts used in Maptek Workflows via the command line. It shows the general format and specific examples for different data types and connector names. ```bash >>> py script.py --name="Tim the enchanter" >>> py script.py -n="King Arthur" >>> py script.py --pre-sorted >>> py script.py >>> py script.py --count=42 >>> py script.py --tolerance=3.14159 >>> py script.py --time="2020-07-10T12:54:07" >>> py script.py origin="1, 1, 1" ``` -------------------------------- ### Example: Set and Get Object Attribute Source: https://help.maptek.com/mapteksdk/1.9/api-reference/mapteksdk.data.points This example demonstrates how to set an integer attribute named 'count' on an object using `set_attribute` and then retrieve its value using `get_attribute`. It highlights the usage of `ctypes` for specifying data types. ```python Examples Create an object attribute on an object at “target” and then read its value. ``` >>> import ctypes >>> from mapteksdk.project import Project >>> project = Project() >>> with project.edit("target") as edit_object: ... edit_object.set_attribute("count", ctypes.c_int16, 0) ... with project.read("target") as read_object: ... print(read_object.get_attribute("count")) 0 ``` ``` -------------------------------- ### Basic Maptek SDK Script: Hello World Source: https://help.maptek.com/mapteksdk/1.9/topics/getting-started A simple Python script demonstrating how to connect to a Maptek application and display a message using the Maptek SDK. It utilizes the Project context manager and the show_message operation. ```python from mapteksdk.project import Project from mapteksdk.operations import show_message with Project() as project: show_message("Message", "Hello, world!") ``` -------------------------------- ### Combo Box with Options Example Source: https://help.maptek.com/workflows/2021.4/Content/Workflows/Workflows/Running_Workflows/Registering_Executables_and_Scripts_TocPath=Appendices%7CRunning+Workflows%7C_____3 Illustrates a 'Combo' parameter, creating a dropdown list with predefined options. Each 'Option' has a 'Label' and a 'Pattern' that is used as the parameter's value when selected. ```xml ``` -------------------------------- ### Example: Copy Block Model Orientation (Python) Source: https://help.maptek.com/mapteksdk/1.9/api-reference/mapteksdk.data.primitives.block_properties Shows how to copy the orientation from one block model (`model_1`) to another (`model_2`) using the `set_orientation` method and tuple unpacking. This requires both models to be open for editing. ```python >>> from mapteksdk.project import Project >>> from mapteksdk.data import DenseBlockModel >>> project = Project() >>> with project.edit("blockmodels/model_1") as model_1: ... with project.edit("blockmodels/model_2") as model_2: ... model_2.set_orientation(*model_1.orientation) ``` -------------------------------- ### Get From Depth Field Source: https://help.maptek.com/mapteksdk/1.9/api-reference/mapteksdk.geologycore.tables Accesses the 'from_depth' field, which defines the start of a depth interval. This field is crucial for defining interval ranges, often used in conjunction with 'to_depth'. It can raise FieldNotFoundError or TooManyFieldsError. ```python table._from_depth ``` -------------------------------- ### Interactive Point Cloud Filtering Setup (Python) Source: https://help.maptek.com/mapteksdk/1.9/topics/object-types/scans This script allows users to interactively set parameters for point cloud filtering. It prompts for a filter ratio, number of neighbors, filtering style (replace or and), and whether to combine objects for filtering. Default values are provided for each parameter. The script then connects to a project, retrieves selected objects, and applies the filtering logic. ```python if __name__ == "__main__": filter_ratio = input("Enter the threshold level based on the standard deviation of the average distances" \ + "across the point cloud.\nThe lower this number the more aggressive the filter will be." + "\n\tDefault = 10.0:\n") filter_ratio = float(filter_ratio) if filter_ratio.replace(".","" ).isnumeric() else 10 filter_neighbours = input("Enter number of point neighbours taken into account in order to " \ +"calculate the average distance for a given point." + "\n\tDefault = 10:\n") filter_neighbours = int(filter_neighbours) if filter_neighbours.isnumeric() else 10 filter_style = input("Use [REPLACE] style or [AND] style filtering?" \ + "\n\tType: 'replace' (default) or 'and'\n") filter_combine = input("Treat all objects as one object for filtering?" \ + "\n\tType: 'True' (default) or 'False' for filter one-by-one\n") filter_combine = False if filter_combine.lower() == "false" else True project = Project() # Connect to default project selection = project.get_selected() # Get the active object selection # Use contextlib ExitStack to work with several 'with' contexts simultaneously with ExitStack() as stack: scans = [stack.enter_context(project.edit(item)) for item in selection] if filter_combine: # Run on all objects as as single entity try: # REPLACE filter (show all, then apply filter) -> filter_style != 'and' # AND filter (don't re-show anything already hidden) -> filter_style == 'and' results = isolated_filter_combined(scans=scans, nb_neighbors=filter_neighbours, std_ratio=filter_ratio, include_hidden=(filter_style.lower()!="and")) for i in range(len(results)): # You can't modify 'scan' points or delete them directly. # Instead we mask/make invisible points to be filtered. scans[i].point_visibility = results[i] except Exception as ex: print(ex) else: # Run on each object as individual entities. for i in range(len(scans)): try: scans[i].point_visibility = isolated_filter_combined(scans=[scans[i]], nb_neighbors=filter_neighbours, std_ratio=filter_ratio, include_hidden=(filter_style.lower()!="and")) except Exception as ex: print(ex) ``` -------------------------------- ### Select Subblocks within a Range of Primary Blocks using grid_index (Python) Source: https://help.maptek.com/mapteksdk/1.9/api-reference/mapteksdk.data.primitives.block_properties Illustrates how to select subblocks within a range of primary blocks by providing start and end coordinates to the `grid_index` function. This example sets the visibility of selected subblocks. ```python >>> from mapteksdk.project import Project >>> project = Project() >>> with project.edit("blockmodels/target") as edit_model: ... index = edit_model.grid_index([0, 2, 2], [4, 5, 6]) ... edit_model.block_visibility[index] = False ``` -------------------------------- ### Create Surface and Save View to Image Source: https://help.maptek.com/mapteksdk/1.9/api-reference/mapteksdk.view.view Example demonstrating how to create a new surface with specified points and facets, then create a view window, add the surface to it, and save the view as a PNG image. It also shows project unloading. ```python from mapteksdk.project import Project from mapteksdk.data import Surface from mapteksdk.view import ViewWindow project = Project() with project.new("/surface/triangle", Surface) as surface: surface.points = [(0.0, 0.0, 0.0), (5.0, 0.0, 0.0), (5.0, 5.0, 0.0)] surface.facets = [(0, 1, 2)] with ViewWindow(width=1024, height=1024) as view: view.controller.add_object(surface.id) view.save_to_image("triangle.png") project.unload_project() ``` -------------------------------- ### Accessing Point Coordinates in Python Source: https://help.maptek.com/mapteksdk/1.9/api-reference/mapteksdk.data.facets Provides examples for accessing the 3D coordinates of points within an object. It demonstrates how to get the coordinates of a specific point by its index and how to extract the x, y, and z components individually. ```python # To get the ith point: point_i = point_set.points[i] # Similarly, to get the x, y and z coordinates of the ith point: x, y, z = point_set.points[i] ``` -------------------------------- ### Interactive Point Filtering Setup (Python) Source: https://help.maptek.com/mapteksdk/1.9/topics/object-types/scans This script segment handles user input for configuring point filtering parameters. It prompts the user for filter size, filtering style ('replace' or 'and'), whether to combine objects for filtering, and whether to keep the lowest or highest point. It then initializes a Project object and retrieves selected items. ```python if __name__ == "__main__": filter_size = input("Enter filter size (m) - default = 1.0:\n") # 1m cells filter_size = float(filter_size) if filter_size.replace(".","").isnumeric() else 1.0 filter_style = input("Use [REPLACE] style or [AND] style filtering?" \ + "\n\tType: 'replace' (default) or 'and'\n") filter_combine = input("Treat all objects as one object for filtering?" \ + "\n\tType: 'True' (default) or 'False' for filter one-by-one\n") filter_combine = False if filter_combine.lower() == "false" else True filter_lowest = input("Keep Lowest ('True'/Default) or Highest('False')?\n") filter_lowest = False if filter_lowest.lower() == "false" else True project = Project() # Connect to default project selection = project.get_selected() # Use contextlib ExitStack to work with several 'with' contexts simultaneously with ExitStack() as stack: scans = [stack.enter_context(project.edit(item)) for item in selection] if filter_combine: # Run on all objects as as single entity try: # REPLACE filter (show all, then apply filter) -> filter_style != 'and' # AND filter (don't re-show anything already hidden) -> filter_style == 'and' ``` -------------------------------- ### Get JSON Input Dimensionality in Python Source: https://help.maptek.com/mapteksdk/1.9/api-reference/mapteksdk.workflows.connector_types This Python class method, `_json_dimensionality`, returns the dimensionality of the input expected in JSON format. The dimensionality can be either 'Single' or 'List', with 'Single' being the default. This information is used to guide how JSON data is processed for inputs. ```python _classmethod _json_dimensionality() The dimensionality of the input in JSON. This must either be ‘Single’ or ‘List’. It is ‘Single’ by default. Return type: str ``` -------------------------------- ### Create and Populate Scan with Angles and Colors (Python) Source: https://help.maptek.com/mapteksdk/1.9/api-reference/mapteksdk.data.scans Demonstrates how to create a new scan, set its dimensions, validity, vertical and horizontal angles, point ranges, and populate point colors. It then prints the resulting point color data. ```python with project.new("scans/valid_angles", Scan( dimensions=dimensions, point_validity=validity)) as scan: scan.vertical_angles_2d.T[:] = np.linspace( start=-np.pi / 4, stop=np.pi / 4, num=dimensions[0]) scan.horizontal_angles_2d = np.linspace( start=-np.pi / 4, stop=np.pi / 4, num=dimensions[1]) scan.point_ranges = 100 point_colours_2d = np.ma.masked_all( (scan.major_dimension_count, scan.minor_dimension_count, 4), np.uint8 ) point_colours_2d[scan.cell_point_validity_2d] = scan.point_colours print(point_colours_2d) ``` -------------------------------- ### Export Point Set to LAS File Source: https://help.maptek.com/mapteksdk/1.9/topics/object-types/point-sets Provides a basic structure for exporting point data from one or more Maptek SDK objects into a LAS file. This example requires the laspy library to be installed. The code snippet sets up the file path for the export. ```python import os import numpy as np import laspy from mapteksdk.project import Project project = Project() # Connect to default project save_as = os.path.abspath("export_example.las") ``` -------------------------------- ### Create Irregular Grid Surface using Python Source: https://help.maptek.com/mapteksdk/1.9/topics/object-types/grid-surfaces This example shows how to create an irregular grid surface where cells are unevenly spaced. It utilizes the `mapteksdk.data.GridSurface` class and `numpy` for point data. The `x_step`, `y_step`, and `start` parameters are omitted for irregular grids. ```python from mapteksdk.project import Project from mapteksdk.data import GridSurface import numpy project = Project() points = numpy.array([ (0, 4.9, 4.9), (1, 5.1, 4.4), (1.9, 5.1, 3.4), (3, 5, 3), (0.1, 4.1, 3.9), (0.9, 4.1, 4.1), (2.1, 4, 2.9), (3.1, 4.1, 2.5), (0.1, 3.1, 3.4), (1, 3.1, 3.4), (2, 3, 2.4), (3.1, 3, 2.1), (0.1, 1.9, 2.5), (0.9, 2, 2.6), (2, 2.1, 1.9), (3.1, 1.9, 1.4), (-0.1, 1, 1.9), (0.9, 0.9, 1.5), (2, 1.1, 1), (3.1, 1.1, 0.9) ]) with project.new("surfaces/irregular_grid", GridSurface( major_dimension_count=5, minor_dimension_count=4)) as irregular_grid_surface: irregular_grid_surface.points = points ``` -------------------------------- ### Extract File Path Components Source: https://help.maptek.com/workflows/2021.4/Content/Workflows/Workflow_Editor/Appendices/Appendices-C-Attributes Shows modifiers for extracting specific parts of a file path. 't' gets the tail (filename), 'e' gets the extension, 'n' gets the filename without extension, 'r' gets the root path, and 'h' gets the path head. ```text $(myPath:t) ``` ```text $(myPath:e) ``` ```text $(myPath:n) ``` ```text $(myPath:r) ``` ```text $(myPath:h) ``` -------------------------------- ### GridSurface Example Source: https://help.maptek.com/mapteksdk/1.9/api-reference/mapteksdk.data.scans Demonstrates the creation and inspection of a GridSurface object, including accessing its cells and the points that define them. ```APIDOC ## GridSurface Example ### Description This example creates a GridSurface object with 3 rows and 3 columns of points and prints the cells. Then it prints the four points which define the first cell (index 0). ### Method ```python from mapteksdk.project import Project from mapteksdk.data import GridSurface project = Project() with project.new("surfaces/small_square", GridSurface( major_dimension_count=3, minor_dimension_count=3, x_step=0.1, y_step=0.1)) as small_square: print("Cells:") print(small_square.cells) print("The points which define the first cell are:") for index in small_square.cells[0]: print(f"Point {index}:", small_square.points[index]) ``` ### Response Example ``` Cells: [[0 3 4 1] [1 4 5 2] [3 6 7 4] [4 7 8 5]] The points which define the first cell are: Point 0: [0. 0. 0.] Point 3: [0.3 0. 0. ] Point 4: [0. 0.1 0. ] Point 1: [0.1 0. 0. ] ``` ``` -------------------------------- ### BrowserFile Parameter Example Source: https://help.maptek.com/workflows/2021.4/Content/Workflows/Workflows/Running_Workflows/Registering_Executables_and_Scripts_TocPath=Appendices%7CRunning+Workflows%7C_____3 Defines a 'BrowserFile' parameter, which creates a combo box with a file query result and a browse button. It requires a 'Descriptor' for the file type and optionally accepts a 'Context' for scoping the query. ```xml ``` -------------------------------- ### ListFile Parameter Example Source: https://help.maptek.com/workflows/2021.4/Content/Workflows/Workflows/Running_Workflows/Registering_Executables_and_Scripts_TocPath=Appendices%7CRunning+Workflows%7C_____3 Illustrates a 'ListFile' parameter, similar to 'BrowserFile' but without a browse button. It is typically used for file contents like layers or block variables and requires a 'Descriptor' and optionally a 'Context'. ```xml ``` -------------------------------- ### Using Wildcards in Selection Files (Python) Source: https://help.maptek.com/mapteksdk/1.9/topics/object-types/selection-files Demonstrates how to use wildcard characters ('?', '*') in selection file patterns to match multiple names. The pattern 'm?n?*g' is used to match strings starting with 'm', followed by any character, then 'n', then one or more characters, and ending with 'g'. This example shows which strings are included based on the wildcard pattern. ```python from mapteksdk.project import Project from mapteksdk.data import SelectionFile def main(project: Project): with project.new("selection files/examples/Many wild cards", SelectionFile) as selection_file: selection_file.add("m?n?*g") print("mining -", "mining" in selection_file) print("manning -", "manning" in selection_file) print("managing -", "managing" in selection_file) print("mounting -", "mounting" in selection_file) if __name__ == "__main__": with Project() as main_project: main(main_project) ``` -------------------------------- ### Generate Boolean Index for Block Properties by Grid Coordinates Source: https://help.maptek.com/mapteksdk/1.9/api-reference/mapteksdk.data.primitives.block_properties Generates a boolean index for accessing block properties by row, column, and slice. The index includes subblocks between a start (inclusive) and stop (exclusive) range, or all subblocks within the start if stop is not specified. It handles integer or array-like inputs for start and end coordinates. ```python from mapteksdk.project import Project project = Project() with project.edit("blockmodels/target") as edit_model: index = edit_model.grid_index([0, 0, 0]) edit_model.block_selection[index] = True ``` ```python from mapteksdk.project import Project project = Project() with project.edit("blockmodels/target") as edit_model: index = edit_model.grid_index([0, 2, 2], [4, 5, 6]) edit_model.block_visibility[index] = False ``` -------------------------------- ### Attribute Management Source: https://help.maptek.com/mapteksdk/1.9/api-reference/mapteksdk.geologycore.drillholes Manage object attributes, including deleting all attributes, deleting a specific attribute, getting attribute values, and getting attribute types. ```APIDOC ## Attribute Management ### Description Manage object attributes, including deleting all attributes, deleting a specific attribute, getting attribute values, and getting attribute types. ### Methods #### delete_all_attributes() ##### Description Delete all object attributes attached to an object. This only deletes object attributes and has no effect on PrimitiveAttributes. ##### Raises - **RuntimeError** – If all attributes cannot be deleted. #### delete_attribute(_attribute_) ##### Description Deletes a single object-level attribute. Deleting a non-existent object attribute will not raise an error. ##### Parameters - **attribute** (str) - Name of attribute to delete. ##### Returns - True if the object attribute existed and was deleted; False if the object attribute did not exist. ##### Raises - **RuntimeError** – If the attribute cannot be deleted. #### get_attribute(_name_) ##### Description Returns the value for the attribute with the specified name. ##### Parameters - **name** (str) - The name of the object attribute to get the value for. ##### Returns - The value of the object attribute name. For dtype = datetime.datetime this is an integer representing the number of milliseconds since 1st Jan 1970. For dtype = datetime.date this is a tuple of the form: (year, month, day). ##### Raises - **KeyError** – If there is no object attribute called name. ##### Warning In the future this function may be changed to return datetime.datetime and datetime.date objects instead of the current representation for object attributes of type datetime.datetime or datetime.date. #### get_attribute_type(_name_) ##### Description Returns the type of the attribute with the specified name. ##### Parameters - **name** (str) - Name of the attribute whose type should be returned. ##### Returns - The type of the object attribute name. ##### Raises - **KeyError** – If there is no object attribute called name. ``` -------------------------------- ### Creating a Cube with Script Arguments in Python Source: https://help.maptek.com/mapteksdk/1.9/topics/key-concepts/how-to-run-python-scripts This Python script demonstrates creating a cube using parsed arguments for path, centroid, and size. It utilizes a `Project` context manager and a `create_cube` function. Optionally, it opens a new view and sets an output selection based on the cube ID. ```python if __name__ == "__main__": parser = create_parser() parser.parse_arguments() with Project() as project: cube_id = create_cube( project, parser["path"], parser["centroid"], parser["size"] ) if parser["view"]: open_new_view(cube_id) parser.set_output("selection", cube_id) ``` -------------------------------- ### Install maptekomf-maptek Package Source: https://help.maptek.com/mapteksdk/1.9/topics/technical-notes/open-mining-format Installs the necessary Python package for OMF data exchange using pip within the Maptek Workbench Python shell. ```bash pip install maptekomf-maptek ``` -------------------------------- ### Create Scan with Grid to Point Index (Python) Source: https://help.maptek.com/mapteksdk/1.9/topics/object-types/scans Demonstrates creating a scan and manipulating point colors based on the grid to point index. It involves filtering out invalid point indices before applying color changes. ```python from mapteksdk.project import Project from mapteksdk.data import Scan, Text2D import numpy as np if __name__ == "__main__": point_validity = [ False, True, True, False, True, True, True, False, True, True, False, False, True, True, True, True, False, False, True, True ] with Project() as project: path = "scans/grid_to_point_index" with project.new(path, Scan( dimensions=(5, 4), point_validity=point_validity ), overwrite=True) as scan: scan.points = [ [1, 0, 0], [2, 0, 0], [0, 1, 0], [1, 1, 0], [2, 1, 0], [0, 2, 0], [1, 2, 0], [0, 3, 0], [1, 3, 0], [2, 3, 0], [3, 3, 0], [2, 4, 0], [3, 4, 0] ] # scan.grid_to_point_index[:, 1] is an array of the indices of points # in the column with index 1. column_one = scan.grid_to_point_index[:, 1] # Once again filter out the invalid points. column_one = column_one[column_one != np.ma.masked] # Set all points in the column with index one to yellow. scan.point_colours[column_one] = [255, 255, 0, 255] # scan.grid_to_point_index[2] is an array of the indices of points # in the row with index 2. row_two = scan.grid_to_point_index[2] # Filter out any element in row_two that is less than zero, because # it indicates an invalid point. row_two = row_two[row_two != np.ma.masked] # Set all points in the row with index two to cyan. scan.point_colours[row_two] = [0, 255, 255, 255] for row in range(scan.row_count): for col in range(scan.column_count): if scan.grid_to_point_index.mask[row, col] == True: print(f"Skipping: {row} {col} because it is invalid.") continue point_index = scan.grid_to_point_index[row, col] with project.new(path + f"_index_labels/{row}{col}", Text2D, overwrite=True) as label: label.location = scan.points[point_index] label.location[2] += 1 label.text = str(point_index) ``` -------------------------------- ### Panel Button Parameter Example Source: https://help.maptek.com/workflows/2021.4/Content/Workflows/Workflows/Running_Workflows/Registering_Executables_and_Scripts_TocPath=Appendices%7CRunning+Workflows%7C_____3 Shows a 'Panel' parameter, which creates a button that opens a sub-panel. The 'Pattern' argument specifies the panel to invoke, and 'Context' can set a default scope for controls within that sub-panel. ```xml ``` -------------------------------- ### Example: Inverting Raster Colors Source: https://help.maptek.com/mapteksdk/1.9/api-reference/mapteksdk.data.base.topology Demonstrates how to iterate through rasters associated with a topology object and invert their pixel colors. This example requires reading an object and then editing its associated rasters. ```python >>> from mapteksdk.project import Project >>> project = Project() >>> with project.read("target") as read_object: ... for raster in read_object.rasters.values(): ... with project.edit(raster) as edit_raster: ... edit_raster.pixels[:, :3] = 255 - edit_raster.pixels[:, :3] ``` -------------------------------- ### Pick an Object and Report its Type (Python) Source: https://help.maptek.com/mapteksdk/1.9/api-reference/mapteksdk.operations This snippet demonstrates how to prompt the user to select an object in the running application and then report its type and path. It requires importing `object_pick` and `write_report` from `mapteksdk.operations` and `Project` from `mapteksdk.project`. ```python >>> from mapteksdk.operations import object_pick, write_report >>> from mapteksdk.project import Project >>> project = Project() >>> oid = object_pick(label="Query object type", ... support_label="Select an object to query its type") >>> write_report("Query type", f"{oid.path} is a {oid.type_name}") ``` -------------------------------- ### Index Block Properties Source: https://help.maptek.com/mapteksdk/1.9/api-reference/mapteksdk.data.blocks Generates a boolean index for accessing block properties by row, slice, and column. It includes subblocks between a start (inclusive) and stop (exclusive) range, or within the start block if stop is not specified. ```python grid_index(_start_ , _stop =None_) ``` -------------------------------- ### Create and Populate Drillhole Database with Geology - Python Source: https://help.maptek.com/mapteksdk/1.9/topics/object-types/drillholes Creates a drillhole database, adds a 'Geology' table with a 'Rock type' field, and then adds a single drillhole with collar information and geological intervals. This demonstrates populating the database with specific geological data. ```python from mapteksdk.project import Project from mapteksdk.geologycore import ( DrillholeDatabase, DrillholeTableType, DrillholeFieldType) if __name__ == "__main__": with Project() as project: with project.new("drillholes/example_basic_database", DrillholeDatabase ) as database: database.add_table("Geology", DrillholeTableType.GEOLOGY) geology_table = database.geology_table geology_table.add_field( "Rock type", str, "The type of rock in the interval", field_type=DrillholeFieldType.ROCK_TYPE ) drillhole_id = database.new_drillhole("example-1") with project.edit(drillhole_id) as drillhole: drillhole.raw_collar = (12.0, -11.4) geology_table = drillhole.geology_table geology_table.add_rows(5) geology_table.from_depth.values = [0.0, 1.1, 2.25, 3.22, 4.18] geology_table.to_depth.values[:-1] = geology_table.from_depth.values[1:] geology_table.to_depth.values[-1] = 5.22 geology_table.rock_type.values = [ "DIRT", "ROCK", "ORE", "ROCK", "ORE" ] ``` -------------------------------- ### DoubleConnectorType Example (Python) Source: https://help.maptek.com/mapteksdk/1.9/api-reference/mapteksdk.workflows.connector_types Illustrates the usage of DoubleConnectorType for defining input and output connectors in a Maptek workflow. This example sets an output connector's value by dividing an input connector's value by two. ```python from mapteksdk.workflows import ( WorkflowArgumentParser, DoubleConnectorType ) parser = WorkflowArgumentParser() parser.declare_input_connector("x", DoubleConnectorType) parser.declare_output_connector("x_over_2", DoubleConnectorType) parser.parse_arguments() ``` -------------------------------- ### Initialize Project and Generate Drillhole Source: https://help.maptek.com/mapteksdk/1.9/topics/object-types/drillholes Initializes a new project, generates a drillhole database, and then creates a specific drillhole within that database. It sets the distance and angle units for the database and defines the collar point for the drillhole. This function is intended to be called within a 'Project()' context. ```python if __name__ == "__main__": with Project() as project: database_id = generate_database( project, "drillholes/candy_cane_db", DistanceUnit.METRE, AngleUnit.DEGREES) collar_point = [0, 0, 0] drillhole_id = generate_drillhole( project, database_id, "Candy_cane", collar_point) open_new_view(database_id) ``` -------------------------------- ### Example: Create and Read Object Attribute Source: https://help.maptek.com/mapteksdk/1.9/api-reference/mapteksdk.data.facets Illustrates how to create a new object attribute on a target object and subsequently read its value using the set_attribute function. This example assumes the use of the mapteksdk.project.Project class. ```python import ctypes from mapteksdk.project import Project project = Project() with project.edit("target") as edit_object: # Code to set and read attribute would follow here ``` -------------------------------- ### Pick a Primitive (Point) and Report Coordinates (Python) Source: https://help.maptek.com/mapteksdk/1.9/api-reference/mapteksdk.operations This example demonstrates how to use `primitive_pick` to request the user to select a point primitive. It then reports the coordinates of the selected point. This requires importing `primitive_pick`, `SelectablePrimitiveType`, and `write_report`. ```python >>> from mapteksdk.operations import ( ... primitive_pick, ... SelectablePrimitiveType, ... write_report) >>> from mapteksdk.project import Project >>> project = Project() >>> primitive = primitive_pick(SelectablePrimitiveType.POINT) >>> with project.read(primitive.path) as read_object: ... write_report("Selected point", str(read_object.points[primitive.index])) ``` -------------------------------- ### IntegerConnectorType Example (Python) Source: https://help.maptek.com/mapteksdk/1.9/api-reference/mapteksdk.workflows.connector_types Demonstrates how to declare and use an IntegerConnectorType for input and output connectors in a Maptek workflow. This example shows setting an output connector's value based on an input connector, incrementing the input value by one. ```python from mapteksdk.workflows import ( WorkflowArgumentParser, IntegerConnectorType ) parser = WorkflowArgumentParser() parser.declare_input_connector("count", IntegerConnectorType) parser.declare_output_connector("new_count", IntegerConnectorType) parser.parse_arguments() parser.set_output("new_count", parser["count"] += 1) ``` -------------------------------- ### Combining Multiple Point Arrays using Numpy (Python) Source: https://help.maptek.com/mapteksdk/1.9/api-reference/mapteksdk.data.edges Demonstrates how to combine more than two numpy arrays of points using `numpy.vstack`. This example assumes the previous two examples have been run and adds a third set of points to the combined array. ```python >>> from mapteksdk.project import Project >>> from mapteksdk.data import PointSet >>> import numpy as np >>> if __name__ == "__main__": ... extra_points = [[-2, -2, 3], [2, -2, 3], [-2, 2, 3], [2, 2, 3]] ``` -------------------------------- ### Text Parameter Example Source: https://help.maptek.com/workflows/2021.4/Content/Workflows/Workflows/Running_Workflows/Registering_Executables_and_Scripts_TocPath=Appendices%7CRunning+Workflows%7C_____3 Shows a 'Text' parameter, which renders as a simple text input box. It can have a 'Pattern' for input validation and is often marked as 'Mandatory'. ```xml ``` -------------------------------- ### Manage Scan Point Validity and Properties (Python) Source: https://help.maptek.com/mapteksdk/1.9/api-reference/mapteksdk.data.scans Demonstrates how to initialize a Scan object with specific point validity, set associated properties like ranges and colors, and access point counts. It highlights how invalid points are handled and do not require storage for their properties. ```python >>> import numpy as np >>> from mapteksdk.project import Project >>> from mapteksdk.data import Scan >>> project = Project() >>> dimensions = (5, 5) >>> # Each line represents one row of points in the scan. >>> # Note that rows containing invalid points have fewer values. >>> ranges = [10.7, 10.6, 10.8, ... 10.3, 10.8, 10.6, ... 9.2, 10.9, 10.7, 10.7, 10.9, ... 9.5, 11.2, 10.6, 10.6, ... 9.1, 9.4, 9.2] >>> horizontal_angles = [-20, -10, 0, 10, 20, ... -20, -10, 0, 10, 20, ... -20, -10, 0, 10, 20, ... -20, -10, 0, 10, 20, ... -20, -10, 0, 10, 20,] >>> vertical_angles = [-20, -20, -20, -20, -20, ... -10, -10, -10, -10, -10, ... 0, 0, 0, 0, 0, ... 10, 10, 10, 10, 10, ... 20, 20, 20, 20, 20,] >>> red = [255, 0, 0, 255] >>> green = [0, 255, 0, 255] >>> blue = [0, 0, 255, 255] >>> point_colours = [red, green, blue, ... red, green, blue, ... red, green, blue, red, green, ... red, green, blue, red, ... red, green, blue] >>> point_validity = [False, False, True, True, True, ... False, True, True, True, False, ... True, True, True, True, True, ... True, True, True, True, False, ... True, True, True, False, False] >>> with project.new("scans/example_with_invalid_and_colours", Scan( ... dimensions=dimensions, point_validity=point_validity ... ), overwrite=True) as example_scan: ... # Even though no points have been set, because point_validity was ... # specified in the constructor point_count will return ... # the required number of valid points. ... print(f"Point count: {example_scan.point_count}") ... # The scan contains invalid points, so cell_point_count ... # will be lower than the point count. ... print(f"Cell point count: {example_scan.cell_point_count}") ... example_scan.point_ranges = ranges ... example_scan.horizontal_angles = np.deg2rad(horizontal_angles) ... example_scan.vertical_angles = np.deg2rad(vertical_angles) ... example_scan.origin = [0, 0, 0] ... example_scan.point_colours = point_colours Point count: 18 Cell point count: 25 ``` -------------------------------- ### Field Count Property Source: https://help.maptek.com/mapteksdk/1.9/api-reference/mapteksdk.geologycore.tables Gets the total number of fields in the table. ```APIDOC ## GET /websites/help_maptek/field_count ### Description Returns the total count of fields present in the table. ### Method GET ### Endpoint `table.field_count` ### Response #### Success Response (200) - **int** - The number of fields in the table. ```