Search elements of a certain type
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 23/05/2011 at 09:36, xxxxxxxx wrote:
Hy there,
what function can I use to check for a certain type of object?
I tried CheckType, GetType(), GetName() ...I want to recourse over the hierarchy and put all matching objects into a list (say, all Sweep NURBS).
The following will fail:
import c4d
sweeps = []def getSweeps(obj) :
global sweeps
if obj == None: returnif obj.CheckType(c4d.Osweep) :
sweeps.append(obj)
print "obj: "+ str(obj)if obj.GetDown() : getSweeps(obj.GetDown)
if obj.GetNext() : getSweeps(obj.GetNext)def main() :
global resetreset = False
print "Impulses: "+getSweeps(obj.GetDown())
Error is:
obj: <c4d.SplineObject object at 0x0000000015F8D3B0>
Traceback (most recent call last) :
File "<Python>", line 27, in main
File "<Python>", line 18, in getSweeps
File "<Python>", line 12, in getSweeps
AttributeError: 'builtin_function_or_method' object has no attribute 'CheckType'BTW. I have this Python code in a XPresso Tag on top of the hierarchy I want to parse.
Thank you,
maxx -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 23/05/2011 at 09:45, xxxxxxxx wrote:
You pass a method in your code: getSweeps(obj.GetDown) -> getSweeps(obj.GetDown () )
Btw, I recommend you to avoid global variables if possible.
import c4d def getSweeps(obj, sweeps) : if obj == None: return if obj.CheckType(c4d.Osweep) : sweeps.append(obj) print "obj: "+ str(obj) getSweeps(obj.GetDown(),sweeps) getSweeps(obj.GetNext(),sweeps) def main() : obj=op sweeps=[] getSweeps(obj.GetDown(), sweeps) print sweeps
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 23/05/2011 at 10:00, xxxxxxxx wrote:
... ...
I am so used to Java IDEs ... don't see the simple things anymore ... now I also understand the Traceback ...
Thanx,
maxx