@i_mazlov This is very useful as it helps avoid manually inputting hard-coded index values! Thank you, and have a great day!
O
Posts made by Oliver
-
RE: How to gracefully obtain the number of targets in a constraint tag?
-
How to gracefully obtain the number of targets in a constraint tag?
Hello all, I need to dynamically obtain the number of Targets in a Constraint tag. I couldn't find a 'Constraint tag' class, and the BaseTag class offers very limited functionality. I had to try retrieving the information from the container. Fortunately, the container contains the data I need. However, I'm curious if there's a more elegant solution beyond using the container?
import c4d def getTargetCount(tag) -> int: tagData = tag.GetDataInstance() count = 0 startIndex = 10002 while True: if tagData.GetData(startIndex) is None: break count += 1 startIndex += 10 return count def main(): tag = doc.GetSelection()[0] print(getTargetCount(tag)) if __name__ == '__main__': main()
-
How to hide an object's native attributes
Hello all, I would like to know if C4D can hide an object's native attributes (e.g., hiding the Object tab of a spline object). This would help avoid unnecessary attributes when selecting the corresponding controllers while animating, thus improving efficiency. In the following code, I found that SetParameter doesn't work. I can only hide custom user data attributes
import c4d def main(): obj = op description = obj.GetDescription(c4d.DESCFLAGS_DESC_NONE) doc.StartUndo() for bc, paramId, groupId in description: if bc[c4d.DESC_NAME] == 'Object Properties': doc.AddUndo(c4d.UNDOTYPE_CHANGE, obj) print(bc[c4d.DESC_HIDE]) # return None bc[c4d.DESC_HIDE] = False obj.SetParameter(groupId, bc, c4d.DESCFLAGS_SET_NONE) # obj.SetUserDataContainer(groupId, bc) # hide userData attr obj.Message(c4d.MSG_CHANGE) doc.EndUndo() c4d.EventAdd() if __name__ == '__main__': main()