# Python rs.ExplodeBlockInstance changes object layer of text objects

**URL:** <https://discourse.mcneel.com/t/python-rs-explodeblockinstance-changes-object-layer-of-text-objects/61274>\
**Category:** Rhino for Windows\
**Created:** [April 24, 2018, 5:53am UTC](https://discourse.mcneel.com/t/python-rs-explodeblockinstance-changes-object-layer-of-text-objects/61274 "2018-04-24T05:53:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![timcastelijn](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/timcastelijn/32/649931_2.png) [@timcastelijn](https://discourse.mcneel.com/u/timcastelijn)\
**Post date:** [April 24, 2018, 5:53am UTC](https://discourse.mcneel.com/t/python-rs-explodeblockinstance-changes-object-layer-of-text-objects/61274/1 "2018-04-24T05:53:54Z")

</div>

I explode a block containing a text object using the script below. The objectlayer property of that text object is unintendetly set to ‘0’. the function rs.ExplodeBlockInstance should not change the objectlayer of the blockInstane contents.

```
import rhinoscriptsyntax as rs
import os

# main script
def main():
    
    # get objects to explode
    objs = rs.GetObjects("select objects to explode", 0, True, True)
    if not objs: print "aborted"; return

    for obj in objs:
        if rs.IsBlockInstance(obj):
            rs.ExplodeBlockInstance(obj)

if __name__ == " __main__":
    main();

```

Version 5 SR14 64-bit  
(5.14.522.8390, 22-May-17)

---

<div class="post-metadata">

**Author:** ![lowell](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/lowell/32/270099_2.png) [@lowell](https://discourse.mcneel.com/u/lowell)\
**Post date:** [April 24, 2018, 5:57pm UTC](https://discourse.mcneel.com/t/python-rs-explodeblockinstance-changes-object-layer-of-text-objects/61274/2 "2018-04-24T17:57:53Z")

</div>

@timcastelijn - I don’t see that happening here in a simple test running your script.  
Can you attach a small file that will show that with the script?

---

<div class="post-metadata">

**Author:** ![Helvetosaur](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/helvetosaur/32/635974_2.png) [@Helvetosaur](https://discourse.mcneel.com/u/Helvetosaur)\
**Post date:** [April 24, 2018, 10:40pm UTC](https://discourse.mcneel.com/t/python-rs-explodeblockinstance-changes-object-layer-of-text-objects/61274/3 "2018-04-24T22:40:48Z")

</div>

> [@timcastelijn](#):
>
> The objectlayer property of that text object is unintendetly set to ‘0’. the function rs.ExplodeBlockInstance should not change the objectlayer of the blockInstane contents.

Remember - block _instances_ reside on a particular layer, but they are just references to the original object(s) - which may be on one or more different layers. When you explode the block, the _instance_ disappears from the layer it was on and the resulting “real” geometry goes back to the original layers the _block definition objects_ were on at the moment the block was created.

–Mitch

---

<div class="post-metadata">

**Author:** ![timcastelijn](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/timcastelijn/32/649931_2.png) [@timcastelijn](https://discourse.mcneel.com/u/timcastelijn)\
**Post date:** [April 25, 2018, 6:03am UTC](https://discourse.mcneel.com/t/python-rs-explodeblockinstance-changes-object-layer-of-text-objects/61274/4 "2018-04-25T06:03:37Z")

</div>

Hi Lowell,

thanks for your response. See the file attached: [test.3dm](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/0/5/05fb64e00202c0981d27402e51dbb9a6b51e6f7a.3dm) (188.8 KB)

hi @Helvetosaur, sorry for my explaination. It was a bit poor. I meant that a text object is on ‘layer01’ at time of defining the block. When i explode an instance of that definition, the text object is on layer ‘0’, while I expect it to be on ‘Layer01’ again

---

<div class="post-metadata">

**Author:** ![Helvetosaur](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/helvetosaur/32/635974_2.png) [@Helvetosaur](https://discourse.mcneel.com/u/Helvetosaur)\
**Post date:** [April 25, 2018, 6:55am UTC](https://discourse.mcneel.com/t/python-rs-explodeblockinstance-changes-object-layer-of-text-objects/61274/5 "2018-04-25T06:55:02Z")

</div>

Don’t see that here with your test file, on exploding the text goes to layer `0.0.160.0 - 16 Contour outer +0`

–Mitch

---

<div class="post-metadata">

**Author:** ![timcastelijn](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/timcastelijn/32/649931_2.png) [@timcastelijn](https://discourse.mcneel.com/u/timcastelijn)\
**Post date:** [April 25, 2018, 7:35am UTC](https://discourse.mcneel.com/t/python-rs-explodeblockinstance-changes-object-layer-of-text-objects/61274/6 "2018-04-25T07:35:11Z")

</div>

Ok thanks for checking. That is different behavior from what i see here. I suspect there is a different version of e.g python/ironPython/… on my system. Do you have any suggestions where i can check the versions being used?

---

<div class="post-metadata">

**Author:** ![Helvetosaur](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/helvetosaur/32/635974_2.png) [@Helvetosaur](https://discourse.mcneel.com/u/Helvetosaur)\
**Post date:** [April 25, 2018, 8:07am UTC](https://discourse.mcneel.com/t/python-rs-explodeblockinstance-changes-object-layer-of-text-objects/61274/7 "2018-04-25T08:07:51Z")

</div>

Sorry, I just re-read your post, I see you are on Rhino V5, I had tested in V6… I do see that the text goes to the layer `0` in V5 when using rs.ExplodeBlock(). Looks like the bug has been fixed for V6.

–Mitch
