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

Method _subloc

cadquery/assembly.py:357–378  ·  view source on GitHub ↗

Calculate relative location of an object in a subassembly. Returns the relative positions as well as the name of the top assembly.

(self, name: str)

Source from the content-addressed store, hash-verified

355 return name, val if isinstance(val, Shape) else None
356
357 def _subloc(self, name: str) -> Tuple[Location, str]:
358 """
359 Calculate relative location of an object in a subassembly.
360
361 Returns the relative positions as well as the name of the top assembly.
362 """
363
364 rv = Location()
365 obj = self.objects[name]
366 name_out = name
367
368 if obj not in self.children and obj is not self:
369 locs = []
370 while not obj.parent is self:
371 locs.append(obj.loc)
372 obj = cast(Assembly, obj.parent)
373 name_out = obj.name
374
375 # This must reduce in the order of (parent, ..., child)
376 rv = reduce(lambda l1, l2: l2 * l1, locs)
377
378 return (rv, name_out)
379
380 @overload
381 def constrain(

Callers 1

constrainMethod · 0.95

Calls 2

LocationClass · 0.85
appendMethod · 0.80

Tested by

no test coverage detected