flowww
05-12-2010, 01:38 PM
Hey,
you are doing a great job in implementing python i.e. scripting for the mac version. I was trying to write my 1st script...
selecting all hatches works fine
# use rhinoscriptsyntax to get all the functions in one shot
import rhinoscriptsyntax as rs
arrAllHatches = rs.ObjectsByType(65536, True)
extended it to send all hatches to a new layer...
# use rhinoscriptsyntax to get all the functions in one shot
import rhinoscriptsyntax as rs
from System.Drawing import Color
layerName = rs.GetString("layer name")
if rs.IsLayer(layerName):
print "The layer exists."
else:
print "created ", rs.AddLayer(layerName, Color.DarkSeaGreen)
arrAllHatches = rs.ObjectsByType(65536, False)
# move all hatches to Layer specified in layerName
for x in arrAllHatches:
rs.ObjectLayer(x, layerName)
Now I wanted to extend it to check all blocks for hatches and send them to that layer as well.
Though I'm a bit stuck as i am heavily missing ObjectType when iterating through all objects in a block to check if it is a hatch. Any better idea how to do this or any workaround?
arrBlocksAndInstances = rs.ObjectsByType(4096, False)
for y in arrBlocksAndInstances:
if rs.IsBlock(y) == True: # is this a block?
arrBlockObjects = rs.BlockObjects(y) # get objects inside the block
for z in arrBlockObjects:
if rs.ObjectType(z) == 4096: # is this a hatch?
rs.ObjectLayer(z, layerName)
the first hour playing with (the) python has been fun!
you are doing a great job in implementing python i.e. scripting for the mac version. I was trying to write my 1st script...
selecting all hatches works fine
# use rhinoscriptsyntax to get all the functions in one shot
import rhinoscriptsyntax as rs
arrAllHatches = rs.ObjectsByType(65536, True)
extended it to send all hatches to a new layer...
# use rhinoscriptsyntax to get all the functions in one shot
import rhinoscriptsyntax as rs
from System.Drawing import Color
layerName = rs.GetString("layer name")
if rs.IsLayer(layerName):
print "The layer exists."
else:
print "created ", rs.AddLayer(layerName, Color.DarkSeaGreen)
arrAllHatches = rs.ObjectsByType(65536, False)
# move all hatches to Layer specified in layerName
for x in arrAllHatches:
rs.ObjectLayer(x, layerName)
Now I wanted to extend it to check all blocks for hatches and send them to that layer as well.
Though I'm a bit stuck as i am heavily missing ObjectType when iterating through all objects in a block to check if it is a hatch. Any better idea how to do this or any workaround?
arrBlocksAndInstances = rs.ObjectsByType(4096, False)
for y in arrBlocksAndInstances:
if rs.IsBlock(y) == True: # is this a block?
arrBlockObjects = rs.BlockObjects(y) # get objects inside the block
for z in arrBlockObjects:
if rs.ObjectType(z) == 4096: # is this a hatch?
rs.ObjectLayer(z, layerName)
the first hour playing with (the) python has been fun!