c4d.DescID

class c4d.DescID

An ID class for description elements. Contains a stack of DescLevel objects.

The description ID is used to exactly identify a parameter value.

Constants

c4d.DESCID_ROOT

Root description ID.

c4d.ID_USERDATA

User data ID.

c4d.DESCID_DYNAMICSUB

User data/dynamic parameters description level.

Methods Signatures

DescID.__init__(self[, id1, id2, id3])

Initializes a c4d.DescID from up to three c4d.DescLevel instances or an integer.

DescID.__str__(self)

Returns a string representation of the DescID object.

DescID.__lshift__(self, other)

Returns the result of popping shift levels from the bottom of the stack

DescID.__getitem__(self, key)

Returns the level at position key in the stack

DescID.__eq__(self, other)

Checks if all levels are equal.

DescID.__ne__(self, other)

The reverse of __eq__.

DescID.SetId(self, subid)

Set the highest level to subid.

DescID.PushId(self, subid)

Push a new level onto the stack.

DescID.PopId(self)

Pops the highest level from the stack.

DescID.GetDepth(self)

Return the depth.

DescID.Write(self, hf)

Writes the description to a file.

DescID.Read(self, hf)

Reads the description from a file.

DescID.GetHashCode(self)

Gets a hash code for the description ID.

DescID.IsPartOf(self, cmp)

Checks if the description ID is part of cmp and returns the length of the match.

Methods Documentation

DescID.__init__(self, id1=0, id2=0, id3=0)

Initializes a c4d.DescID from up to three c4d.DescLevel instances or an integer.

# op: c4d.BaseObject # An object to access parameters for.

# Construct an ID from an integer directly, this only works when `id1` is the only
# argument. One can path either one of the ID symbols or a numeric literal. Here we 
# construct the ID for the relative position of an object.
idPos: c4d.DescID = c4d.DescID(903)
idPos: c4d.DescID = c4d.DescID(c4d.ID_BASEOBJECT_REL_POSITION) # Same as 903

# But `c4d.DescID` instances can have up to three levels. Here we construct the ID for 
# the x-component of the relative position vector of an object.
idPosX: c4d.DescID = c4d.DescID(c4d.DescLevel(c4d.ID_BASEOBJECT_REL_POSITION), 
                                c4d.DescLevel(c4d.VECTOR_X))

# Or a three level ID for the x-component of a vector inside the user data container. 
# The addressed element is the first user data element as expressed by the second level.
idUserVecX: c4d.DescID = c4d.DescID(c4d.DescLevel(c4d.ID_USERDATA),
                                    c4d.DescLevel(1), 
                                    c4d.DescLevel(c4d.VECTOR_X))

# And finally the ID for the x component of the relative potion of an object expressed
# with the highest possible precision. Here we also express data types and ownership.
# Being that precise this is usually only necessary when interacting with descriptions.
# For parameter access the former definition `idPosX` will suffice.
idPosX: c4d.DescID = c4d.DescID(
    c4d.DescLevel(
        c4d.ID_BASEOBJECT_REL_POSITION, # The ID of the first level, the whole vector.
        c4d.DTYPE_VECTOR,               # The data type of the first level.
        op.GetType()                    # The owner of the parameter, usually the type 
                                        # of the node, e.g., `c4d.Ocube`.
    ),
    c4d.DescLevel(
        c4d.VECTOR_X,                   # The ID of the second level, here the x-component
                                        # of the vector.
        c4d.DTYPE_REAL,                 # The data type of this channel/level. A vector
                                        # is composed out of three real numbers.
        0                               # Ownership is usually only defined for the
                                        # first level.
    )
)
Parameters
DescID.__str__(self)
Returns a string representation of the DescID object.

Called if str() is invoked on a DescID object. See object.__str__() for more information on Python’s data model.
>>> dId = c4d.DescID(c4d.DescLevel(30))
>>> print(dId)
(30, 0, 0)
Return type

str

Returns

The DescID as string.

DescID.__lshift__(self, other)

Returns the result of popping shift levels from the bottom of the stack

>>> dId = c4d.DescID(c4d.DescLevel(30), c4d.DescLevel(40), c4d.DescLevel(50))
>>> dId<<2
(50, 0, 0)
Parameters

other (int) – Number of levels to pop.

Raises

IndexError – If other is out of range : 0<=other<GetDepth().

Return type

c4d.DescID

Returns

Result.

DescID.__getitem__(self, key)

Returns the level at position key in the stack

>>> dId = c4d.DescID(c4d.DescLevel(30), c4d.DescLevel(40), c4d.DescLevel(50))
>>> dId[2]
<c4d.DescLevel object at 0x00000265FBB1F600>
Parameters

key (int) – The position.

Raises

IndexError – If other is out of range : 0<=key<GetDepth().

Return type

c4d.DescLevel

Returns

The level at the specified position.

DescID.__eq__(self, other)

Checks if all levels are equal.

DescID.__ne__(self, other)

The reverse of __eq__.

DescID.SetId(self, subid)

Set the highest level to subid.

Parameters

subid (c4d.DescLevel) – New toplevel.

DescID.PushId(self, subid)

Push a new level onto the stack.

Parameters

subid (c4d.DescLevel) – Level to push.

DescID.PopId(self)

Pops the highest level from the stack.

DescID.GetDepth(self)

Return the depth.

Return type

int

Returns

The depth.

DescID.Write(self, hf)

Writes the description to a file.

Parameters

hf (c4d.storage.HyperFile) – The hyperfile to write to.

DescID.Read(self, hf)

Reads the description from a file.

Parameters

hf (c4d.storage.HyperFile) – The hyperfile to read from.

Return type

bool

Returns

True if successful, otherwise False.

DescID.GetHashCode(self)

Gets a hash code for the description ID.

New in version R17.048.

Return type

int

Returns

The hash code.

DescID.IsPartOf(self, cmp)

Checks if the description ID is part of cmp and returns the length of the match.

New in version R18.020.

Parameters

cmp (Union[int, list, c4d.DescID]) –

The super description ID.

Changed in version R18.057.

Can be a int, list or DescID

Return type

Tuple[bool, int]

Returns

A tuple with the following information:


bool: True if the description ID matches a lowest part of cmp, otherwise False.
int: The length of the match.