i’m trying to copy out the nested blocks but having trouble getting them back in their instance locations, they go back to 0. Do i need to create a plane at their instance origin and do plane to plane transformation? It seems to hold some sort of relation to the Top Level Block.
My attempts so far.
import rhinoscriptsyntax as rs
import Rhino
#Select Block
#Get all instances of block
#Explode and get 1st level nested blocks
#place instance of said block at its locations
selBlks = rs.GetObjects("Select Blocks", 4096)
blkcpy = []
for blk in selBlks:
name = rs.BlockInstanceName(blk)
allBlks = rs.BlockInstances(name)
for bk in allBlks:
blkObjs = rs.BlockObjects(rs.BlockInstanceName(allBlks[0]))
for blkblk in blkObjs:
if rs.IsBlockInstance(blkblk):
blkcpy.append(blkblk)
rs.CopyObjects(blkcpy)
print blkcpy
import rhinoscriptsyntax as rs
import Rhino
#Select Block
#Get all instances of block
#Explode and get 1st level nested blocks
#place instance of said block at its locations
selBlks = rs.GetObjects("Select Blocks", 4096)
for blk in selBlks:
name = rs.BlockInstanceName(blk)
allBlks = rs.BlockInstances(name)
for bk in allBlks:
blkObjs = rs.BlockObjects(rs.BlockInstanceName(allBlks[0]))
bkx = rs.BlockInstanceXform(bk)
for blkblk in blkObjs:
if rs.IsBlockInstance(blkblk):
xform = rs.BlockInstanceXform(blkblk)
bname = rs.BlockInstanceName(blkblk)
#needs transformation of bkx to xform
#insrtbk = rs.InsertBlock2(bname, bkx)