MAXScript

Flatiron includes an interface to MAXScript, allowing you to control the plugin through your scripts without accessing the utility UI directly.

Some of the previously available properties have been deprecated to simplify usage of the plug-in. Those properties can still be used without causing an error for backwards compatibility but they will no longer affect the plug-in operation. The previously used angle properties now affect both, ridges and grooves, simultaneously and work identical to the old version.

Properties

The properties for Flatiron correspond to the options that are adjustable in the user interface and allow you to retrieve and set all values that are used by Flatiron.

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 a completeley new unwrap, 3 - Keep all existing UV data as it is without change, 4 - Projection unwrap mode based on a viewpoint and direction.

Flatiron.map_channel : Integer

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

Flatiron.stretch : Float

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

Flatiron.padding : Integer

Distance between charts in the texture.

Flatiron.width : Integer

Texture width of the UV and the baked map.

Flatiron.height : Integer

Texture height of the UV and the baked map.

Flatiron.high_quality : Boolean

Use high quality unwrap mode. This will consume more space in RAM and take longer, but will produce more accurate results. (Less stretch, charts packed tighter.)

Flatiron.preview : Boolean

A UV template will be rendered as a preview of the unwrapped map.

Flatiron.keep_seams : Boolean

If True the unwrapping process will retain already existing seams as long as the given constraints allow. If False all already existing seams are discarded and Flatiron places new seams autonomously.

Flatiron.source_channel : Integer

Defines the map channel from which the existing seams area taken when keep_seams is True. Has no effect when keep_seams is False.

Flatiron.polygonal : Boolean

If True the meshes will be unwrapped in polygonal mode, keeping quads and higher order polygons intact in the UV map. If False, seams can cut along any edge without paying special attention to the mesh’s polygon structure.

Flatiron.use_grooves : Boolean

The mesh will be split with seams along sharp grooves of at least the given threshold when this settings is True.

Flatiron.groove_angle : Float

The angle threshold used by the automatic seam generation when use_grooves is True.

Flatiron.use_ridges : Boolean

The mesh will be split with seams along sharp ridges of at least the given threshold when this settings is True.

Flatiron.ridge_angle : Float

The angle threshold used by the automatic seam generation when use_ridges is True.

Flatiron.projection_camera : Object

The object that is used to determine view location and direction. Does not have to be an actual 3ds Max camera, any object works.

Flatiron.projection_angle : Float

The view angle of the camera object.

Flatiron.projection_tolerance : Float

The tolerance angle for which backfacing polygons are included in the projection unwrap.

Flatiron.projection_orthographic : Boolean

When set to true an orthogonal projection ignoring the view angle is used.

Flatiron.multimap : Integer

The number of UV maps across which the sleected objects are distributed. By default all objects are unwrapped into the same UV map. When the setting is equal or higher than the number of objects, each object is unwrapped into its own map.

Flatiron.use_sets : Boolean

When this is True, Flatiron will ignore the active object selection and the multimap settings and instead use the assigned selection sets. An individual UV map for each set is generated.

Flatiron.sets : <array>

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

Flatiron.num_sets : Integer

Returns the number of selection sets which are considered by Flatiron when use_sets is True. This property is read-only, setting it has no effect.

Flatiron.output : String

Specifies the directory where the baked map will be saved. Do not add a file name, just the path. The file names are set individually for each bake element.

Flatiron.bake_mode : Integer

Determines the bake mode that is used by Flatiron. 0 indicates that Multi Pass baking is used, 1 indicates that Single Pass baking is used.

Flatiron.overlap : Integer

The amount of pixels that the rendered texture will overlap over the UV chart borders to avoid visible seams. If this setting is too high the overlap might draw into the area of another chart if the gutter padding between charts is too low.

Flatiron.illumination : Boolean

If True the target material is set to being 100% self-illuminated, if False the source self-illumination is not changed.

Flatiron.material_str : String

Gets or sets the material to be assigned to baked objects via the material’s name.

Flatiron.material_cls : MaxObject

Gets or sets the material to be assigned to baked objects via the material’s max object.

Flatiron.use_shell : Boolean

If True the selected objects receive a shell material that contains the object’s original material in one slot and the new bake material in the other slot. If False the map is inserted directly into the object’s target map slot.

Flatiron.bake_range : Boolean

If True a range of multiple frames will be baked. If False only the current frame will be baked.

Flatiron.range_from : Integer

Specifies the first frame of the range when multiple frames are baked.

Flatiron.range_to : Integer

Specifies the last frame of the range when multiple frames are baked.

Flatiron.netrender : Boolean

Determines if the network rendering component is used. If False, local rendering will be used.

Flatiron.host : String

Host name or IP address of the Backburner manager that will handle the render job.

Flatiron.port : Integer

Port number that is used by the Backburner manager on the target host.

Flatiron.net_path : String

Network directory for temporary data used by Flatiron.

Flatiron.error : String

If any of the methods encountered an error (and returned False) this property contains the error message. This property is read-only, setting it has no effect.

Flatiron.bb_automate: Boolean

Enables or disables the automated handling of the backburner dialog. This is disabled by default. Automation of Backburner is not officially supported through the 3ds Max SDK or MAXScript. Flatiron uses various workarounds to enable this feature and it can encounter issues or might not work at all depending on various circumstances.

Flatiron.bb_name: String

The job’s name for the Backburner monitor. Different jobs cannot have identical names. If you set custom job names take care that they are unique for each queued job. If this option is not set (or set to an empty string) Flatiron will automatically generate a unique name for the render job.

Flatiron.bb_description: String

The job’s description which is shown in the Backburner monitor.

Flatiron.bb_search_mask: String

Specifies the network mask for automatic search of the manager. Setting this will automatically enable automatic search. Defaults to 255.255.255.0. Querying this property will return an empty string if automatic search is currently disabled.

Flatiron.bb_manager_ip: String

Specifies the IP address of the backburner server. Setting this will automatically disable automatic search. Querying this property will return an empty string if automatic search is currently enabled.

Flatiron.bb_priority: Integer

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

Flatiron.bb_ignore_scene_path: Boolean

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

Flatiron.bb_rendered_frame_window: Boolean

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

Flatiron.bb_include_maps: Boolean

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

Flatiron.bb_initially_suspended: Boolean

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

Methods

The methods for Flatiron correspond to the buttons of the UI.

<bool> Flatiron.unwrap <unwrap_group_name>

Unwraps the selected objects with the current Flatiron settings and creates an unwrap group with the given name that can then be used for texture baking. Returns True if successful, False if an error occured.

<bool> Flatiron.remove_unwrap_group <unwrap_group_name>

Removes the group with the given name from the list of existing unwrap groups. Returns True on success, False if the group can’t be removed or doesn’t exist.

<array> Flatiron.list_unwrap_groups()

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

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

Changes the name of the given group with a new name. Returns true on success, False if the group couldn’t be renamed because another group with the new name already exists).

<array> Flatiron.get_group_objects <unwrap_group_name>

Returns an array of all objects in the scene that are part of the unwrap group with the given name.

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

Returns an array of all objects in the scene that are part of the unwrap group with the given name and are in the map with the given index.

<int> Flatiron.get_num_maps_in_group <unwrap_group_name>

Returns the number of maps that the objects in the gived group are spread across.

<bool> Flatiron.add_bake_element_str <element_str>

Adds the bake element with the given name to the list of bake elements to be rendered. Returns True on success, False if the bake element can’t be added or doesn’t exist.

<bool> Flatiron.add_bake_element_cls <element_cls>

Adds the bake element with the given class to the list of bake elements to be rendered. Returns True on success, False if the bake element can’t be added or doesn’t exist.

<array> Flatiron.list_bake_elements()

Returns an array of strings with the names of all bake elements that are queued to be rendered when bake() is called.

<bool> Flatiron.remove_bake_element <index>

Removes the bake element at the given index from the list of bake elements to be rendered. Returns True on success, False if the bake element can’t be removed or doesn’t exist.

<string> Flatiron.get_element_file_name <index>

Returns the file name of the bake element at the given index in the list of bake elements to be rendered.

Flatiron.set_element_file_name <index> <filename>

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

<int> Flatiron.get_element_width <index>

Returns the render width of the bake element at the given index in the list of bake elements to be rendered.

Flatiron.set_element_width <index> <width>

Sets the render width of the bake element at the given index in the list of bake elements to be rendered.

<int> Flatiron.get_element_height <index>

Returns the render height of the bake element at the given index in the list of bake elements to be rendered.

Flatiron.set_element_height <index> <height>

Sets the render height of the bake element at the given index in the list of bake elements to be rendered.

<string> Flatiron.get_element_slot <index>

Returns the name of the currently assigned material map slot for the bake element at the given index.

Flatiron.set_element_slot <index> <slotname>

Sets the currently assigned material map slot for the bake element at the given index by name.

<color> Flatiron.get_element_bg <index>

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

Flatiron.set_element_bg <index> <color>

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

<int> Flatiron.get_num_element_properties <index>

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

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

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

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

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

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

Returns the given parameter for the bake element at the given index.

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

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

<bool> Flatiron.bake <uv_group_name>

Bakes the objects that are in the given unwrap group with the current Flatiron settings. Returns True if successful, False if an error occured.

<bool> Flatiron.reset()

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

<bool> Flatiron.load <file>

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

<bool> Flatiron.save <file>

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

<bool> Flatiron.delete_shells <keep_baked>

Removes the shell materials from the selected objects. If the parameter is True it will keep the material from the “baked” slot and discard the original material. If the parameter is False the original material will be kept and the baked material will be discarded. Returns True if successful, False if an error occured.

<bool> Flatiron.merge <job_file>

This method executes the merge workaround function for network rendering when the job completion could not be detected automatically by Flatiron. Make sure that the render job is completed before calling this function, otherwise the resulting texture will be incomplete. The parameter specifies the job description file that is automatically created by Flatiron in the render job’s temporary network directory. Returns True if successful, False if an error occured.

<bool> Flatiron.merge_all <directory>

This works like the merge function but it merges all jobs in the subdirectories of the given directory. Make sure that all render jobs are completed before calling this function, otherwise the resulting textures will be incomplete. Returns True if successful, False if for at least one of the merge operations encountered an error.

<bool> Flatiron.add_set <name>

Adds the named selection set with the given name to the list of sets used by Flatiron. Returns True if the set was added, False if nothing was done. This can happen when no selection set with the given name exists or the set was already included in the list for Flatiron.

<bool> Flatiron.remove_set_str <name>

Removes the named selection set with the given name from the list of sets used by Flatiron. Returns True if the set was removed successfully. Returns False when the set could not be removed because it is not included in the list or no selection set with the given name exists at all.

<bool> Flatiron.remove_set_int <index>

Removes the named selection set at the given index in the list of sets used by Flatiron. The order of sets in the list is identical to the one in the array returned by Flatiron.sets and starts with 1. Returns True if the set was removed successfully. Returns False when the set could not be removed because the index was invalid.

<bool> Flatiron.bb_reset()

Works similar to the full reset but it only resets the settings relating to the backburner dialog to their default values. Calling Flatiron.reset() will also reset those settings.

Example Script

This example bakes a complete map map for the whole 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"