Model.offset_surfaces_and_modify#

Model.offset_surfaces_and_modify(collection, surf_collection, line_collection, offset_type, offset)#

Offsets selected surfaces or solids normally to their surface by the distance specified by you. It has two main modes, disjoint offset and continuous offset, and several modifications.

With the disjoint offset only the surfaces selected by you will be offset. This mode cannot be applied to the surfaces that belong to a solid, if the selection is made “by surfaces” (entity type in collection is not solid), because this could disrupt the solid.

With the continuous offset the surfaces adjacent to the surfaces selected by you also will be modified, to keep continuity of the created model. The modification of the adjacent surfaces will be such that their edges that are shared with the selected surfaces will be moved together with the selected surfaces, while their edges that do not touch the selected surfaces will be locked (stay where they were).

Both disjoint and continuous modes have a modification, remove degenerations. A degeneration is a surface (or several adjacent surfaces) that will self intersect after the offset. (e.g., this will occur if a cylinder or a sphere is offset inside by a distance that is bigger than its radius.) If the ‘remove degenerations’ modification is on, the offset tool will try to clean out the self-intersections automatically. It is recommended to have this mode “on” only if the degenerations are really happening and there is a need to remove them, because having this mode “on” all the time increasing the time of the function execution (to analyze for the degenerations) and increases the risk of a failure.

The continuous offset can be modified by the user-selected lines, separators. If you select a separator line between the selected and not the offset surfaces, the non-selected surface will not be modified (pulled) to keep the result continuous. Instead, a new surface will be inserted between the separator line and the new position of the offsetted edge, to create the result continuity.

If you select the separators inconsistently, it can dramatically break the result. Therefore, an automatic completion of the separator lines is possible, by selecting the “auto-complete separators” modification. If this mode is selected, additional separators will be added automatically to get a reasonable result (or, at least, to try to get the reasonable result).

Note

The additional separators might be added not the way you would want them to go. This is why, if the “auto-complete” modification is used, a review of the actually used separators is recommended.

Parameters:
  • collection (Collection) – The collection containing the entities for the offset. Valid entities are surfaces, splines and solids.

  • surf_collection (Collection) – Reserved for future development. Must be set an empty colleciton.

  • line_collection (Collection) – The collection containing the line entities used as seperators.

  • offset_type (int) –

    Flag to specify the offset mode and modifications:

    -13 - Continuous offset. Remove degenerations. Auto-complete separators. Update eccentricity.

    -11 - Continuous offset. Do not remove degenerations. Auto-complete separators. Update eccentricity.

    -4 - Do not offset, only display how the separators will be auto-completed, to review.

    -3 - Continuous offset. Remove degenerations. Auto-complete separators. Do not update eccentricity.

    -1 - Continuous offset. Do not remove degenerations. Auto-complete separators. Do not update eccentricity.

    0 - Disjoint offset. Do not remove degenerations. Do not update eccentricity.

    1 - Continuous offset. Do not remove degenerations. Do not auto-complete separators. Do not update eccentricity.

    2 - Disjoint offset. Remove degenerations. Do not update eccentricity.

    3 - Continuous offset. Remove degenerations. Do not update eccentricity.

    10 - Disjoint offset. Do not remove degenerations. Update eccentricity.

    11 - Continuous offset. Do not remove degenerations. Do not auto-complete separators. Update eccentricity.

    12 - Disjoint offset. Remove degenerations. Update eccentricity.

    13 - Continuous offset. Remove degenerations. Do not auto-complete separators. Update eccentricity.

  • offset (double) – The value of the offset (offset distance with a sign). The offset will occur in the direction of the surfaces normals, if offset > 0, and in the opposite to the normals direction otherwise.

Example#

Offset by -0.5 surface ID 105 using continuous offset with removal of degenerated surfaces, separator line ID 2471 and auto-completion of the separators#
import hm
import hm.entities as ent

model = hm.Model()

model.offset_surfaces_and_modify(
    collection=hm.Collection(model, ent.Surface, [105]),
    surf_collection=hm.Collection(model, ent.Surface, populate=False),
    line_collection=hm.Collection(model, ent.Line, [2471]),
    offset_type=-3,
    offset=-0.5,
)