Long story short, the Mac version of the GHPython component sucks as a text editor/IDE, and we shouldn’t expect any improvements before the “next version of Rhino” (according a recent discussion). In terms of running code, it mostly works just fine though.
In order to get clearer, more detailed debugging information, you can plug a panel into the out output of the GHPython component. This will then show you on which line of code your errors occur.
I doubt that! It seems to be a value error, since it tells you that it expected a curve, but got a GUID.
First of all, you must understand that the rhinoscriptsyntax mostly refers to geometry by GUID, a type of id, and the API (i.e. Rhino) deals with “code” objects. I can’t handle GUIDs unless you convert them first.
Generally speaking it is not a good idea to mix both, since you then have to deal with these kinds of conversion errors.
The rhinoscriptsyntax is a Python wrapper for the Rhino API, and is usually better for beginners, since it’s easier to understand (nearer to Rhino commands). The downside is that it’s less flexible and usually slower.
The Rhino API is for more advanced users, since you have to be familiar with some coding concepts, like object-oriented programming and other stuff, to comprehend how everything works structurally.
Your code seems to be API oriented, so I stuck with that. Here’s a simplified, working version:
"""Explodes a box geometry and offsets its faces along their normal vectors.
box: A box geometry
dist: An offset distance
a: The exploded, offset box faces"""
__author__ = "p1r4t3b0y"
__version__ = 0.2
# Get the box center
box_center = box.Center
# Convert the box to a brep
bbrep = Rhino.Geometry.Box.ToBrep(box)
# Get a list of faces
faces = bbrep.Faces
exploded_faces =  # empty faces list
for i in xrange(faces.Count):
face = faces[i] # current face
# Reparameterise the current face
# Get the center of the current face
face_center = face.PointAt(0.5, 0.5)
# Calculate the translation vector
vec = face_center - box_center
vec *= dist
# Convert the face to a brep
fbrep = face.ToBrep()
# Move the face brep
# Store the moved brep
a = exploded_faces
Note that it was this line of code that threw the error:
area = Rhino.Geometry.AreaMassProperties.Compute(box)
Simply because it expects a brep, mesh, or curve geometry and can’t handle boxes (cf. documentation). A box is not a brep, unless you convert it first, or set the type hint of your “box” input to brep (which then does the conversion for you).
However, as you may have noticed in my code, this line is not even necessary, since a box object has already a center property built in.