Skip to content

Commit 98e741e

Browse files
committed
Added a traits dictionary on OpenSCADObject. This is used to collect information for solid.utils.bill_of_materials()`, but could be used for other metadata storage.
1 parent 2adc937 commit 98e741e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

solid/solidpython.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from typing import Set, Sequence, List, Callable, Optional, Union, Iterable
2222

2323
from types import ModuleType
24-
from typing import Callable, Iterable, List, Optional, Sequence, Set, Union
24+
from typing import Callable, Iterable, List, Optional, Sequence, Set, Union, Dict
2525

2626
import pkg_resources
2727
import regex as re
@@ -52,6 +52,13 @@ def __init__(self, name: str, params: dict):
5252
self.is_hole = False
5353
self.has_hole_children = False
5454
self.is_part_root = False
55+
self.traits: Dict[str, Dict[str, float]] = {}
56+
57+
def add_trait(self, trait_name:str, trait_data:Dict[str, float]):
58+
self.traits[trait_name] = trait_data
59+
60+
def get_trait(self, trait_name:str) -> Optional[Dict[str, float]]:
61+
return self.traits.get(trait_name)
5562

5663
def set_hole(self, is_hole: bool = True) -> "OpenSCADObject":
5764
self.is_hole = is_hole

0 commit comments

Comments
 (0)