3ds Max C++ API Reference
units.h File Reference
#include "maxheap.h"
#include "strclass.h"
#include "maxtypes.h"

Classes

struct  DispInfo
 This is the display information structure. More...
 

Macros

#define UNITS_INCHES   0
 
#define UNITS_FEET   1
 
#define UNITS_MILES   2
 
#define UNITS_MILLIMETERS   3
 
#define UNITS_CENTIMETERS   4
 
#define UNITS_METERS   5
 
#define UNITS_KILOMETERS   6
 
#define MAX_UNIT_TYPES   7
 
#define UNITDISP_GENERIC   0
 
#define UNITDISP_METRIC   1
 
#define UNITDISP_US   2
 
#define UNITDISP_CUSTOM   3
 
#define MAX_UNITDISP_TYPES   4
 
#define UNIT_METRIC_DISP_MM   0
 
#define UNIT_METRIC_DISP_CM   1
 
#define UNIT_METRIC_DISP_M   2
 
#define UNIT_METRIC_DISP_KM   3
 
#define MAX_METRIC_DISP_TYPES   4
 
#define UNIT_US_DISP_FRAC_IN   0
 
#define UNIT_US_DISP_DEC_IN   1
 
#define UNIT_US_DISP_FRAC_FT   2
 
#define UNIT_US_DISP_DEC_FT   3
 
#define UNIT_US_DISP_FT_FRAC_IN   4
 
#define UNIT_US_DISP_FT_DEC_IN   5
 
#define MAX_US_DISP_TYPES   6
 
#define UNIT_FRAC_1_1   0
 
#define UNIT_FRAC_1_2   1
 
#define UNIT_FRAC_1_4   2
 
#define UNIT_FRAC_1_8   3
 
#define UNIT_FRAC_1_10   4
 
#define UNIT_FRAC_1_16   5
 
#define UNIT_FRAC_1_32   6
 
#define UNIT_FRAC_1_64   7
 
#define UNIT_FRAC_1_100   8
 
#define MAX_FRAC_TYPES   9
 
#define UNIT_DESIG_MM   0
 
#define UNIT_DESIG_CM   1
 
#define UNIT_DESIG_M   2
 
#define UNIT_DESIG_KM   3
 
#define UNIT_DESIG_IN   4
 
#define UNIT_DESIG_FT   5
 
#define UNIT_DESIG_CUSTOM   6
 
#define UNIT_DESIG_TYPES   7
 
#define US_UNIT_DEFAULT_FEET   0
 
#define US_UNIT_DEFAULT_INCHES   1
 

Enumerations

enum  TimeDisp { DISPTIME_FRAMES , DISPTIME_SMPTE , DISPTIME_FRAMETICKS , DISPTIME_TIMETICKS }
 

Functions

CoreExport double GetSystemUnitScale (int type)
 Retrieves the System Unit scale in terms of the specified unit type. More...
 
MAX_DEPRECATED CoreExport double GetMasterScale (int type)
 
CoreExport double GetRelativeScale (int fromType, float fromScale, int toType, float toScale)
 Computes a scaling factor for going from given units to others.
More...
 
CoreExport void GetSystemUnitInfo (int *type, float *scale)
 Retrieves the System Unit settings in effect. More...
 
MAX_DEPRECATED CoreExport void GetMasterUnitInfo (int *type, float *scale)
 
CoreExport int SetSystemUnitInfo (int type, float scale)
 Sets the System Unit settings. More...
 
MAX_DEPRECATED CoreExport int SetMasterUnitInfo (int type, float scale)
 
CoreExport void GetUnitDisplayInfo (DispInfo *info)
 Retrieves the current unit display information. More...
 
CoreExport int SetUnitDisplayInfo (DispInfo *info)
 Sets the unit display information used by 3ds Max. More...
 
CoreExport int GetUnitDisplayType ()
 Returns the current unit display type to one of the following values: More...
 
CoreExport int SetUnitDisplayType (int type)
 Sets the current unit display type to one of the following values: More...
 
CoreExport BOOL IsValidUnitCharacter (int ch)
 
CoreExport void SetUSDefaultUnit (int type)
 
CoreExport int GetUSDefaultUnit ()
 
CoreExport const MCHARGetFirstUnitName ()
 
CoreExport const MCHARGetNextUnitName ()
 
CoreExport const MCHARGetFirstMetricDisp ()
 
CoreExport const MCHARGetNextMetricDisp ()
 
CoreExport const MCHARGetFirstUSDisp ()
 
CoreExport const MCHARGetNextUSDisp ()
 
CoreExport const MCHARGetFirstFraction ()
 
CoreExport const MCHARGetNextFraction ()
 
CoreExport const MCHARFormatUniverseValue (float value)
 Converts the specified value to an ASCII representation according to the current unit scale. More...
 
CoreExport float DecodeUniverseValue (const MCHAR *string, BOOL *valid=NULL)
 Parses the specified string using the current unit settings and converts it to a floating point value. More...
 
CoreExport void TimeToString (TimeValue t, MSTR &string)
 
CoreExport BOOL StringToTime (MSTR string, TimeValue &t)
 
CoreExport int GetFrameRate ()
 
CoreExport void SetFrameRate (int rate)
 
CoreExport int GetTicksPerFrame ()
 
CoreExport void SetTicksPerFrame (int ticks)
 
CoreExport TimeDisp GetTimeDisplayMode ()
 
CoreExport void SetTimeDisplayMode (TimeDisp m)
 
CoreExport int LegalFrameRate (int r)
 
CoreExport void RegisterDistanceDefault (const MCHAR *section, const MCHAR *key, float inchesDefault, float metersDefault)
 Registers a default value for a distance value. More...
 
CoreExport void RestoreDistanceDefault (const MCHAR *section, const MCHAR *key, float inchesDefault, float metersDefault)
 Restores the original default value for a distance value. More...
 
CoreExport float GetDistanceDefault (const MCHAR *section, const MCHAR *key)
 Gets the default for the given section and key in the defaults file. More...
 
CoreExport void SetDistanceDefault (const MCHAR *section, const MCHAR *key, float value)
 Sets the defaults for the given section and key in the defaults file. More...
 

Macro Definition Documentation

◆ UNITS_INCHES

#define UNITS_INCHES   0

◆ UNITS_FEET

#define UNITS_FEET   1

◆ UNITS_MILES

#define UNITS_MILES   2

◆ UNITS_MILLIMETERS

#define UNITS_MILLIMETERS   3

◆ UNITS_CENTIMETERS

#define UNITS_CENTIMETERS   4

◆ UNITS_METERS

#define UNITS_METERS   5

◆ UNITS_KILOMETERS

#define UNITS_KILOMETERS   6

◆ MAX_UNIT_TYPES

#define MAX_UNIT_TYPES   7

◆ UNITDISP_GENERIC

#define UNITDISP_GENERIC   0

◆ UNITDISP_METRIC

#define UNITDISP_METRIC   1

◆ UNITDISP_US

#define UNITDISP_US   2

◆ UNITDISP_CUSTOM

#define UNITDISP_CUSTOM   3

◆ MAX_UNITDISP_TYPES

#define MAX_UNITDISP_TYPES   4

◆ UNIT_METRIC_DISP_MM

#define UNIT_METRIC_DISP_MM   0

◆ UNIT_METRIC_DISP_CM

#define UNIT_METRIC_DISP_CM   1

◆ UNIT_METRIC_DISP_M

#define UNIT_METRIC_DISP_M   2

◆ UNIT_METRIC_DISP_KM

#define UNIT_METRIC_DISP_KM   3

◆ MAX_METRIC_DISP_TYPES

#define MAX_METRIC_DISP_TYPES   4

◆ UNIT_US_DISP_FRAC_IN

#define UNIT_US_DISP_FRAC_IN   0

◆ UNIT_US_DISP_DEC_IN

#define UNIT_US_DISP_DEC_IN   1

◆ UNIT_US_DISP_FRAC_FT

#define UNIT_US_DISP_FRAC_FT   2

◆ UNIT_US_DISP_DEC_FT

#define UNIT_US_DISP_DEC_FT   3

◆ UNIT_US_DISP_FT_FRAC_IN

#define UNIT_US_DISP_FT_FRAC_IN   4

◆ UNIT_US_DISP_FT_DEC_IN

#define UNIT_US_DISP_FT_DEC_IN   5

◆ MAX_US_DISP_TYPES

#define MAX_US_DISP_TYPES   6

◆ UNIT_FRAC_1_1

#define UNIT_FRAC_1_1   0

◆ UNIT_FRAC_1_2

#define UNIT_FRAC_1_2   1

◆ UNIT_FRAC_1_4

#define UNIT_FRAC_1_4   2

◆ UNIT_FRAC_1_8

#define UNIT_FRAC_1_8   3

◆ UNIT_FRAC_1_10

#define UNIT_FRAC_1_10   4

◆ UNIT_FRAC_1_16

#define UNIT_FRAC_1_16   5

◆ UNIT_FRAC_1_32

#define UNIT_FRAC_1_32   6

◆ UNIT_FRAC_1_64

#define UNIT_FRAC_1_64   7

◆ UNIT_FRAC_1_100

#define UNIT_FRAC_1_100   8

◆ MAX_FRAC_TYPES

#define MAX_FRAC_TYPES   9

◆ UNIT_DESIG_MM

#define UNIT_DESIG_MM   0

◆ UNIT_DESIG_CM

#define UNIT_DESIG_CM   1

◆ UNIT_DESIG_M

#define UNIT_DESIG_M   2

◆ UNIT_DESIG_KM

#define UNIT_DESIG_KM   3

◆ UNIT_DESIG_IN

#define UNIT_DESIG_IN   4

◆ UNIT_DESIG_FT

#define UNIT_DESIG_FT   5

◆ UNIT_DESIG_CUSTOM

#define UNIT_DESIG_CUSTOM   6

◆ UNIT_DESIG_TYPES

#define UNIT_DESIG_TYPES   7

◆ US_UNIT_DEFAULT_FEET

#define US_UNIT_DEFAULT_FEET   0

◆ US_UNIT_DEFAULT_INCHES

#define US_UNIT_DEFAULT_INCHES   1

Enumeration Type Documentation

◆ TimeDisp

enum TimeDisp
Enumerator
DISPTIME_FRAMES 
DISPTIME_SMPTE 
DISPTIME_FRAMETICKS 
DISPTIME_TIMETICKS 
209  {
214  };
@ DISPTIME_FRAMETICKS
Definition: units.h:212
@ DISPTIME_SMPTE
Definition: units.h:211
@ DISPTIME_TIMETICKS
Definition: units.h:213
@ DISPTIME_FRAMES
Definition: units.h:210

Function Documentation

◆ GetSystemUnitScale()

CoreExport double GetSystemUnitScale ( int  type)

Retrieves the System Unit scale in terms of the specified unit type.

For example, GetSystemUnitScale(UNITS_INCHES) returns the number of inches per unit. Returns -1.0 if an invalid unit type is supplied.

◆ GetMasterScale()

MAX_DEPRECATED CoreExport double GetMasterScale ( int  type)
Deprecated:
This has been deprecated as of 3ds Max 2022, please use GetSystemUnitScale instead. [insensitive language]

◆ GetRelativeScale()

CoreExport double GetRelativeScale ( int  fromType,
float  fromScale,
int  toType,
float  toScale 
)

Computes a scaling factor for going from given units to others.

Parameters
[in]fromType- type of units from which we start (a value going from UNITS_INCHES to UNITS_KILOMETERS).
[in]fromScale- scale of units from which we start.
[in]toType- type of units into which we want to rescale (a value going from UNITS_INCHES to UNITS_KILOMETERS).
[in]toScale- scale of units into which we want to rescale.
Returns
- The scale factor that is needed to scale from given units to others.

◆ GetSystemUnitInfo()

CoreExport void GetSystemUnitInfo ( int type,
float *  scale 
)

Retrieves the System Unit settings in effect.

These are the System Unit type (Inches, Feet, Meters, and so on) and the System Unit scale settings. These are the values that users enter in the "1 Unit = XXX field" of the System Unit Setup dialog box.

◆ GetMasterUnitInfo()

MAX_DEPRECATED CoreExport void GetMasterUnitInfo ( int type,
float *  scale 
)
Deprecated:
This has been deprecated as of 3ds Max 2022, please use GetSystemUnitInfo instead. [insensitive language]

◆ SetSystemUnitInfo()

CoreExport int SetSystemUnitInfo ( int  type,
float  scale 
)

Sets the System Unit settings.

These are the System Unit type (Inches, Feet, Meters, and so on) and the System Unit scale settings.

◆ SetMasterUnitInfo()

MAX_DEPRECATED CoreExport int SetMasterUnitInfo ( int  type,
float  scale 
)
Deprecated:
This has been deprecated as of 3ds Max 2022, please use SetSystemUnitInfo instead. [insensitive language]

◆ GetUnitDisplayInfo()

CoreExport void GetUnitDisplayInfo ( DispInfo info)

Retrieves the current unit display information.

◆ SetUnitDisplayInfo()

CoreExport int SetUnitDisplayInfo ( DispInfo info)

Sets the unit display information used by 3ds Max.

◆ GetUnitDisplayType()

CoreExport int GetUnitDisplayType ( )

Returns the current unit display type to one of the following values:

  • UNITDISP_GENERIC
  • UNITDISP_METRIC
  • UNITDISP_US
  • UNITDISP_CUSTOM

◆ SetUnitDisplayType()

CoreExport int SetUnitDisplayType ( int  type)

Sets the current unit display type to one of the following values:

  • UNITDISP_GENERIC
  • UNITDISP_METRIC
  • UNITDISP_US
  • UNITDISP_CUSTOM

◆ IsValidUnitCharacter()

CoreExport BOOL IsValidUnitCharacter ( int  ch)

◆ SetUSDefaultUnit()

CoreExport void SetUSDefaultUnit ( int  type)

◆ GetUSDefaultUnit()

CoreExport int GetUSDefaultUnit ( )

◆ GetFirstUnitName()

CoreExport const MCHAR* GetFirstUnitName ( )

◆ GetNextUnitName()

CoreExport const MCHAR* GetNextUnitName ( )

◆ GetFirstMetricDisp()

CoreExport const MCHAR* GetFirstMetricDisp ( )

◆ GetNextMetricDisp()

CoreExport const MCHAR* GetNextMetricDisp ( )

◆ GetFirstUSDisp()

CoreExport const MCHAR* GetFirstUSDisp ( )

◆ GetNextUSDisp()

CoreExport const MCHAR* GetNextUSDisp ( )

◆ GetFirstFraction()

CoreExport const MCHAR* GetFirstFraction ( )

◆ GetNextFraction()

CoreExport const MCHAR* GetNextFraction ( )

◆ FormatUniverseValue()

CoreExport const MCHAR* FormatUniverseValue ( float  value)

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 (_T("")). So, developers can check for this condition using something like if (buf[0] == '\0') to see if an overflow occurred.

◆ DecodeUniverseValue()

CoreExport float DecodeUniverseValue ( const MCHAR string,
BOOL *  valid = NULL 
)

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.

◆ TimeToString()

CoreExport void TimeToString ( TimeValue  t,
MSTR string 
)

◆ StringToTime()

CoreExport BOOL StringToTime ( MSTR  string,
TimeValue t 
)

◆ GetFrameRate()

CoreExport int GetFrameRate ( )

◆ SetFrameRate()

CoreExport void SetFrameRate ( int  rate)

◆ GetTicksPerFrame()

CoreExport int GetTicksPerFrame ( )

◆ SetTicksPerFrame()

CoreExport void SetTicksPerFrame ( int  ticks)

◆ GetTimeDisplayMode()

CoreExport TimeDisp GetTimeDisplayMode ( )

◆ SetTimeDisplayMode()

CoreExport void SetTimeDisplayMode ( TimeDisp  m)

◆ LegalFrameRate()

CoreExport int LegalFrameRate ( int  r)

◆ RegisterDistanceDefault()

CoreExport void RegisterDistanceDefault ( const MCHAR section,
const MCHAR key,
float  inchesDefault,
float  metersDefault 
)

Registers a default value for a distance value.

The default has separate values for both Imperial and Metric systems. The Imperial default is given in inches and the Metric default is given in Meters.

◆ RestoreDistanceDefault()

CoreExport void RestoreDistanceDefault ( const MCHAR section,
const MCHAR key,
float  inchesDefault,
float  metersDefault 
)

Restores the original default value for a distance value.

◆ GetDistanceDefault()

CoreExport float GetDistanceDefault ( const MCHAR section,
const MCHAR key 
)

Gets the default for the given section and key in the defaults file.

The system returns the default relative to the current system units. If the units are Imperial (inches, feet, and so on) it returns the Imperial version of the default, otherwise it returns the Metric version. In either case the default value is returned in the current system units.

◆ SetDistanceDefault()

CoreExport void SetDistanceDefault ( const MCHAR section,
const MCHAR key,
float  value 
)

Sets the defaults for the given section and key in the defaults file.

The system sets the default relative to the current system units. If the units are Imperial (inches, feet, and so on) it sets the Imperial version of the default, otherwise it sets the Metric version.