MCPcopy
hub / github.com/CadQuery/cadquery / Sketch

Class Sketch

cadquery/sketch.py:133–1382  ·  view source on GitHub ↗

2D sketch. Supports faces, edges and edges with constraints based construction.

Source from the content-addressed store, hash-verified

131
132
133class 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(

Callers 15

showablesFunction · 0.90
skFunction · 0.90
test_styleFunction · 0.90
test_face_interfaceFunction · 0.90
test_modesFunction · 0.90
test_distributeFunction · 0.90
test_rarrayFunction · 0.90
test_parrayFunction · 0.90
test_eachFunction · 0.90
test_modifiersFunction · 0.90
test_deleteFunction · 0.90
test_selectorsFunction · 0.90

Calls

no outgoing calls

Tested by 15

showablesFunction · 0.72
skFunction · 0.72
test_styleFunction · 0.72
test_face_interfaceFunction · 0.72
test_modesFunction · 0.72
test_distributeFunction · 0.72
test_rarrayFunction · 0.72
test_parrayFunction · 0.72
test_eachFunction · 0.72
test_modifiersFunction · 0.72
test_deleteFunction · 0.72
test_selectorsFunction · 0.72