DescID Manual
Parameters of C4DAtom based elements are identified using a DescID object. Such a DescID object is composed of several levels of DescLevel objects. In this way DescIDs can reflect the structure of complex data types. For example a 向量 consists of three Float values. With the first DescLevel the 向量 is accessed as a whole, with the second DescLevel the three Float components can be accessed individually.
// This example reads two parameters from the given "Landscape" object.// get the "Scale" parameter
// read the "Scale" parameter if (!landscape->GetParameter(scaleID, data, DESCFLAGS_GET::NONE )) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); const Float scale = data. GetFloat (); ApplicationOutput ( "Scale: " + String::FloatToString (scale));
// get the x component of the "Size" parameter const DescLevel fractalLenLevel( PRIM_FRACTAL_LEN , DTYPE_VECTOR , 0); const DescLevel vectorXLevel( VECTOR_X , DTYPE_REAL , 0); const DescID sizeXID = DescID (fractalLenLevel, vectorXLevel);
// read the x-component of the "Size" parameter if (!landscape->GetParameter(sizeXID, data, DESCFLAGS_GET::NONE )) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); const Float sizeX = data. GetFloat (); ApplicationOutput ( "Size X: " + String::FloatToString (sizeX));
User data parameters are stored in a sub-container with the ID ID_USERDATA .
// This example reads the user data parameters 1 and 2 of the given object. GeData data; const DescLevel userDataLevel( ID_USERDATA , DTYPE_SUBCONTAINER , 0); const DescLevel firstParameter(1, DTYPE_REAL , 0); const DescID floatParameterID = DescID (userDataLevel, firstParameter);// read the user data parameter 1 if (object-> GetParameter (floatParameterID, data, DESCFLAGS_GET::NONE )) { const String floatStr = String::FloatToString (data. GetFloat ()); ApplicationOutput ( "Float value: " + floatStr); } const DescLevel secondParameter(2, DTYPE_VECTOR , 0); const DescLevel vectorXLevel( VECTOR_X , DTYPE_REAL , 0); const DescID vectorSubParameterID = DescID (userDataLevel, secondParameter, vectorXLevel);
// read the x-component of the user data parameter 2 if (object-> GetParameter (vectorSubParameterID, data, DESCFLAGS_GET::NONE )) { const String floatStr = String::FloatToString (data. GetFloat ()); ApplicationOutput ( "Vector X value: " + floatStr); }
A DescID object identifies a parameter.
DescID objects can be created with different constructors:
// This example reads the "Radius" parameter of the given sphere object // with differently constructed DescIDs. GeData data; DescID radiusID = DescID ( PRIM_SPHERE_RAD );// read "Radius" parameter if (!sphere-> GetParameter (radiusID, data, DESCFLAGS_GET::NONE )) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); MAXON_SCOPE { const Float radius = data. GetFloat (); ApplicationOutput ( "Radius: " + String::FloatToString (radius)); } radiusID = DescID ( DescLevel ( PRIM_SPHERE_RAD , DTYPE_REAL , 0));
// read "Radius" parameter if (!sphere-> GetParameter (radiusID, data, DESCFLAGS_GET::NONE )) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); MAXON_SCOPE { const Float radius = data. GetFloat (); ApplicationOutput ( "Radius: " + String::FloatToString (radius)); }
A complex DescID object with several levels can be constructed with these tools:
// read the x-component of the "Size" parameter if (!landscape->GetParameter(sizeXID, data, DESCFLAGS_GET::NONE )) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); const Float sizeX = data. GetFloat (); ApplicationOutput ( "Size X: " + String::FloatToString (sizeX));
The levels of a DescID object can also be edited with these operators:
// read the x-component of the "Size" parameter if (!landscape->GetParameter(sizeXID, data, DESCFLAGS_GET::NONE )) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); const Float sizeX = data. GetFloat (); ApplicationOutput ( "Size X: " + String::FloatToString (sizeX));
Further functions are:
DescID objects can be stored in a HyperFile .
A DescLevel represents a level of a DescID parameter ID.
DescLevel objects can be created with different constructors:
// This example reads the "Radius" parameter of the given sphere object // with differently constructed DescLevels. GeData data; DescID radiusID = DescID ( DescLevel ( PRIM_SPHERE_RAD ));// read the "Radius" parameter if (!sphere-> GetParameter (radiusID, data, DESCFLAGS_GET::NONE )) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); MAXON_SCOPE { const Float radius = data. GetFloat (); ApplicationOutput ( "Radius: " + String::FloatToString (radius)); } radiusID = DescID ( DescLevel ( PRIM_SPHERE_RAD , DTYPE_REAL , 0));
// read the "Radius" parameter if (!sphere-> GetParameter (radiusID, data, DESCFLAGS_GET::NONE )) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); MAXON_SCOPE { const Float radius = data. GetFloat (); ApplicationOutput ( "Radius: " + String::FloatToString (radius)); }
The public attributes of a DescLevel are:
Two DescLevel objects can be compared with: