c4d.modules.volume.VolumeObject.GetVolume() returns unknown data type

  • Env.: R20, Windows
    Lang.: Python

    @s_bach said in Check object (poly) intersect:

    Regarding Volume Interface: if you have problems using the Volume object, please report this in a new thread. There are some issues with the API, that are fixed in the next version.

    To formalize it: c4d.modules.volume.VolumeObject.GetVolume() returns a unknown data type and Cinema 4D did crash on me when I tried try to access the value (I think I did something like dir(my_volumeInterface)).

    I always assumed this was somehow intentional/NYI since the Python SDK has no maxon framework and VolumeInterface type (yet), although the Python SDK states that return type of GetVolume() is maxon.VolumeInterface.

    If VolumeInterfaces aren't introduced into the R21 Python SDK, it might be a good idea to flag related methods as NYI.


  • Hello,

    maxon is not a framework, but a module. It is actually available in R20 (just not documented). It can be imported like this:

    import maxon

    Volume interfaces are part of the volume framework:

    from maxon.frameworks import volume as v

    With these interfaces it is possible to use the volume classes:

    import c4d
    import maxon
    from maxon.frameworks import volume as v
    def main():
        # Create VolumeObject
        volumeObj = c4d.BaseObject(c4d.Ovolume)
        if volumeObj is None:
        # Insert the volume Object within the scene
        doc.InsertObject(volumeObj, None, None)
        # Create volume
        volume = v.VolumeToolsInterface.CreateNewFloat32Volume(0.0)
        volume.SetGridName("Example Grid")
        scaleMatrix = maxon.Matrix()
        # Create accessor
        access = v.GridAccessorInterface.Create(maxon.Float32)
        # Set values in the shape of a helix
        offset = 0.0
        scale = 100.0
        scaleY = 10.0
        while offset < 50.0:
            res = c4d.utils.SinCos(offset)
            sin = res[0]
            cos = res[1]
            pos = maxon.IntVector32()
            pos.x = maxon.Int32(sin * scale)
            pos.y = maxon.Int32(cos * scale)
            pos.z = maxon.Int32(offset * scaleY)
            # Set value
            access.SetValue(pos, 10.0)
            offset = offset + 0.1
        # Insert volume in the VolumeObject
    if __name__=='__main__':

    A volume is then accessed like:

    volume = op.GetVolume()

    Using dir() seems to crash, but this fixed in the next version.

    The upcoming R21 Python documentation will include much more information on the MAXON API and the maxon module.

    best wishes,

  • Hi,

    thank you for the clarification.