Hello @bentraje
@bentraje said in How to Use ListAllNodes?:
doc: c4d.documents.BaseDocument # The active document.
I'm not too familiar with the Python 3 syntax but this line returns an empty graph down the line.
Tha is a bit odd, especially since I tested and ran the code with R25. This line or code such as below
# Without type hinting.
def foo(a):
return f"{a}"
# With type hinting.
def foo(a: typing.Any) -> str:
return f"{a}"
makes use of type hinting. It tries to rectify ambiguities that come with the fact that Python is dynamically typed. For now, type hinting has no real impact on code run on CPython (i.e., the "standard" Python), unless you use special libraries to run your CPython code or use interpreters other than CPython which support static or at least asserted typing out of the box.
All the line
doc: c4d.documents.BaseDocument # The active document.
does for now is:
Make code more readable by telling humans what the module attribute doc is and that it exists in the first place.
Enable auto-complete engines as provided by, for example, VSCode to give you smart suggestions.
Enable linters or runtime libraries to run type assertions on your code.
Adding or removing this line should have zero impact on the execution, unless you added there an equals sign and overwrote the value of doc.
Cheers,
Ferdinand