Python script crashing Rhino 5.1 & WIP

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)

I also have been having a lot of trouble with crashing when running Python scripts recently - sent in a bunch of crash reports… Sometimes after running scripts it also crashes silently on closing, when I re-open rhino the next time I get the crash report box…

–Mitch

This happened today after trying the script twice. Yesterday at home though, I never got the crash report on reopening Rhino.

«Randy

Hi all,

Just to let you know that we are looking into this.

Thanks,
Alain

Happening agin here at home with the write to notes commented in the script.

I have tried with WIP & 5.1

Software information

Software versions
Rhinoceros version: 5.1 (5B161)
IronPython version: 5.1.2015.131
Language: en (MacOS default)
OS X version: Version 10.10.5 (Build 14F1021)

Plug-ins
/Users/fatty/Library/ColorPickers/SkalaColor.colorPicker/Contents/MacOS/SkalaColor

Third party kernel extensions
at.obdev.nke.LittleSnitch (4352)
com.digidesign.mbox2.boot.driver (10.3.5f211)
com.Greatdy.driver.SystemAudioCapture (1.0.0)
com.intel.kext.intelhaxm (1.1.1)
com.copy.github.osxfuse.filesystems.copy_osxfusefs (2.8.0)

Hardware information

Computer hardware
Hardware model: MacPro2,1
Processor: Intel Xeon CPU 5150 @ 2.66GHz
Memory: 18 GB
Architecture: Intel 64 bit

Video hardware
Graphics: ATI Radeon HD 5770 1024 MB
Memory: 1024 MB
Screen size: 1680 x 1050, 1920 x 1200
Displays: Cinema (99dpi 1x), BenQ FP231W (98dpi 1x)

USB devices
Apple Inc.: iPhone
PixArt: DynexWired USB Optical Mouse
Apple Inc.: Apple Keyboard
Apple Computer, Inc.: Apple Cinema Display
Canon: CanoScan
Digidesign: Mbox 2

Bluetooth devices
None

OpenGL information

OpenGL software
OpenGL version: 2.1 ATI-1.32.25
Render version: 2.1
Shading language: 1.20
Maximum texture size: 16384 x 16384
Z-buffer depth: 24 bits
Maximum viewport size: 16384 x 16384

Implementation settings
Use texture compression: No

Appearance settings
Antialiasing: 0x
Mip map filtering: None
Anisotropic filtering: None