Need help with a Rhino script to generate a bill of materials

I am a fabricator. We build our models in Rhino, several years ago someone on this forum gave me an amazing script and I lost it. Basically I am modeling parts that are extrusions, and I need to generate a CSV file that has the part name and a length, that is it. The script I found on this forum worked by first having all my parts be blocks, with the block name being the part number, inside the block was the extrusion, and a dimension string which specified the desired length. Additionally, in the properties of the dimension string, it has a “name” which was “dim”. When I built my model, I made all the parts blocks, then I ran the script and it produced a CVS file with all the part numbers and lengths. It worked great! Then I lost it in a hard drive failure. Could anyone help me find it again or point me in the right direction?

Gregory

Hi,
Was it not the script linked here?

Thank you for responding, but I think that was a false flag, it doesn’t work because it requires first to make a part as a seperate rhino file. I was initially excited because I thought it was what I was looking for .

Could you post a sample file together with the output format you are looking for? It sounds really easy to recreate (famous last words)

Sure. I will do so tommorrow, thank you.

Good morning Graham, so i found it! BOMGenerateCSV-New(1).py (831 Bytes)
BOM script test.3dm (61.3 KB)

3 Likes

Good news! Have a great weekend

thank you for your help, so I really dont know where I originally found this script, but i accidently re- named it the same name is this other script which is there all this confusion came from.

Hi Gregoryhitchcoc,
Can you guide me how do i execute this script in windows? If you have any document then that would be great. Which python version i have to install and how rhinoscriptsyntax need to import. Looking forward to here from you.

Regards
Sharief

Hi Sharief -

That script was written to be used in Rhino.
You don’t have to install python.
-wim

Thanks for your reply, can you guide me what are the software / library need to install in my linux server

Hi - how does any of this have anything to do with generating a bill of materials?
Please describe clearly what it is that you are trying to do.
-wim

image

try this :

import rhinoscriptsyntax as rs

def BOMCSV():

    DocPath=rs.DocumentPath()
    fileObject=open(DocPath+'BOM.txt','w')
    BlockNameList= []
    fileObject.write('BlockName'+'\t'+'PartLength'+'\t'+'QTY'+'\n')


    BlockTestList=rs.BlockNames(True)

    for i in BlockTestList:
        if rs.IsBlockInUse(i,0):
            BlockNameList.append(i)

    for d in BlockNameList:
        PartLen ='-'
        BlockObListD=rs.BlockObjects(d)
        for i in BlockObListD:
            if rs.IsDimension(i):
                obname = rs.ObjectName(i,);
                if obname == 'length':
                    PartLen=rs.DimensionText(i)
        Qty = rs.BlockInstanceCount(d)
        fileObject.write(d+'\t'+PartLen+'\t'+str(Qty)+'\n')
    fileObject.close()
    print ("CSV Exported")


BOMCSV()