get base object input ID for link fields
-
On 24/01/2017 at 04:54, xxxxxxxx wrote:
Hello,
I know it is possible to find the designation of most input fields for base objects by observing the Script Log.
By manipulating the field, e.g. incrment value, the script log shows the id of what was just changed. This seems like a great way to access and manipulate user data and manipulating existing data fields.
This works with all input fields I've tried so far apart from link fields, for example the stage object, I cannot identify the designation for camera input.
I can't seem to find it in documentation either.. is there another way to find out this kind of information? -
On 24/01/2017 at 05:44, xxxxxxxx wrote:
You can simply do
Stage[c4d.STAGEOBJECT_CLINK] = MyCamera c4d.EventAdd()
For knowing such element you can grab it to the console (shift + F10)
-
On 24/01/2017 at 07:10, xxxxxxxx wrote:
Wow that's an extremely helpful bit of info I needed!
So do link fields like this require the object name (string) or the object itself? I assume nameThank you very much.
-
On 24/01/2017 at 07:19, xxxxxxxx wrote:
No, in case of the stage object it only accept any Obase object.
That mean any BaseList2D node wich is an object.
As you can see if you drop and down any object into the console and then add ".GetClassification()" you will see a number (5155, wich is egal to c4d.Obase).
So any objects who belong to this classification can be filled. -
On 25/01/2017 at 08:24, xxxxxxxx wrote:
thanks again, this is extremely useful to know!
-
On 25/01/2017 at 08:31, xxxxxxxx wrote:
Hi,
I'm aware in Python it's a bit different, but I still think it might shed some light to know, that internally the content of the link field is stored as a BaseLink (C++ manual, C++ API reference), the name does not come into play, wouldn't work that well either (imagine a user naming everything identically).
I'm not sure, if you are also interested in finding out, which types of entities are allowed in a certain link field. This can be found out by taking a look at the description.
Like so:# in the following code tag is a Contraint tag desc = tag.GetDescription(c4d.DESCFLAGS_DESC_0) bcDesc = desc.GetParameterI(c4d.DescID(30001), None) # 30001: ID of Target in Constraint tag (parent mode) bcTypesAccepted = bcDesc[c4d.DESC_ACCEPT] # there's also the opposite DESC_REFUSE for index, value in bcTypesAccepted: print "Index: %i, Value: %s" % (index, str(value))
-
On 25/01/2017 at 09:18, xxxxxxxx wrote:
Hi Andreas,
You have really confused me..
How did you ascertain the ID of the Target field?
I don't understand your method compared to gr4ph0s .GetClassification() approach.How are you both able to look up these IDs like 5155 and 30001, I don't see them in the documentation anywhere..
-
On 25/01/2017 at 10:57, xxxxxxxx wrote:
I'm sorry, it wasn't my intention to confuse you.
The ID of the target field you can easily find out by simply dragging the name of the target parameter to the input field of the console, just like gr4ph0s suggested earlier.And the code I posted, was not intended to replace gr4ph0s code. I thought, you were also interested in finding out, which types of objects/entities were accepted by a certain link parameter. That's what my code snippet is for. It prints all accepted type IDs to the console. If you do not care about this info, then just ignore my code snippet.
One more about the IDs:
The 5155 is the ID of BaseObject (c4d.Obase) and like gr4ph0s explained above:
Open the Console window (from the Script menu), there you have an input field, which can be used to directly write Python code. Now, when you drag an object (or material or tag... whatever) into this input field, you will get this object in there (drag a Cube in there, it will say "Cube"). The point is, it's as if you have a variable in your Python code representing this object. Now, just complete the Python command. Like suggested above by adding .GetClassification() or .GetType() and press return. The Python command will be executed and the result will be printed to the console, providing you with the type ID of this object.Similarly it works for almost every parameter in C4D. Drag the parameter into the input field of the console and it will automatically provide you with a line to access that parameter, e.g. Cube[c4d.PRIM_CUBE_LEN]. Simply press return and the value of the given parameter is printed to the console. Not for all parameters you get the "named representation", but like in the Constraint tag case, you will simply get the numeric ID. So if you drag the name "Target" of the target link field of the constraint tag to the Console input field, you get: Constraint[30001]
-
On 26/01/2017 at 04:38, xxxxxxxx wrote:
Please, its fine, I am easily confused as this is all new to me.
I see what you mean now, I actually meant that I do not know how you derive the meaning (object type) from the ID numbers, I understood that .GetClassification() is used to get the ID, but as gr4ph0s said originally:
"add ".GetClassification()" you will see a number (5155, wich is egal to c4d.Obase )"
What I should have said was, how do ascertain the number is equal to c4d.Obase?But I think you have answered that by also letting me know about .GetType()
I see what you mean now.
I wanted to try your code but with the Stage object instead of your tag example, I got an error at the line:
bcDesc = desc.GetParameterI(c4d.DescID(5155), None)
"TypeError: 'NoneType' object has no attribute '__getitem__'"full code (in a python tag on a stage object) :
import c4d
stageObj = op.GetObject()
desc = stageObj.GetDescription(c4d.DESCFLAGS_DESC_0)
bcDesc = desc.GetParameterI(c4d.DescID(5155), None) # to get ID drag param to console and append .GetType()
bcTypesAccepted = bcDesc[c4d.DESC_ACCEPT] # there's also the opposite DESC_REFUSEdef main() :
frame = doc.GetTime().GetFrame(doc.GetFps())
stageObj[c4d.STAGEOBJECT_CLINK] = cam(frame)
for index, value in bcTypesAccepted:
print "Index: %i, Value: %s" % (index, str(value))
def cam(frm) :
childs = stageObj.GetChildren()
return childs[frm%len(childs)]