Units of Measurement Reference

3DS Max Plug-In SDK

Units of Measurement Reference

This section documents the API structures and functions related to units of measurement. For overview information see the Advanced Topics section Units of Measurement.

Structures:

See Structure DispInfo.

Function:

double GetMasterScale(int type);

Remarks:

Retrieves the master scale in terms of the specified unit type. For example:. GetMasterScale(UNITS_INCHES) returns the number of inches per unit. Returns -1.0 if an invalid unit type is supplied.

Parameters:

int type

Supported unit types:

UNITS_INCHES

UNITS_FEET

UNITS_MILES

UNITS_MILLIMETERS

UNITS_CENTIMETERS

UNITS_METERS

UNITS_KILOMETERS

Return Value:

The master scale in terms of the specified unit type.

Function:

void GetMasterUnitInfo(int *type, float *scale);

Remarks:

Retrieves the master unit settings in effect. These are the unit type (Inches, Feet, Meters, etc.) and the master scale setting.

Parameters:

int *type

Retrieves the unit type in effect. This may be one of the following values:

Supported unit types:

UNITS_INCHES

UNITS_FEET

UNITS_MILES

UNITS_MILLIMETERS

UNITS_CENTIMETERS

UNITS_METERS

UNITS_KILOMETERS

float *scale

The master scale setting. This is the value the user entered in the

1 Unit = XXX field of the General Page in the Preference Settings dialog box.

Function:

int SetMasterUnitInfo(int type,float scale);

Remarks:

Set the master unit settings. These are the unit type (Inches, Feet, Meters, etc.) and the master scale setting.

Parameters:

int *type

Specifies the unit type to use. This may be one of the following values:

Supported unit types:

UNITS_INCHES

UNITS_FEET

UNITS_MILES

UNITS_MILLIMETERS

UNITS_CENTIMETERS

UNITS_METERS

UNITS_KILOMETERS

float *scale

The master scale setting.

Return Value:

Nonzero if the information was set; 0 if invalid values were specified and nothing was stored.

Function:

void GetUnitDisplayInfo(DispInfo *info);

Remarks:

Retrieves the current unit display information.

Parameters:

DispInfo *info

Points to storage for the display information. See Structure DispInfo.

Function:

int SetUnitDisplayInfo(DispInfo *info);

Remarks:

Sets the unit display information used by 3ds max.

Parameters:

DispInfo *info

Points to display information. See Structure DispInfo.

Return Value:

Nonzero if the information was set; 0 if invalid values were specified and nothing was stored.

Function:

int GetUnitDisplayType();

Remarks:

Returns the current unit display type.

Return Value:

One of the following values:

UNITDISP_GENERIC

UNITDISP_METRIC

UNITDISP_US

UNITDISP_CUSTOM

Function:

int SetUnitDisplayType(int type);

Remarks:

Sets the current unit display type.

Parameters:

int type

One of the following values:

UNITDISP_GENERIC

UNITDISP_METRIC

UNITDISP_US

UNITDISP_CUSTOM

Return Value:

Nonzero if the value was set. Zero if an improper value was specified.

Function:

TCHAR *FormatUniverseValue(float value);

Remarks:

This function converts the specified value to an ASCII representation according to the current unit scale. Note that this can cause a string overflow, especially when the units are set to miles or kilometers. If an overflow occurs the function returns a null string (i.e. _T("")). Thus developers can check for this condition using something like if (buf[0] == '\0') to see if an overflow occurred.

Parameters:

float value

The input value to convert.

Function:

float DecodeUniverseValue(TCHAR *string, BOOL *valid = NULL);

Remarks:

This method parses the specified string using the current unit settings and converts it to a floating point value. If an error occurs in the parsing then valid is set to FALSE.

Parameters:

TCHAR *string

The input string to convert.

BOOL *valid = NULL

TRUE if the string was converted correctly; FALSE on error.