MAXScript

UV-Packer includes an interface to MAXScript, allowing you to control the plugin through your scripts in order to automate the use of the modifier even further and to allow for convenient batch processing of objects.

Properties

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

UVPacker.combine : Boolean

If this option is enabled all objects that share the instance of the modifier will be packed together into the same uv space so that they don’t overlap each other. If it is disabled each object is packed individually without considering other objects that share the same modifier instance.

UV Sheet

UVPacker.width : Integer

Texture width of the UV and the baked map. Setting this via MAXScript does not take the aspect lock state into consideration. The height will not be cahnged automatically when this value is adjusted.

UVPacker.height : Integer

Texture height of the UV and the baked map. Setting this via MAXScript does not take the aspect lock state into consideration. The width will not be cahnged automatically when this value is adjusted.

UVPacker.padding : Integer

Distance between charts in the texture.

UV Packing Engine

UVPacker.packmode : Integer

Specifies tha packing engine used.

0: Classic

1: Efficient

2: High Quality

UVPacker.rescale : Boolean

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

UVPacker.prerotate : Boolean

Determines if each chart should be indivdiually rotated into an optimized base rotation. Prerotation is independent of the rotation setting below.

UVPacker.rotation : Integer

Determines the angle steps that each chart gets rotated by to place it better into the UV map. The values 0 to 3 correspond to the buttons in the user interface. A higher value allows for more fine grained rotation steps.

UVPacker.full_rotation : Boolean

With this option enabled rotations will allow counterparts for each rotation steps that are rotated by 180 degrees. This can improve the quality of pack results but has a notable performance impact.

UV Channel Control

UVPacker.source_channel : Integer

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

UVPacker.channel : Integer

Target map slot. This is where the generated UV map will be stored. If the option for a separate source channel is not used this is also the channel where the input charts are taken from.

UV Tiles

UVPacker.uvtile_x : Integer

The number of horizontal tiles along the U coordinate.

UVPacker.uvtile_y : Integer

The number of vertical tiles along the V coordinate.

UVPacker.create_materialid : Boolean

If this is True each face will receive a material ID depending on the tile it’s packed into. This overwrites any material IDs that might already exist on the object.

Options

UVPacker.show_preview : Boolean

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

UVPacker.color_fill_charts : Boolean

Charts in the UV preview will be filled with color.

UVPacker.color_draw_edges : Boolean

Edges and seams of charts will be drawn in the UV preview.

UVPacker.color_background : fRGBA color

The background color used in the UV preview.

UVPacker.color_edges : fRGBA color

The line color for normal edges used in the UV preview.

UVPacker.color_charts : fRGBA color

The fill color for charts used in the UV preview.

UVPacker.color_seams : fRGBA color

The line color for chart seams used in the UV preview.

Error Handling

UVPacker.success : Boolean

If True the last executed unwrapping process finished successfully. If False it finished with an error. This property is read-only, setting it has no effect.

UVPacker.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.

Methods

The methods for UV-Packer correspond to the buttons of the UI.

UVPacker.pack()

Packs with the current modifier settings. Due to the way the plug-in works this method can unfortunately not detect if packing the uv charts succeeded or an error occured! Call the property success after calling pack() to retrieve the result. If success returns False you can use the property error to retrieve the error message.

UVPacker.copy()

Copies the UV data from the current source channel to the current target channel. Just like the pack() method the operation is asynchronous and the calls to success and error can be used in the same way.

UVPacker.swap()

Swaps the UV data from the current source channel and the current target channel. Just like the pack() method the operation is asynchronous and the calls to success and error can be used in the same way.

Example Script

This example iterates through all selected objects, takes the UV data in map channel 1 as input, packs it and stores the results in map channel 2.

for obj in selection do
(
  p = UVPacker()
  addmodifier obj p
  p.show_preview = false
  p.source_channel = 1
  p.channel = 2
  p.pack()
)