get lamp attributes?
-
I would like to call and get the attributes returned for a redshiftlamp.
In Maya it is close to this.
selectedobject.getattr('intensity')
which will return me5
How would I approach this in Python for Cinema, I need to do this for almost all the attributes.
My thanks!
-
Hello there and welcome to the plugincafe,
since you didn't specify what language you want to use, here's a link to the C++ manual.
You should go withGetParameter()
: See here and here
This blog post might also help you: [URL-REMOVED]Please consider adding appropriate tags to your post and flag it as a question.
[URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.
-
Hello mp5,
Thanks for the info, I assumed only Python was available.
Edited the question and marked it -
In Python, it's actually more convenient. You simply access them like this:
Example is a cube, we want its X-size:
Cube[c4d.PRIM_CUBE_LEN,c4d.VECTOR_X]
You can simply drag an object's parameter into the command line of the console or the console itself. It then shows you the parameter names.
That is the most simple and easiest way.
However, that might not always work depending on what you want to read, so you have to use BaseContainer or GetParameter() as well.Oh and may I kindly ask you for tagging this thread correctly? It makes it easier to search the forums, so other users can benefit from your question.
https://developers.maxon.net/forum/topic/10953/how-to-post-questions -
@mp5gosu
Thanks for the example. but I still don't get the syntax right
any introduction maybe to read on? this seems super basic...
If I drag in a parameter from a cube, let's keep using X.cube = doc.GetActiveObjects(0) x = cube[c4d.PRIM_CUBE_LEN,c4d.VECTOR_X]
returns nothing. ('of course' probably) and the selected cube will not take
GetParameter
since it's a baseobjects and not a C4D.Atom class.
butx = c4d.C4DAtom()
is not allowed to be instantiatededit:
got it working. forum got's loads of answered question wich gave good insight. thanks -
The syntax is python, so you can look it up here.
There's of course a lot of stuff to get your hands on. Here you will find the official SDK documentation with lots of examples on GitHub to help getting started.Your code didn't work, because you did not access the returned list correctly.
The correct way would be:cube = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_0)[0] # note: It is better to write out flags and not set the Ints directly. More readable and less error-prone to API changes.
You can read it up here: GetActiveObjects()
You may want to consider using GetActiveObject(), which returns the current active object only (Returns
None
in case of multiple objects - see docs). -
Hi,
@Jvos it looks like your question got answered. Afterwards you deleted this thread. I'd like to ask you not to do so. This forum is all about sharing knowledge. There are no stupid questions and nothing to be ashamed about. Every answered question might help a future developer.
I have moved this thread into the Cinema 4D Development category.
Cheers,
Andreas