内容表

关于

Tags can be added to BaseObject elements to add additional data or functionality (expression). The base class for all tags is BaseTag . Some tags store data of variable length depending on the host object. These extended tags are based on VariableTag and BaseTag .

BaseTag objects are an instance of Tbase , VariableTag objects are an instance of Tvariable .

注意
Tags can be hidden in the Object Manager.
警告
Since R17 the Take System can add and own tags. See Take System Take System Additional Information .

Access

The currently selected tags can be obtained from the BaseDocument :

另请参阅 BaseDocument 选择 .

The tags that are attached to an object are obtained from that object:

BaseObject Tags .

// This example removes all "Annotation" tags from the given object.

// loop until no "Annotation" tag can be found anymore while (object-> GetTag ( Tannotation )) { object ->KillTag( Tannotation ); }

A BaseTag may also be returned from a tag itself:

Allocation/Deallocation

BaseTag objects are created with the usual tools:

The tag IDs of many build-in tag types are defined in Tag Types and SelectionTag Types .

// This example creates a new "Compositing" tag and adds it to the given BaseObject. BaseTag * const tag = BaseTag::Alloc ( Tcompositing ); if (tag == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION ); object ->InsertTag(tag);

VariableTag objects are created with the usual tools, too:

The tag IDs of many build-in variable tag types are defined in VariableTag Types .

// This example creates a VertexMap tag with the given point count. const Int32 pointCount = polygonObject-> GetPointCount (); VariableTag * const vetexMapTag = VariableTag::Alloc ( Tvertexmap , pointCount); if (vetexMapTag == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION ); polygonObject-> InsertTag (vetexMapTag);

BaseTag and VariableTag elements can also be handled by the BaseObject that hosts these tags:

BaseObject Tags .

// This example checks if the given object owns a "Protection" tag. // If not, the "Protection" tag is created. BaseTag * protectionTag = object ->GetTag( Tprotection ); if (protectionTag == nullptr ) { protectionTag = object ->MakeTag( Tprotection ); if (protectionTag == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION ); }

An UVW tag can be created with this dedicated function:

A tag is hosted and owned by a BaseObject .

导航

Tags are organized in a list.

// This example loops through the tags of the given object. BaseTag * tag = object ->GetFirstTag(); while (tag != nullptr ) { ApplicationOutput ( "Tag: " + tag-> GetName ()); tag = tag-> GetNext (); }

What's a VariableTag?

VariableTag is just a means to store a varying amount of data. So it's "variable" in the sense of "capable of being changed", not in the sense of a variable (i.E. a place to store data) which again of course comes from being variable... Take for example a Polygon Object. It needs to store a number of Vectors describing point positions. And it needs to store information about polygons (basically an array of point indexes). While this information could of cause be stored in members of the Polygon Object implementation, one would need to take care of reading/writing/copying this data. Instead one can simply make use of VariableTags ( PointTag and PolygonTag in this case), they'll take care of the contained data in these cases. In regards to caching and scene execution pipeline, VariableTags don't do much, as they are only data containers in most cases. So in the above example it's rather the Polygon Object doing something with the data stored in its VariableTags. VariableTags can not be created with the SDK, one can only make use of the existing ones.

Variable Data

Variable tags store an array of elements. Typically dedicated classes exist to access the settings.

The data stored in a VariableTag can be accessed directly from the BaseObject :

另请参阅 BaseObject Tags .

// This example writes random values into the memory of the object's vertex map tag. Random random; Float32 * const data = static_cast< Float32 * > (polygonObject-> GetTagDataW ( Tvertexmap )); if (data) { for ( Int32 i = 0; i < pointCount; ++i) data[i] = ( Float32 )random. Get01 (); }

The data can also be accessed with the VariableTag itself.

// This example writes random values into the memory of the object's vertex map tag directly. VariableTag * const vTag = static_cast< VariableTag * > (polygonObject-> GetTag ( Tvertexmap )); if (vTag == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION , "The function exited unexpectedly when accessing the Tag data instance." _s); const Int32 elements = vTag-> GetDataCount (); Float32 * const data = static_cast< Float32 * > (vTag-> GetLowlevelDataAddressW ()); if (data == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION , "The function exited unexpectedly when accessing the low-level data address of the Tag data." _s); Random random; for ( Int32 i = 0; i < elements; ++i) data[i] = ( Float32 )random. Get01 ();

Flags

Tag plugins can be registered with several flags. These flags can be accessed with GeListNode::GetInfo() .

Utility

These utility functions can return the name of the tag type or return the tag type based on that name.

// This example prints the name of the tag type of the given tag. const Int32 type = tag-> GetType (); const maxon::String typeName = GetTagName (type); ApplicationOutput ( "Tag Type: " _s + typeName);

延伸阅读

BaseTag::Alloc
static BaseTag * Alloc(Int32 type)
VariableTag::GetDataCount
Int32 GetDataCount(void) const
VariableTag::GetLowlevelDataAddressW
void * GetLowlevelDataAddressW(void)
PointObject::GetPointCount
Int32 GetPointCount(void) const
定义: c4d_baseobject.h:1439
maxon::String
定义: string.h:1197
Float32
maxon::Float32 Float32
定义: ge_sys_math.h:66
Tannotation
#define Tannotation
Annotation.
定义: ge_prepass.h:1242
BaseTag
定义: c4d_basetag.h:46
VariableTag
定义: c4d_basetag.h:116
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
定义: memoryallocationbase.h:66
Tprotection
#define Tprotection
Protection.
定义: ge_prepass.h:1238
GetTagName
String GetTagName(Int32 type)
BaseObject::GetTagDataW
void * GetTagDataW(Int32 type, Int32 nr=0)
定义: c4d_baseobject.h:704
VariableTag::Alloc
static VariableTag * Alloc(Int32 type, Int32 count)
Int32
maxon::Int32 Int32
定义: ge_sys_math.h:58
ApplicationOutput
#define ApplicationOutput(formatString,...)
定义: debugdiagnostics.h:207
BaseObject::GetTag
BaseTag * GetTag(Int32 type, Int32 nr=0)
定义: c4d_baseobject.h:674
Random::Get01
Float Get01(void)
BaseTag::GetNext
BaseTag * GetNext(void)
定义: c4d_basetag.h:78
Random
定义: c4d_tools.h:811
BaseList2D::GetName
String GetName() const
定义: c4d_baselist.h:2318
Tcompositing
#define Tcompositing
Compositing/render.
定义: ge_prepass.h:1241
C4DAtom::GetType
Int32 GetType() const
定义: c4d_baselist.h:1348
BaseObject::InsertTag
void InsertTag(BaseTag *tp, BaseTag *pred=nullptr)
Tvertexmap
#define Tvertexmap
Vertex map data.
定义: ge_prepass.h:1252

Copyright  © 2014-2025 乐数软件    

工业和信息化部: 粤ICP备14079481号-1