Hi!
Maybe this video can help you:
https://lesterbanks.com/2019/10/how-to-install-a-3rd-party-python-library-in-cinema-4d/
Hello @ferdinand ,
First of all thanks a lot for your answer, it does exactly what I was trying to achieve, print the names of the volume grids stored on a Volume Loader with Python, I just added the GetName()
on the last loop for that.
Sorry about the rule violation, I thought it was a good idea to have the C++ and the Python code equivalent at the same place because of the same reason that you mentioned, if someone was looking for doing this they could find both versions at the same place, also as you mentioned, sometimes it can be tricky to decide when something is on-topic or not.
Here is the updated code with the grid name:
"""Demonstrates accessing volume caches.
Volumes are composed differently based on part of application using them but this script demonstrates
how most of them can be accessed.
"""
import c4d
doc: c4d.documents.BaseDocument # The active document
op: c4d.BaseObject | None # The active object, None if unselected
def main() -> None:
"""
"""
if not op:
return
# Volume output is contained in the caches of objects. In this case an Ovolume is directly
# the cache content of some tangible scene object.
cache: c4d.BaseObject = op.GetCache()
if cache.CheckType(c4d.Ovolume):
print (f"{cache = }")
# Sometimes, e.g., Pyro, volumes are loaded from VDB files on disk, in that case the loading
# tangible scene object usually holds a Ovolumeloader as the first child of its cache.
if cache.CheckType(c4d.Ovolumeloader):
cache = cache.GetCache()
# Many things contain not only a singular volume but sets of them. Which then hold their content
# as children. Stuff can get more complex as always the case with caches in Cinema 4D, but the
# cache structure of a Pyro Output object loading data from disk could look like this:
#
# PyroOutput
# Cache: Ovolumeloader
# Cache: Ovolumeset
# Child: Ovolume (Color)
# Child: Ovolume (Density)
# ...
if cache.CheckType(c4d.Ovolumeset):
cache = cache.GetCache()
for item in cache.GetChildren():
print (f"{item = }")
print ("grid name = " + item.GetName())
if __name__ == '__main__':
main()
That's great, thanks a lot for your answer @i_mazlov , may I ask if is possible to add also an Icon to the parent folder? and if is possible to add subfolders too like on the scripts?
Thanks again.
@s_bach said in Ovolumeloader:
Hello,
a volume loader is just an ordinary generator. This means the stuff it creates is in its cache. You can access the volumes stored in its cache as usual:
if (baseObject->IsInstanceOf(Ovolumeloader) == false) return maxon::IllegalArgumentError(MAXON_SOURCE_LOCATION); BaseObject* const cache = baseObject->GetCache(); if (cache == nullptr) return maxon::IllegalArgumentError(MAXON_SOURCE_LOCATION); if (cache->IsInstanceOf(Ovolume) == false) return maxon::UnexpectedError(MAXON_SOURCE_LOCATION); const VolumeObject* const volumeObject = static_cast<VolumeObject*>(cache); ApplicationOutput("Volume Object: " + volumeObject->GetName());
See also VolumeObject Manual.
best wishes,
Sebastian
Hello guys!
May I ask if this is possible to do with Python too? I tried but the equivalent of cache.IsInstanceOf(c4d.Ovolume)
is not returning True.
Thanks!
Hello!
I want to ask if someone knows how to add a "parent" plugin folder into the Extensions menu like this example:
I saw the CV-ArtSmart .pyp but I didn't understand how to put that parent and all the plugins inside of it.
I discovered if I create one folder on the plugins folder, and them each children plugin as folders it will appears as I want but that's not the most efficient way to do it if the plugins will share data that I need to duplicate on each sub folder, what's why I'm trying to get a solution similar to this example.
Thanks!
Thanks a lot for the quick response @ferdinand ! I'll use the raw int values then, thanks
Hello!
It is possible to read somehow the Color parameter from the Background section of the RS Camera?
RSCamera[c4d.RSCAMERAOBJECT_BACKGROUND_COLOR]
Hello @m_magalhaes ,
Thanks a lot for the tip, works perfectly as you said
Hello,
I created my first Python Field script, it measure the distance between one camera and each clone, everything works almost fine at this point but I don't know why for some reason, when I move the camera the field doesn't update the data from the camera position.
I need to disable and re-enable the field to update the camera data, I also tried to add "c4d.EventAdd()" on the script to force the refresh but didn't worked, someone know what I'm missing to get a proper update of the field when I move the camera?
You will find the demo file below, thanks a lot.