MaxScript

MAXScript

Flatiron includes a MAXScript interface that allows you to control the plug-in directly from your own scripts, without accessing the utility UI. This is useful for automation, batch processing, and integration into production pipelines.

Some previously available properties have been deprecated to simplify the plug-in. These properties can still be used for backwards compatibility and will not trigger errors, but they may no longer affect the plug-in’s behavior. The angle properties used in earlier versions now affect both ridges and grooves simultaneously.


Properties

The following properties correspond to settings available in the Flatiron user interface and allow you to retrieve or set the values used by Flatiron.

Unwrap Settings

Unwrap Mode

Flatiron.unwrap_mode : Integer

Unwrap mode used by Flatiron:

  • 0 — Standard unwrap mode optimized for organic shapes
  • 1 — Unwrap mode for hard-surface shapes
  • 2 — Pack existing UV charts instead of creating a completely new unwrap
  • 3 — Keep all existing UV data unchanged
  • 4 — Projection unwrap mode based on a viewpoint and direction

Map Channel

Flatiron.map_channel : Integer

Destination map slot. This is where the generated UV maps will be stored.

Source Channel

Flatiron.source_channel : Integer

Defines the map channel from which existing chart and seam data are taken.

Stretch

Flatiron.stretch : Float

The amount of stretching allowed. 0 means no stretching is allowed, 1 means any amount of stretching can be used.

Padding

Flatiron.padding : Float

Distance between charts in the texture.

Width

Flatiron.width : Integer

Texture width of the UV map and the baked map.

Height

Flatiron.height : Integer

Texture height of the UV map and the baked map.

Preview

Flatiron.preview : Boolean

Renders a UV template as a preview of the unwrapped map.

Show Activity

Flatiron.show_activity : Boolean

Enables or disables the activity window shown while the plug-in is working.

Packing Settings

Pack Mode

Flatiron.packmode : Integer

Specifies the packing engine used:

  • 0 — Classic
  • 1 — Efficient
  • 2 — High Quality

Rescale

Flatiron.rescale : Boolean

If True, the individual charts are rescaled depending on the amount of mesh surface they cover. If False, the relative sizes of the UV charts stay as they were before packing.

Pre-Rotate

Flatiron.prerotate : Boolean

Determines whether each chart should be rotated into an optimized base rotation before packing. Pre-rotation is independent of the general rotation setting below.

Rotation

Flatiron.rotation : Integer

Determines the angle steps by which each chart may be rotated to fit better into the UV map. Values 0 to 3 correspond to the buttons in the user interface. Higher values allow finer rotation steps.

Full Rotation

Flatiron.full_rotation : Boolean

When enabled, Flatiron also tests counterparts for each rotation step that are rotated by 180 degrees. This can improve packing quality, but has a noticeable impact on performance.

Seam Settings

Keep Seams

Flatiron.keep_seams : Boolean

If True, the unwrapping process retains existing seams as long as the current constraints allow. If False, existing seams are discarded and Flatiron places new seams automatically.

Use Grooves

Flatiron.use_grooves : Boolean

If True, the mesh is split with seams along sharp grooves that meet the defined threshold.

Groove Angle

Flatiron.groove_angle : Float

Angle threshold used by automatic seam generation when use_grooves is enabled.

Use Ridges

Flatiron.use_ridges : Boolean

If True, the mesh is split with seams along sharp ridges that meet the defined threshold.

Ridge Angle

Flatiron.ridge_angle : Float

Angle threshold used by automatic seam generation when use_ridges is enabled.

Projection Settings

Projection Camera

Flatiron.projection_camera : Object

Object used to determine the view location and direction. This does not need to be an actual 3ds Max camera; any object can be used.

Projection Angle

Flatiron.projection_angle : Float

View angle of the projection camera object.

Projection Tolerance

Flatiron.projection_tolerance : Float

Tolerance angle that determines whether backfacing polygons are included in the projection unwrap.

Projection Orthographic

Flatiron.projection_orthographic : Boolean

When set to True, an orthographic projection is used and the view angle is ignored.

Group and Selection Set Settings

Multi Map

Flatiron.multimap : Integer

Number of UV maps across which the selected objects are distributed. By default, all objects are unwrapped into the same UV map. When this value is equal to or higher than the number of objects, each object is unwrapped into its own map.

Use Selection Sets

Flatiron.use_sets : Boolean

When True, Flatiron ignores the active object selection and the multimap settings, and instead uses the assigned selection sets. One UV map is generated for each set.

Sets

Flatiron.sets : <array>

An array of strings defining the names of all selection sets considered by Flatiron when use_sets is True.

Number of Sets

Flatiron.num_sets : Integer

Returns the number of selection sets currently considered by Flatiron when use_sets is True.

This property is read-only. Setting it has no effect.

Bake Output Settings

Output Directory

Flatiron.output : String

Specifies the directory where baked maps will be saved. Do not include a file name; file names are defined individually for each bake element.

Bake Mode

Flatiron.bake_mode : Integer

Determines the bake mode used by Flatiron:

  • 0 — Multi Pass
  • 1 — Single Pass

Overlap

Flatiron.overlap : Integer

Defines how many pixels the rendered texture overlaps beyond UV chart borders to reduce visible seams. If this value is set too high and the padding between charts is too small, the overlap may bleed into neighboring charts.

Illumination

Flatiron.illumination : Boolean

If True, the target material is set to 100% self-illuminated. If False, the source self-illumination is left unchanged.

Material by Name

Flatiron.material_str : String

Gets or sets the material assigned to baked objects by using the material name.

Material by Class

Flatiron.material_cls : MaxObject

Gets or sets the material assigned to baked objects using the material’s MaxObject.

Use Shell Material

Flatiron.use_shell : Boolean

If True, selected objects receive a shell material that stores the original material in one slot and the new bake material in the other. If False, the baked map is inserted directly into the target map slot of the object.

Animation Range Settings

Bake Range

Flatiron.bake_range : Boolean

If True, Flatiron bakes multiple frames. If False, only the current frame is baked.

Range From

Flatiron.range_from : Integer

Specifies the first frame of the bake range.

Range To

Flatiron.range_to : Integer

Specifies the last frame of the bake range.

File Naming

Add Group Prefix

Flatiron.add_group_prefix : Boolean

If True, the unwrap group name is added to the rendered texture file names to avoid accidental overwrites when multiple groups are baked with similar settings. If False, only the bake element’s file name is used.

Network Rendering Settings

Network Rendering

Flatiron.netrender : Boolean

Determines whether Flatiron uses network rendering. If False, baking is performed locally.

Host

Flatiron.host : String

Host name or IP address of the Backburner Manager handling the render job.

Port

Flatiron.port : Integer

Port number used by the Backburner Manager.

Network Path

Flatiron.net_path : String

Network directory used by Flatiron for temporary data during network rendering.

Error Message

Flatiron.error : String

If a method returns False because of an error, this property contains the corresponding error message.

This property is read-only. Setting it has no effect.

Backburner Automation Settings

Automate Backburner Dialog

Flatiron.bb_automate: Boolean

Enables or disables automated handling of the Backburner dialog. This is disabled by default.

Backburner automation is not officially supported through the 3ds Max SDK or MAXScript. Flatiron uses workarounds for this feature, so it may not work reliably in all environments.

Backburner Job Name

Flatiron.bb_name: String

Sets the job name shown in the Backburner Monitor. Different jobs must not use the same name. If left empty, Flatiron automatically generates a unique job name.

Backburner Job Description

Flatiron.bb_description: String

Sets the job description shown in the Backburner Monitor.

Backburner Search Mask

Flatiron.bb_search_mask: String

Specifies the network mask for automatic search of the Backburner Manager. Setting this property automatically enables automatic search.

Default value:

255.255.255.0

Querying this property returns an empty string if automatic search is currently disabled.

Backburner Manager IP

Flatiron.bb_manager_ip: String

Specifies the IP address of the Backburner server. Setting this property automatically disables automatic search. Querying it returns an empty string if automatic search is currently enabled.

Backburner Priority

Flatiron.bb_priority: Integer

Sets the render job priority. Values are automatically clamped to the range 1 to 100.

Ignore Scene Path

Flatiron.bb_ignore_scene_path: Boolean

Toggles the checkbox with the same name in the Backburner dialog.

Rendered Frame Window

Flatiron.bb_rendered_frame_window: Boolean

Toggles the checkbox with the same name in the Backburner dialog.

Include Maps

Flatiron.bb_include_maps: Boolean

Toggles the checkbox with the same name in the Backburner dialog.

Initially Suspended

Flatiron.bb_initially_suspended: Boolean

Toggles the checkbox with the same name in the Backburner dialog.


Methods

The following methods correspond to the main Flatiron UI actions.

Unwrap Group Methods

Unwrap

<bool> Flatiron.unwrap <unwrap_group_name>

Unwraps the selected objects using the current Flatiron settings and creates an unwrap group with the given name. Returns True if successful, False if an error occurred.

Remove Unwrap Group

<bool> Flatiron.remove_unwrap_group <unwrap_group_name>

Removes the specified unwrap group from the scene. Returns True on success, False if the group cannot be removed or does not exist.

List Unwrap Groups

<array> Flatiron.list_unwrap_groups()

Returns an array of strings with the names of all unwrap groups currently stored in the scene.

Rename Unwrap Group

<bool> Flatiron.rename_unwrap_group <old_name> <new_name>

Renames an unwrap group. Returns True on success, False if the rename fails, for example because another group already uses the new name.

Get Group Objects

<array> Flatiron.get_group_objects <unwrap_group_name>

Returns an array of all scene objects belonging to the specified unwrap group.

Get Group Map Objects

<array> Flatiron.get_group_map_objects <unwrap_group_name> <map_index>

Returns an array of all scene objects in the specified unwrap group that belong to the specified map index.

Get Number of Maps in Group

<int> Flatiron.get_num_maps_in_group <unwrap_group_name>

Returns the number of UV maps across which the objects in the specified group are distributed.

Bake Element Methods

Add Bake Element by Name

<bool> Flatiron.add_bake_element_str <element_str>

Adds a bake element by name to the queue of bake elements. Returns True on success, False if the bake element cannot be added or does not exist.

Add Bake Element by Class

<bool> Flatiron.add_bake_element_cls <element_cls>

Adds a bake element by class to the queue of bake elements. Returns True on success, False if the bake element cannot be added or does not exist.

List Bake Elements

<array> Flatiron.list_bake_elements()

Returns an array of strings with the names of all bake elements queued for rendering when bake() is called.

Remove Bake Element

<bool> Flatiron.remove_bake_element <index>

Removes the bake element at the given index from the queue. Returns True on success, False if the element does not exist or cannot be removed.

Get Element File Name

<string> Flatiron.get_element_file_name <index>

Returns the file name of the bake element at the given index.

Set Element File Name

Flatiron.set_element_file_name <index> <filename>

Sets the file name of the bake element at the given index. All bake elements are saved in the directory specified by Flatiron.output.

Get Element Width

<int> Flatiron.get_element_width <index>

Returns the render width of the bake element at the given index.

Set Element Width

Flatiron.set_element_width <index> <width>

Sets the render width of the bake element at the given index.

Get Element Height

<int> Flatiron.get_element_height <index>

Returns the render height of the bake element at the given index.

Set Element Height

Flatiron.set_element_height <index> <height>

Sets the render height of the bake element at the given index.

Get Element Slot

<string> Flatiron.get_element_slot <index>

Returns the material map slot currently assigned to the bake element at the given index.

Set Element Slot

Flatiron.set_element_slot <index> <slotname>

Sets the material map slot of the bake element at the given index by name.

Get Element Background Color

<color> Flatiron.get_element_bg <index>

Returns the background color assigned to the bake element at the given index.

Set Element Background Color

Flatiron.set_element_bg <index> <color>

Sets the background color for the bake element at the given index.

Get Number of Element Properties

<int> Flatiron.get_num_element_properties <index>

Returns the number of individual parameters available for the bake element at the given index.

Get Element Property Name

<string> Flatiron.get_element_property_name <index> <parameter>

Returns the name of the specified parameter for the bake element at the given index.

Get Element Property Type

<int> Flatiron.get_element_property_type <index> <parameter>

Returns the type of the specified parameter for the bake element at the given index.

Get Element Property Value

<FPValue> Flatiron.get_element_property_value <index> <parameter>

Returns the current value of the specified parameter for the bake element at the given index.

Set Element Property Value

<bool> Flatiron.set_element_property_value <index> <parameter> <value>

Sets the value of the specified parameter for the bake element at the given index.

Bake and Settings Methods

Bake

<bool> Flatiron.bake <uv_group_name>

Bakes the objects in the specified unwrap group using the current Flatiron settings. Returns True if successful, False if an error occurred.

Reset

<bool> Flatiron.reset()

Resets all Flatiron settings to their default values. Returns True if successful, False otherwise.

Load Settings

<bool> Flatiron.load <file>

Loads Flatiron settings from a file. Returns True if successful, False otherwise.

Save Settings

<bool> Flatiron.save <file>

Saves Flatiron settings to a file. Returns True if successful, False otherwise.

Delete Shells

<bool> Flatiron.delete_shells <keep_baked>

Removes shell materials from the selected objects. If the parameter is True, the material from the baked slot is kept and the original material is discarded. If the parameter is False, the original material is kept and the baked material is discarded.

Returns True if successful, False if an error occurred.

Network Merge Methods

Merge

<bool> Flatiron.merge <job_file>

Executes Flatiron’s merge workaround for network rendering when job completion could not be detected automatically. Make sure the render job is finished before calling this function, otherwise the resulting texture will be incomplete.

The parameter specifies the job.desc file automatically created by Flatiron in the render job’s temporary network directory.

Returns True if successful, False if an error occurred.

Merge All

<bool> Flatiron.merge_all <directory>

Works like merge, but merges all jobs found in the subdirectories of the specified directory. Make sure all network render jobs are completed before calling this function, otherwise the resulting textures will be incomplete.

Returns True if successful, False if at least one merge operation encounters an error.

Selection Set Methods

Add Set

<bool> Flatiron.add_set <name>

Adds the named selection set to the list of sets used by Flatiron. Returns True if the set was added, False if nothing was changed. This can happen if the named selection set does not exist or is already included.

Remove Set by Name

<bool> Flatiron.remove_set_str <name>

Removes the named selection set from the list used by Flatiron. Returns True if successful, False if the set was not found or could not be removed.

Remove Set by Index

<bool> Flatiron.remove_set_int <index>

Removes the selection set at the given index from Flatiron’s internal list. The order matches the array returned by Flatiron.sets and starts at 1.

Returns True if successful, False if the index is invalid.

Backburner Reset

Reset Backburner Settings

<bool> Flatiron.bb_reset()

Resets only the Backburner-related settings to their default values. Calling Flatiron.reset() also resets these settings.


Example Script

This example bakes a complete map for the entire scene and inserts the resulting map directly into the Diffuse Color slot of all objects.

select $*
Flatiron.reset()
Flatiron.map_channel = 2
Flatiron.stretch = 0.05
Flatiron.padding = 4
Flatiron.width = 512
Flatiron.height = 512
Flatiron.overlap = 4
Flatiron.preview = false
Flatiron.unwrap "group1"
Flatiron.output = "C:\\"
Flatiron.material_str = "Standard"
Flatiron.add_bake_element_str "CompleteMap"
Flatiron.set_element_file_name 1 "render.tga"
Flatiron.set_element_slot 1 "Diffuse Color"
Flatiron.set_element_width 1 1024
Flatiron.set_element_height 1 1024
Flatiron.use_shell = false
Flatiron.bake "group1"