Model.startnotehistorystate#

Model.startnotehistorystate(name)#

Defines the start of a history state. Must be followed by a call to Model.endnotehistorystate() with the same name value.

This is used to group a set of functions into a single undo/redo operation. All functions that appear within the start/end block must be supported for undo/redo.

Parameters:

name (hwString) – The name of the history state.

Example#

Execute an element remesh operation on two selections of elements , but consider them as a single history operation#
import hm
import hm.entities as ent

model = hm.Model()

model.startnotehistorystate(name="Remesh two element selections")
model.setedgedensitylinkwithaspectratio(aspectratio=0.0)
hm.setoption(element_order=1)
model.setusefeatures(mode=3)

# Creating a collection that contains the elements with IDs 1-100
filter_elements = hm.FilterByEnumeration(ent.Element, list(range(1, 101)))
elements_collection = hm.Collection(model, filter_elements)

model.defaultremeshelems(
    collection=elements_collection,
    elem_size=1,
    elem_type=2,
    elem_type_2=2,
    comp_mode=1,
    size_control=1,
    skew_control=1,
    edge_mesh_type=1,
    min_size=0,
    max_size=0,
    max_deviation=0,
    max_angle=0,
    previous_settings=2,
    vertex_angle=30,
)

# Creating a collection that contains the elements with IDs 101-200
filter_elements2 = hm.FilterByEnumeration(ent.Element, list(range(101, 201)))
elements_collection2 = hm.Collection(model, filter_elements2)

model.defaultremeshelems(
    collection=elements_collection2,
    elem_size=1,
    elem_type=2,
    elem_type_2=2,
    comp_mode=1,
    size_control=1,
    skew_control=1,
    edge_mesh_type=1,
    min_size=0,
    max_size=0,
    max_deviation=0,
    max_angle=0,
    previous_settings=2,
    vertex_angle=30,
)

model.setusefeatures(mode=0)

model.endnotehistorystate(name="Remesh two element selections")