2D sketch. Supports faces, edges and edges with constraints based construction.
| 131 | |
| 132 | |
| 133 | class Sketch(object): |
| 134 | """ |
| 135 | 2D sketch. Supports faces, edges and edges with constraints based construction. |
| 136 | """ |
| 137 | |
| 138 | parent: Any |
| 139 | locs: List[Location] |
| 140 | |
| 141 | _faces: Compound |
| 142 | _edges: List[Edge] |
| 143 | |
| 144 | _selection: Optional[List[SketchVal]] |
| 145 | _constraints: List[Constraint] |
| 146 | |
| 147 | _tags: Dict[str, Sequence[SketchVal]] |
| 148 | |
| 149 | _solve_status: Optional[Dict[str, Any]] |
| 150 | |
| 151 | def __init__( |
| 152 | self: T, |
| 153 | parent: Any = None, |
| 154 | locs: Iterable[Location] = (Location(),), |
| 155 | obj: Optional[Compound] = None, |
| 156 | ): |
| 157 | """ |
| 158 | Construct an empty sketch. |
| 159 | """ |
| 160 | |
| 161 | self.parent = parent |
| 162 | self.locs = list(locs) |
| 163 | |
| 164 | self._faces = obj if obj else Compound.makeCompound(()) |
| 165 | self._edges = [] |
| 166 | |
| 167 | self._selection = None |
| 168 | self._constraints = [] |
| 169 | |
| 170 | self._tags = {} |
| 171 | |
| 172 | self._solve_status = None |
| 173 | |
| 174 | def __iter__(self) -> Iterator[Face] | Iterator[Edge]: |
| 175 | """ |
| 176 | Iterate over faces-locations combinations. If not faces are present |
| 177 | iterate over edges: |
| 178 | """ |
| 179 | |
| 180 | if self._faces: |
| 181 | return iter(f for l in self.locs for f in self._faces.moved(l).Faces()) |
| 182 | else: |
| 183 | return iter(e.moved(l) for l in self.locs for e in self._edges) |
| 184 | |
| 185 | def _tag(self: T, val: Sequence[SketchVal], tag: str): |
| 186 | |
| 187 | self._tags[tag] = val |
| 188 | |
| 189 | # face construction |
| 190 | def face( |
no outgoing calls