c4d.storage.ByteSeq

Several objects and hooks in CINEMA 4D allow Python to access the internal data on low-level. These functions can be used to handle raw data. ByteSeq is similar to the built-in Buffer Object but is optimized to work with CINEMA 4D.

class c4d.storage.ByteSeq

Methods

ByteSeq.__init__(buf, len[, readonly=False])

Allocates a byte sequence.

Parameters:
  • buf (PyCObject or None) – PyCObject address or None to allocate a new pool of memory
  • len (int) – The length of the new byte sequence
  • readonly (bool) – Set to True if the byte sequence should be flagged as read-only, otherwise False.
Return type:

ByteSeq

Returns:

The byte sequence object.

ByteSeq.__str__()

Creates a string object from the byte sequence.

Return type: string
Returns: The byte-sequence returned as a string.
ByteSeq.__add__(other)
Parameters: other (int) – The offset value.
Return type: ByteSeq
Returns: New ByteSeq object.
ByteSeq.__compare__(other)

Compares two byte sequences.

Parameters: other (ByteSeq) – The other byte sequence.
Return type: bool
Returns: True if the byte sequences are equal, otherwise False.
ByteSeq.__iter__()

Iterates over the bytes of the object, interpreted as one-element string:

for b in bs:
    print b
Return type: iter for str
Returns: The iterator.
ByteSeq.__hash__()

Returns a hash of the byte sequence. The hash value is cached if the object owns the byte sequence and it’s flagged as read-only:

print hash(bs)
Return type: int
Returns: The hash.
ByteSeq.__len__()

Returns the length of the byte sequence.

Return type: int
Returns: The length.
ByteSeq.__setitem__(key, value)

Replaces a byte at position key with the new value:

bs1[5:7] = "ab"
bs2[100] = "a"
bs3[:100] = "0"*100
Raises TypeError:
 

Raised if byte sequence is flagged as read-only.

Parameters:
  • key (int or slice) – The index
  • value (int) – The new value, must between 0-255.
ByteSeq.__getitem__(key)

Gets the bytes at position key:

print bs1[5:7] #output: "ab"
print bs2[100] # output "a"
print bs3[:100] # output "0000..."
Parameters: key (int or slice) – The index
Return type: str
Returns: The bytes at the requested position.
ByteSeq.GetClone()

Clones a byte sequence.

Return type: ByteSeq
Returns: The clone.
ByteSeq.GetOffset(o)

Returns a buffer object with a relative point.

Parameters: o (int) – The offset length.
Return type:
Returns: The buffer object.

Table Of Contents