1+ class Attribute :
2+ """
3+ A class that represents named attributes, providing methods for accessing and storing them.
4+
5+ Create an attribute with a name, data type, and optional domain.
6+ ```python
7+ height_level = Attribute(
8+ "height_level",
9+ NamedAttribute.DataType.FLOAT,
10+ StoreNamedAttribute.Domain.POINT # optional
11+ )
12+ ```
13+
14+ Access the attribute value by calling the class instance.
15+ ```python
16+ height_level()
17+ ```
18+
19+ Store a value for the named attribute on some geometry with `store(...)`.
20+ ```python
21+ height_level.store(geometry, value)
22+ ```
23+
24+ Check if the attribute exists on some geometry with `exists()`.
25+ ```python
26+ selection = height_level.exists()
27+ ```
28+ """
29+ name : str
30+ data_type : 'NamedAttribute.DataType'
31+ domain : 'StoreNamedAttribute.Domain'
32+
33+ def __init__ (
34+ self ,
35+ name : str ,
36+ data_type : 'NamedAttribute.DataType' ,
37+ domain : 'StoreNamedAttribute.Domain' = 'POINT'
38+ ):
39+ self .name = name
40+ self .data_type = data_type
41+ self .domain = domain
42+
43+ def __call__ (self , * args , ** kwargs ):
44+ """
45+ Creates a "Named Attribute" node with the correct arguments passed, and returns the "Attribute" socket.
46+ """
47+ from geometry_script import named_attribute
48+ return named_attribute (data_type = self .data_type , name = self .name , * args , ** kwargs ).attribute
49+
50+ def exists (self , * args , ** kwargs ):
51+ """
52+ Creates a "Named Attribute" node with the correct arguments passed, and returns the "Exists" socket.
53+ """
54+ from geometry_script import named_attribute
55+ return named_attribute (data_type = self .data_type , name = self .name , * args , ** kwargs ).exists
56+
57+ def store (self , geometry : 'Geometry' , value , * args , ** kwargs ) -> 'Geometry' :
58+ """
59+ Creates a "Store Named Attribute" node with the correct arguments passed, and returns the modified `Geometry`.
60+ """
61+ from geometry_script import store_named_attribute
62+ return store_named_attribute (
63+ data_type = self .data_type ,
64+ domain = self .domain ,
65+ geometry = geometry ,
66+ name = self .name ,
67+ value = value ,
68+ * args ,
69+ ** kwargs
70+ )
0 commit comments