Model.surfaceprimitivefrompoints#

Model.surfaceprimitivefrompoints(collection, surf_type, options, tol)#

Takes input nodes or points and uses them as target points to construct a surface of the specified primitive type. Optionally, a tolerance value can be specified to reject a surface that does not fit the input points.

Parameters:
  • collection (Collection) – The collection containing the node or point entities to construct the surface.

  • surf_type (int) –

    Type of primitive surface to create. Valid values are:

    1 - plane

    2 - sphere

    3 - cylinder

    4 - cone

    5 - general quadric surface

    For surf_type=4, if a cylinder can be fit to the input entities, it will be created instead of a cone.

  • options (int) –

    Flags that indicate different modes.

    Bit values are used and the value is calculated as (Bit0 + 2*Bit1). Valid Bit options are:

    Bit0

    Tolerance usage mode. Valid values are:

    0 - Tolerance is not used, best possible surface is found for any input set of points.

    1 - Tolerance specified by tol parameter is used to reject surface that does not fit input points.

    Bit1

    Component mode. Used only when entities in collection is points. Valid values are:

    0 - Surface is created in the current component.

    1 - Surface is created in the most common input points component.

    Show Bit value calculator
    Radio Button Table
    Option Name Value
    Tolerance usage mode (Bit0)
    Component mode (Bit1)
    Calculated argument value: 0

  • tol (double) – Tolerance value used to accept generated surface. Not used if options Bit0 is 0. Negative value can be set to specify that the global value of the geometry cleanup tolerance use hm.setoption(cleanup_tolerance=...).

Examples#

Create a cone surface that fits all displayed points in a best possible way#
import hm
import hm.entities as ent

model = hm.Model()

model.surfaceprimitivefrompoints(
    collection=hm.CollectionByDisplayed(model, ent.Point), surf_type=4, options=0, tol=0.0
)
Try to create sphere that fits the nodes with IDs 1 through 8 with a deviation not larger than 0.02#
import hm
import hm.entities as ent

model = hm.Model()

# Creating a collection that contains the nodes with IDs 1-8
filter_nodes = hm.FilterByEnumeration(ent.Node, list(range(1, 9)))
nodes_collection = hm.Collection(model, filter_nodes)

model.surfaceprimitivefrompoints(
    collection=nodes_collection, surf_type=2, options=1, tol=0.02
)