Awesome, Thank you so much @m_adam !
Cheers and best regards
Ben
Awesome, Thank you so much @m_adam !
Cheers and best regards
Ben
Hi I just wanted to follow up and ask if this will be fixed any time soon?
Its not super urgent but this bug is putting a project of mine on hold where I want to pull a rig (with several python tags on spline control objects) from the asset browser with a script. For the moment its not a problem to do it manually though but I would love to automate this.
Cheers Ben
Hi @bentraje I just came across this thread and quickly tested the above script in 2024. It still works as expected.
Without any further knowledge I would assume that A) you dont have a xpresso tag on your object or B) its not the the second tag on your object.
Hello^^
I am experiencing a weird, but very specific behaviour in c4d 2024:
When I try to load a Spline Object with a Python Tag attached to it from the Asset Browser via a python script, Cinema 4D 2024 gets stuck. But this happens only with Spline Object and only in 2024. I tried it with a Null Object as well with a Polygon Object and those are loading fine.
In Cinema 4D 2023 there is no issue. all three Objects (Spline, Null and Polygon) get loaded with the script and manually loading the Asset by double clicking it in the Asset Browser is also no problem in both versions. Could this be simply a bug?
Here is a small video to show you the behaviour in both R 2023 and R 2024.
The script I used is a striped down version from one of the example scripts on github.
Thank you in advance for your time!
Oh wow! Thank you so much!
Yes I'm a beginner with python cinema 4D so I really appreciate your support and this definitly gives me a better understanding of the node structure.
Hello,
I have a RS standard Material with one texture node inside of it, linking to a texture file. Now I want to add additional texture nodes/files based on the file location of the original texture node with python.
I know how to add additional nodes but before I can do that I need to retrieve the value of the 'filename' port of the original texture node. (com.redshift3d.redshift4c4d.nodes.core.texturesampler.tex0)
Through some examples here on the forum I figured out how to get the value of the name but I'm not able to get the filepath.
here is a small part of my script where I try to print the name and the filepath of the texture node:
from typing import Optional
import c4d
import maxon
doc: c4d.documents.BaseDocument # The active document
op: Optional[c4d.BaseObject] # The active object, None if unselected
def GetFileAssetUrl(aid: maxon.Id):
# Bail when the asset ID is invalid.
if not isinstance(aid, maxon.Id) or aid.IsEmpty():
raise RuntimeError(f"{aid = } is not a valid asset ID")
# Get the user repository, a repository which contains almost all assets, and try to find the
# asset description, a bundle of asset metadata, for the given asset ID in it.
repo = maxon.AssetInterface.GetUserPrefsRepository()
if repo.IsNullValue():
raise RuntimeError("could not access the user repository")
asset = repo.FindLatestAsset(
maxon.AssetTypes.File(), aid, maxon.Id(), maxon.ASSET_FIND_MODE.LATEST)
if asset.IsNullValue():
raise RuntimeError(f"Could not find file asset for {aid}.")
# When an asset description has been found, return the URL of that asset in the "asset:///"
# scheme for the latest version of that asset.
return maxon.AssetInterface.GetAssetUrl(asset, True)
def GetAllMaterials():
materials = []
# Get the active document
doc = c4d.documents.GetActiveDocument()
# Get the material manager
materialManager = doc.GetMaterials()
# Iterate through all materials in the material manager
for mat in materialManager:
materials.append(mat)
return materials
def main() -> None:
# Get the list of all materials in the Material Manager
mat_all = GetAllMaterials()
material = None
for mat in mat_all:
if mat.GetName() == "MatTest":
material = mat
if material is not None:
idTextureNode = maxon.Id("com.redshift3d.redshift4c4d.nodes.core.texturesampler")
# Get the RS node graph of the Material
nodeMaterial = material.GetNodeMaterialReference()
graph = nodeMaterial.GetGraph(
maxon.Id("com.redshift3d.redshift4c4d.class.nodespace"))
if graph.IsNullValue():
raise RuntimeError("could not get RS graph of the imported material")
texResult = []
maxon.GraphModelHelper.FindNodesByAssetId(graph, idTextureNode, True, texResult)
# print the texturesampler node name and the texture file path
for tex in texResult:
print("Name: "+ str(tex.GetValue(maxon.NODE.BASE.NAME)))
print("Path: "+ str(tex.GetValue("com.redshift3d.redshift4c4d.nodes.core.texturesampler.tex0")))
else:
print("Cant find Material")
print(" ")
c4d.EventAdd()
if __name__ == '__main__':
main()
Maybe someone here can point me in the right direction?
Thanks in advance for your time!
ah ok I figured it out. its possible to check those with the c4d.IsCommandChecked() function.
Hello,
I'm trying to figure out a way to check the state of the record modes (position, scale, rotation, parameters, pla) located under the 'animate -> record(modes)' menu with python?
I've already done a extensiv search in the documentation but could not find anything. Maybe someone has an idea and can push me in the right direction?
I know how to toggle the modes with c4d.CallCommand() but I want to check the state before toggeling.
Thank you in advance!