Hi Ilia,
Thank you very much, I was not aware of that!
Cheers!
Hi Ilia,
Thank you very much, I was not aware of that!
Cheers!
Hello,
I am running the following code to create a vertex map tag on an object (targetObject is a sphere BaseObject every time I call the function):
# Make object editable
res = c4d.utils.SendModelingCommand(
command = c4d.MCOMMAND_MAKEEDITABLE,
list = [targetObject],
mode = c4d.MODELINGCOMMANDMODE_ALL,
doc = doc )
if res is False or res is True:
raise TypeError()
elif isinstance( res, list ):
doc.InsertObject( res[0] )
vertexMapTag = res[0].GetTag( c4d.Tvertexmap )
if vertexMapTag is None:
vertexMapTag = c4d.BaseTag( c4d.Tvertexmap )
vertexMapTag[c4d.ID_TAGFIELD_ENABLE] = True
vertexMapTag[c4d.ID_TAGFIELD_INVERT] = False
vertexMapTag[c4d.ID_TAGFIELD_DEFORMED] = False
res[0].InsertTag( vertexMapTag )
c4d.EventAdd()
After running this I get a sphere with a UVW tag and a vertex map tag, as intended. However, when I select the sphere and select the paint tool, I get the following error:
What is causing the tag to not be in sync?
Thank you for your help,
Daniel
Hey Ferdinand, thanks again for the quick reply.
What we're going to do is basically have a "cache" location, as you said, where we will save the users' textures when they bake the stack. I would also prefer the approach you showed using the document's asset repository, but since the textures might be very heavy, it would probably lead to very large document sizes for a lot of users, especially if they use several textures/have several stacks with textures. I'm working on implementing solution 1.1, using the Message system to move things around. However, thank you very much for the code example, I will probably use something similar with other assets that are not as large as textures.
Cheers,
Daniel
Hi Ferdinand and Maxime,
I think I was unclear when asking the last question, my bad. I get that the issue would be that we would essentially have a Filename
that does not resolve if the image was in working memory (using a RamDisk
or a MemoryFileStruct
) and then shut down and re-launched Cinema 4D. I was originally wondering if we could trigger a function (probably using the modifier Message
function) when saving the scene to save the image on the physical disk at that point, and change the Filename
in the shader accordingly. However we've decided not to try putting the image in memory at all, and directly save it to the disk. I'll try to explain what we're trying to achieve so the situation is a bit clearer, I would love your input on this.
We currently have an object consisting of a stack that performs computations. We are implementing functionality so that the entire stack can be baked into a single object, which helps speed up computations. The collapse is reversible, so we want the user to be able to "unbake" the object. We also want the user to be able to save the stack to the physical disk as a "baked" object. If one of the objects in the stack (let's call it object A) uses a texture, we save the texture as an image with the baked object. We essentially serialize the image and use it in the calculations, then save it to the physical disk. However, if the user "unbakes" the object, we need to take the serialized image and generate a texture for object A to use. The texture could be an image found on the disk, a gradient created in C4D, some procedurally generated image, etc.
What we are currently considering is to simply save the texture as an image at the moment that the stack is baked, and use a Filename
pointing to it if the stack is unbaked. However, if the scene had not been saved before, we would have to create the image as a temp file and copy it to wherever the scene is saved on the disk afterwards. Is there something I might be missing in the Cinema 4D SDK that could improve this approach, or even be a better way to handle the situation?
Thanks a lot for the help,
Daniel
Hi Ferdinand,
Thank you very much for the answer! Don't worry about it, I was also dealing with other tasks in the interim. The volatility might be an issue, we might have to write manual code to save scenes if necessary. That would just involve saving the image file somewhere on the actual disk and changing the where the shader points to, right?
Thank you for the example, I'll work on implementing something similar in our code and get back to you if anything comes up.
Cheers,
Daniel
Hi @m_adam,
I've been trying to use a RamDiskInterface
to store the images I need in memory, but I can't see a way to create a file using it. I can see the CreateLazyFile method, but that's not available before C4D 2024, and I need support back to R25. I am looking into MemoryFileStruct and it seems promising, I was just wondering if the RamDiskInterface
is preferred when creating multiple files in memory.
Cheers,
Daniel Bauer
Hi Maxime,
Thank you very much for the answer! Sorry I haven't responded in a while, some other issues came up. I'll try using the method you mentioned, the image structure should not be a problem because we save images already generated in Cinema 4D. I'll get back to you once I get a chance to implement it.
Thanks again,
Daniel
Hi,
In our plugin we generate images which we would like to use as texture maps in our modifiers. I've been following the BaseShader
manual and can see that I can create a Bitmap Shader and populate the bitmap with a file:
// configure the bitmap shader and the material
bitmapShader>SetParameter(ConstDescID(DescLevel(BITMAPSHADER_FILENAME)), imageFile, DESCFLAGS_SET::NONE);
(This is from the C4D documentation). I was wondering if it's possible to populate the BaseShader
bitmap without saving the image to the disk.
Thank you very much,
Daniel
Hi Maxime, thank you very much for your answer! I wasn't sure if storing things in the global document BaseContainer was a good approach, but it's working well.
Cheers,
Daniel
Hello,
I have a command plugin that inherits from CommandData, defined and registered in C++. I am trying to create a Python script which calls this command plugin, but I want to pass data to it so it can use that data in its Execute()
function. I can modify the class in C++ if necessary. Can I do this in Python? I know I can pass data using the Message()
function, but have not found a way to use that from Python.
Thank you for the help,
Daniel