VolumeCentroid not operating on Blocks


(Willem Derks) #1

Hi,

As per subject, would be usefull to have VolumeCentroid to operate on Blocks.

Thanks
-Willem


Volume and Volume Centroid from Blocks
#2

Hi Willem,

I agree with that.

In the mean time, a simple exploding of the block, calculating a VolumeCentroid of it’s pieces and creating the block back with the same name and insertion point as the exploded one, might do the trick:

import rhinoscriptsyntax as rs

block_id = rs.GetObject("Pick up the block", 4096, True)
block_name = rs.BlockInstanceName(block_id)
block_base_point = rs.BlockInstanceInsertPoint(block_id)
objects_ids = rs.ExplodeBlockInstance(block_id)
rs.SelectObjects(objects_ids)
rs.Command("_-VolumeCentroid ")
rs.InsertBlock(block_name, block_base_point)
rs.DeleteObjects(objects_ids)