I have a script I have been running for a while, like months at least. Yesterday it crashed Rhino at least 3 times, while working at home. I tried the script here at work and it crashed Rhino again. The script lets me go through most of the steps, it was only when I tried to “place” the text output, that Rhino crashed.
I commented out 2 lines at the end of the script that was adding the text to Notes in Rhino. It runs now, so something about adding to Notes?
Rhino script for finding weight of object and adding File information, mostly by Mitch Heynick
# -*- coding: utf-8 -*-
import rhinoscriptsyntax as rs
import scriptcontext as sc
import datetime, time; # This is required to include time module.
import Rhino
def CalculateObjectPrice():
#constants
unitsFactor = .001
'''Change Text Height
1.25 for pendants & rings
0.75 for pops'''
tHt=1.25
objs=rs.GetObjects("Select Objects for volume", filter=16, group=True, preselect=False, select=True)
if not objs: return
totalV=0
for obj in objs:
if rs.IsObjectSolid(obj):
vol=rs.SurfaceVolume(obj)
if vol:
totalV+=vol[0]
#bail if there is 0 volume
if totalV==0: return
#create an empty dictionary
densDict={}
#fill the dictionary with entries
#NO SPACES in material names for GetString!
densDict['Gold_24K']=19.3
densDict['Gold_18K']=15.5
densDict['Gold_14K']=13.5
densDict['Silver']=10.3
densDict['Platinum']=21.45
densDict['Plutonium']=19.8
densDict['Cubic_Zirconia']=5.8
densDict['White_Bronze']=8.166
densDict['Diamond']=3.52
#can add as many more as you want
#gets a list of all the dictionary keys (not ordered!)
metaList=densDict.keys()
#sorts the list for easier reading in next step
metaList.sort()
#Get a string from the command line
mType=rs.GetString("Select Metal Type",strings=metaList)
if not mType: return
if not densDict.has_key(mType):
print "Invalid material type!"
return
#price = rs.GetReal('Price of '+mType+', per gram')
#if not price: return
#get the density corresponding to chosen metal from dictionary
density=densDict[mType]
#Calculate total weight of object(s)
grams = totalV * unitsFactor * density
# you are removing 15%?
finished = round((grams - (grams * .15)), 3)
amount = round((finished), 2)
grams=round(grams, 3)
text = rs.EditBox(message="Enter Gem, Enamel & or Clay info")
designer = raw_input('Enter Designers Initials: ')
fileBy = raw_input('Enter Rhino Done By Initials: ')
build_for = raw_input('Enter Factory Name: ')
now = datetime.date.today().strftime("(%d %B %Y)")
point = rs.GetPoint("Point for text insertion")
if point:
tObjs=[]
#create your text string
textString='''Calculated {mType} Weight:
{grams} grams in Rhino
{finished} grams finished
{text}
Designer: {designer}
Rhino: {fileBy}
Factory: {build_for}
© JewelPop Inc. {now}
'''
context = {
"mType":mType,
"grams":grams,
"finished":finished,
"text":text,
"designer":designer,
"fileBy":fileBy,
"build_for":build_for,
"now":now,
}
tObjs.append(rs.AddText(textString.format(**context),point,tHt))
#notes=textString.format(**context)
#sc.doc.Notes=notes
CalculateObjectPrice()
Just wondering if something has changed in the latest builds?
Here is script also to download.
JobInfoText.py (2.6 KB)