Model.filewriteentities#

Model.filewriteentities(collection, filename, reserved, ce_realizedflag=0)#

Saves a binary file with only the contents of selected modules/parts. This is useful for shattering a large binary file into smaller ones.

There are certain rules and limitations:

  • There can be only one module on the input collection. That module may have multiple children.

  • Only the entities listed below are saved, and all other entities are ignored:

    All components in the module hierarchy.

    All elements in those components.

    All nodes in those components.

    Materials referred by those components.

    Properties referred by those components.

    Materials referred by those properties.

  • Components being exported must not be topologically connected to components in modules not part of the hierarchy being exported.

Parameters:
  • collection (Collection) – The collection containing the entities to export. Only supported for modules.

  • filename (hwString) – The full name and ID of the file to write.

  • reserved (int) – Reserved for future use.

  • ce_realizedflag (int) – Reserved for future use. Must be set to 0.

Example#

Write module with ID 10 and all of its children modules to the file C:/temp/shatter10.hm#
import hm
import hm.entities as ent

model = hm.Model()

model.filewriteentities(
  collection=hm.Collection(model, ent.Part, [1]),
  filename="C:/temp/shatter10.hm",
  reserved=0
)