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)
| 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( |