mantukaitis wrote:Hi there,
Could anyone share the best method of scattering Octane proxies? Just don't really get how to generate CSV file in Rhino.
Many thanks in advance.
mantukaitis,
I prefer this method which I've been keeping up to date through python (rather than using GH). You just scatter your geometry around the scene and it will produce a csv file for you. It just pops up with a list of blocks in the scene and you choose which ones you want to export the .csv for
Code: Select all
#-------------------------------------------------------------------------------
# Name: CSV Scatter Exporter
# Purpose: Exports Rhino block instance transformation matrixes to .csv files
# Author: PaulM, extended & updated CamN
# Created: 28/07/2012
# Notes: Updated (reduced) to only export .csv
#-------------------------------------------------------------------------------
__copyright__ = "Copyright 2013, PaulM, CamN"
__license__ = "MIT license, http://www.opensource.org/licenses/mit-license.php"
__version__ = "0.4 Development"
__status__ = "Alpha"
__url__ = (" ")
import rhinoscriptsyntax as rs
import os.path
import Rhino
def Interface():
#Choose which blocks to use
blocks = rs.BlockNames(sort=True)
defaults = [True for i in range(len(blocks))]
vals = Rhino.UI.Dialogs.ShowCheckListBox("Blocks", "Choose blocks to export:", blocks, defaults)
useBlocks = []
for block in blocks:
index = blocks.index(block)
if vals[index] == True:
useBlocks.append(block)
return useBlocks
def XFormFlipYZ(xfm):
flp = rs.XformChangeBasis2((1,0,0),(0,1,0),(0,0,1),(1,0,0),(0,0,1),(0,-1,0))
return(flp * xfm)
def GetExportPath():
pth = rs.DocumentPath()
pth = pth[:pth.rfind("\\")] + "\\"
pth = rs.BrowseForFolder(folder = pth, message = "ObjFileLocation", title = "location for ObjFiles") + "\\"
return pth
def TransformsBlocksOctane(pth):
for block in useBlocks:
instance_lst = []
for inst01 in rs.BlockInstances(block):
inst = rs.BlockInstanceXform(inst01)
if not rs.IsXformIdentity(inst):
inst = XFormFlipYZ(inst)
matrixVals = [inst.M00, inst.M01, inst.M02, inst.M03, inst.M10, inst.M11, inst.M12, inst.M13, inst.M20, inst.M21, inst.M22, inst.M23]
for x, val in enumerate(matrixVals):
instance_lst.extend(str(val))
if x != len(matrixVals) -1: instance_lst.extend(",")
instance_lst.extend(" \n")
name_of_file = block
completeName = os.path.join(pth, name_of_file+".csv")
file1 = open(completeName, "w")
for x in instance_lst:
x = x.replace("[", "")
x = x.replace("]", "")
file1.write(x)
file1.close()
if __name__ == "__main__":
useBlocks = Interface()
pth = GetExportPath()
TransformsBlocksOctane(pth)