Nested assembly of Workplane and Shape objects defining their relative positions.
| 94 | |
| 95 | |
| 96 | class Assembly(object): |
| 97 | """Nested assembly of Workplane and Shape objects defining their relative positions.""" |
| 98 | |
| 99 | loc: Location |
| 100 | name: str |
| 101 | color: Optional[Color] |
| 102 | material: Optional[Material] |
| 103 | metadata: Dict[str, Any] |
| 104 | |
| 105 | obj: AssemblyObjects |
| 106 | parent: Optional["Assembly"] |
| 107 | children: List["Assembly"] |
| 108 | |
| 109 | objects: Dict[str, "Assembly"] |
| 110 | constraints: List[Constraint] |
| 111 | |
| 112 | # Allows metadata to be stored for exports |
| 113 | _subshape_names: BiDict[Shape, str] |
| 114 | _subshape_colors: BiDict[Shape, Color] |
| 115 | _subshape_layers: BiDict[Shape, str] |
| 116 | |
| 117 | _solve_result: Optional[Dict[str, Any]] |
| 118 | |
| 119 | def __init__( |
| 120 | self, |
| 121 | obj: AssemblyObjects = None, |
| 122 | loc: Optional[Location] = None, |
| 123 | name: Optional[str] = None, |
| 124 | color: Optional[Color] = None, |
| 125 | material: Optional[Material] = None, |
| 126 | metadata: Optional[Dict[str, Any]] = None, |
| 127 | ): |
| 128 | """ |
| 129 | construct an assembly |
| 130 | |
| 131 | :param obj: root object of the assembly (default: None) |
| 132 | :param loc: location of the root object (default: None, interpreted as identity transformation) |
| 133 | :param name: unique name of the root object (default: None, resulting in an UUID being generated) |
| 134 | :param color: color of the added object (default: None) |
| 135 | :param material: material (for visual and/or physical properties) of the added object (default: None) |
| 136 | :param metadata: a store for user-defined metadata (default: None) |
| 137 | :return: An Assembly object. |
| 138 | |
| 139 | |
| 140 | To create an empty assembly use:: |
| 141 | |
| 142 | assy = Assembly(None) |
| 143 | |
| 144 | To create one constraint a root object:: |
| 145 | |
| 146 | b = Workplane().box(1, 1, 1) |
| 147 | assy = Assembly(b, Location(Vector(0, 0, 1)), name="root") |
| 148 | |
| 149 | """ |
| 150 | |
| 151 | self.obj = obj |
| 152 | self.loc = loc if loc else Location() |
| 153 | self.name = name if name else str(uuid()) |
no outgoing calls