THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 13/08/2011 at 18:22, xxxxxxxx wrote:
I got the number 51 by printing ID's of the MoText object in increments of ten. Then once I got a return value of -1. I knew where the end of the container was.
The reason I did that was because I forgot how to iterate through a container at the time. And rather than look it up in my notes. I just wrote the loop that way as a crutch for my poor memory.
Here's a different (more proper) way to write it using "len" as a way to automatically count the number of container entries:
from c4d import gui
def main() :
op = doc.GetActiveObject()
bc = op.GetData()
while i < len(bc) :
index = bc.GetIndexId(i)
elementType = bc.GetType(index)
print "Index: %i, Type: %i" % (index, elementType)
If Sebastian has set up the ID's for an object. Using value in a loop will work.
But in this case. He hasn't done that yet. So all we get in return are ID numbers.
You can drag each one into the console one at a time. But since the MoText object has lots of items in it. It's faster to get one of the names. Then search for the .h file it belongs to and get the other ID's names and numbers.
When writing plugins with C++. We have to do that kind of searching for .h files a lot to include them in our code. So I've gotten used to doing that.
It's not something you'd typically have to do in Python that much.