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

Function display

cadquery/occ_impl/jupyter_tools.py:164–194  ·  view source on GitHub ↗
(shape)

Source from the content-addressed store, hash-verified

162
163
164def display(shape):
165
166 payload: List[Dict[str, Any]] = []
167
168 if isinstance(shape, Shape):
169 shape_edges, shape_faces = toString(shape)
170
171 payload.append(
172 dict(
173 shape=shape_edges,
174 color=(0.0, 0.0, 0.0, 1.0),
175 position=[0, 0, 0],
176 orientation=[0, 0, 0],
177 )
178 )
179 payload.append(
180 dict(
181 shape=shape_faces,
182 color=DEFAULT_COLOR + (1,),
183 position=[0, 0, 0],
184 orientation=[0, 0, 0],
185 )
186 )
187 elif isinstance(shape, Assembly):
188 payload = toJSON(shape)
189 else:
190 raise ValueError(f"Type {type(shape)} is not supported")
191
192 code = TEMPLATE.format(data=dumps(payload), element="element", ratio=0.5)
193
194 return Javascript(code)

Callers 3

test_display_errorMethod · 0.90
_repr_javascript_Method · 0.85
_repr_javascript_Method · 0.85

Calls 3

toStringFunction · 0.85
toJSONFunction · 0.85
appendMethod · 0.80

Tested by 1

test_display_errorMethod · 0.72