Finds the root element of the given scope and returns it. This function allows the access to a nested scope that is a child of this element. The `scope_identifier` argument specifies the path to the child scope element. Args: scope_identifier: The path of the desired scope el
(self, scope_identifier)
| 498 | return out |
| 499 | |
| 500 | def enter_scope(self, scope_identifier): |
| 501 | """Finds the root element of the given scope and returns it. |
| 502 | |
| 503 | This function allows the access to a nested scope that is a child of this |
| 504 | element. The `scope_identifier` argument specifies the path to the child |
| 505 | scope element. |
| 506 | |
| 507 | Args: |
| 508 | scope_identifier: The path of the desired scope element. |
| 509 | |
| 510 | Returns: |
| 511 | An `mjcf.Element` object, or `None` if a scope element with the |
| 512 | specified path is not found. |
| 513 | """ |
| 514 | if constants.PREFIX_SEPARATOR in scope_identifier: |
| 515 | scope_name = scope_identifier.split(constants.PREFIX_SEPARATOR)[0] |
| 516 | try: |
| 517 | attachment = self.namescope.get('attached_model', scope_name) |
| 518 | except KeyError: |
| 519 | return None |
| 520 | |
| 521 | scope_suffix = scope_identifier[(len(scope_name) + 1):] |
| 522 | if scope_suffix: |
| 523 | return attachment.enter_scope(scope_suffix) |
| 524 | else: |
| 525 | return attachment |
| 526 | else: |
| 527 | try: |
| 528 | return self.namescope.get('attached_model', scope_identifier) |
| 529 | except KeyError: |
| 530 | return None |
| 531 | |
| 532 | def _check_valid_attribute(self, attribute_name): |
| 533 | if attribute_name not in self._spec.attributes: |