ExplodeBlock are killing object names

Hey guys, I am having a problem with inserting blocks.

Here is some of my code

        plp1 = rs.ObjectsByName("PART LIST POINT 1")
        plp1Coor = rs.PointCoordinates(plp1)
        dlpTB = rs.InsertBlock("DOUBLE LIST PART TITLE BLOCK", plp1Coor)
        dlpP = rs.InsertBlock("SINGLE PART DOUBLE LIST", plp1Coor)
        rs.MoveObject(dlpP, (0,-2.242,0))
        rs.ExplodeBlockInstance(dlpP)
        partD = rs.ObjectsByName("PART DESCRIPTION") #its not finding this, cause it was wiped
        rs.TextObjectText(partD, string)

Here’s whats happening.

When the block is inserted and exploded, it looses all object information.

But this only happens when you do it programmatically. If I manually insert the block (Insert command) and then explode it, the keeps all the objects names intact.

Any ideas?

Thanks :slight_smile:

@AlanGreyjoy,

are the object names preserved if you script the _Explode command instead of using rs.ExplodeBlockInstance(dlpP) ? I mean something like this:

rs.SelectObject(dlpP)
rs.Command("_Explode", False)

c.

Thanks for the reply.

Sadly, I did try that before… and yet it still cleared the object names.

I can’t think of any other way to grab that text either, without the object name…

It’s crazy huh? If I manually insert them and explode them, they hold all the object names lol.

I am going to play around with linking… maybe that will be the cure

@AlanGreyjoy,

you might to script the _Insert command as well. The bug seems to be realted to this post.

c.

Thanks clement :slight_smile:

Seems this is a Rhino bug for sure.

I did have luck with making the block “Embedded and Link”

It still loses object names when you explode the block with ExplodeBlock, but running as a command keeps the object names now :slight_smile: :slight_smile:

One last unrelated problem that I know you can answer fast for me…

How do you get 1 in stead of 1.0 :stuck_out_tongue:

I am using GetReal, but in python it stores it as a float and not an int.

Thanks again!!

Nevermind… i think i found it GetInteger lmao…

I am not entirely sure, if i run below script with below file, exploding via script seems to keep the object names and attributes. The block insertion and explosion is similar as in your above example:

import rhinoscriptsyntax as rs
    
def DoSomething():
    myblock = rs.InsertBlock("MyBlock", (0,0,0))
    if myblock: 
        rs.MoveObject(myblock, (50,0,0))
        rs.ExplodeBlockInstance(myblock)
    
if __name__=="__main__":
    DoSomething()

Please try with below example file which has an embedded block instance named “MyBlock”. Does this fail as well on your side ? BlockTest.3dm (470.0 KB)

c.

Well… it didn’t fail then… ExplodeBlockInstace saved all the object names…

I am not doing anything different in my code…

Although my objects are text’s… maybe that’s the bug?

They are pretty much Title Blocks. Only way I can get the object names to preserve, is if I embed them and link them.

Since rhino has no spreadsheet option, I am having to do it this way. I make a generic block with all my fields, insert it, explode it, and modify it.

Thanks again for your help :slight_smile:

@AlanGreyjoy,

as a last resort and if your Blocks are not nested, you might get the object names as list before exploding using rs.BlockObjects(). Then after using rs.ExplodeBlockInstance(), apply them. Note that the order the objects appear after exploding could be reversed.

c.