Some stuff regarding classes, i do right now.
Does anybody have some practical use regarding architecture?
I have these small examples:
from Autodesk.DesignScript.Geometry import *
#The inputs to this node will be stored as a list in the IN variables.
name = IN
age = IN
def init(mysillyobject, name, age):
mysillyobject.name = name
mysillyobject.age = age
return ("Hello my name is " + abc.name)
p1 = Person(name, age)
OUT = p1.myfunc()
How can I use that for lists? And for what can I use that in my projects?
class.dyn (13.7 KB)
I really like Coreys tutorials. Here’s one of them on Python classes. https://www.youtube.com/watch?v=ZDa-Z5JzLYM
The short story is - if you have no idea what Python class is and how you could use one - you probably do not need to use them as for now. Learning Python is still the way to go.
A common application of classes is in object-oriented programming (OOP). Much of how you already interact with the Revit API uses similar concepts (methods and properties). See below:
def __init__(self, name, age):
self.name = name
self.age = age
def is_older(self, age):
"""Determines whether person is older than a given age.
age (int): Age to compare against, in years.
bool: True if Person is older than the given age.
return self.age > age
names = IN
ages = IN
# Construct our Person objects
people = [Person(name, age) for name, age in zip(names, ages)]
test = 
for p in people:
# Test whether each person is older than 40 years old.
OUT = test
make a new topic! than you get an answer very fast
You need to instantiate the class rather than simply passing the class itself. i.e.
OUT should be
MyClass() rather than
MyClass. Both of the following are valid (although the first is a better approach):
Thanks you. I noticed that after my attempts. LOL