# Changing Context with the API

**URL:** <https://forums.sketchup.com/t/changing-context-with-the-api/98034>\
**Category:** Ruby API\
**Created:** [June 28, 2019, 1:39am UTC](https://forums.sketchup.com/t/changing-context-with-the-api/98034 "2019-06-28T01:39:35Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![medeek](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/medeek/32/10675_2.png) [@medeek](https://forums.sketchup.com/u/medeek)\
**Post date:** [June 28, 2019, 3:38am UTC](https://forums.sketchup.com/t/changing-context-with-the-api/98034/4 "2019-06-28T03:38:58Z")

</div>

`close_active` will allow me to get back to the root of the model.

`active_path` will give me a way of checking whether I need to use the previous method to jump back to the root of the model.

Found this gem by Eneroth:

> [@How to get the root Model in the scene?](https://forums.sketchup.com/t/how-to-get-the-root-model-in-the-scene/32088/21):
>
> btw, to esily detect if a ComponentDefinition is open for editing you can do this test def inside\_component?(definition) path = (Sketchup.active\_model.active\_path || [])# This method should in my view return an empty Array, not nil, when the model root is the active context. instance = path.last instance && instance.definition == definition end

However I don’t see a way of passing a group or component to a method which will then allow me to open up that entity for editing. There has got to be a way to do this, otherwise this is a major hole in the API.

---

_[View the full topic](https://forums.sketchup.com/t/changing-context-with-the-api/98034)._
