Rest Block Transformations?

Hi everyone,

I am currently looking for a way to reset block transformations, it would come in real handy.

I found this thread by some scripts uploaded but the link seems broken.
Reset (or change) block instances transformations (scale, rotation)

Thanks!

On the same thread you can find a link to rhinotools:

You can find what you’re looking for there:

Hi! Thank you, but I am afraid the script isn’t doing what I need, I think this one only resets scale… :frowning:

I runs okay, but I can see the block has not been reset by looking at the gumball. Then I check the Base Point of the Block, and indeed it is still located differently from a newly inserted block.

If you want to reset everything, you can simply use Transform.TryGetInverse():

import rhinoscriptsyntax as rs
import scriptcontext as sc
def RunCommand( is_interactive ):
    if sc.escape_test(False):
        print "script cancelled" #do something
    print "Resetting..."
    objectIds = rs.GetObjects("Pick some blocks", 4096, preselect=True)
    if not objectIds:
        print "No objects"
        return False
    rs.EnableRedraw(False)
    for id in objectIds:
        blockXForm = rs.BlockInstanceXform(id)
        inverseBlockXForm = blockXForm.TryGetInverse()[1]
        rs.TransformObject(id, inverseBlockXForm)
    rs.SelectObjects(objectIds)
    rs.EnableRedraw(True)
    print "...aaand its done."
    return 0
RunCommand(True)

ShynnSup.py (680 Bytes)

1 Like

Aha, great! Thank You!

Wouldn’t just inserting a new instance at W0,0,0 do that?

-Pascal

See the following,

https://github.com/mcneel/rhino-developer-samples/blob/6/rhinoscript/ResetBlock.rvb

– Dale

Technically :joy: but the script can be applied to multiple blocks at once!

And it saves the trouble of looking for the block in the insert window.

Yes, of course, but the script could be greatly simplified, it seems to me…

import rhinoscriptsyntax as rs

ids = rs.GetObjects(filter=4096, preselect=True)

if ids:
    for id in ids: 
        rs.InsertBlock(rs.BlockInstanceName(id), [0,0,0])
        rs.DeleteObject(id)

or, in place:

import rhinoscriptsyntax as rs

ids = rs.GetObjects(filter=4096, preselect=True)

if ids:
    for id in ids: 
        rs.InsertBlock(rs.BlockInstanceName(id), rs.BlockInstanceInsertPoint(id))
        rs.DeleteObject(id)

-Pascal

5 Likes