BruceSherwood / vpython-jupyter

This repository has been moved to https://github.com/vpython/vpython-jupyter
64 stars 33 forks source link

Can't make compound objects from triangles #10

Closed akaihola closed 8 years ago

akaihola commented 8 years ago

The compound documentation page states:

Currently label objects, lights, and objects based on curve objects (curve, helix) cannot be compounded. However, triangles, quads and even other compounds can be compounded.

However, if I try to create a compound object from triangle objects, I get this traceback:

vpython/vpython.py in __init__(self, objList, **args)
   1376             if type(obj) in ineligible:
   1377                 raise TypeError(str(type(obj)) + ' cannot be used in a compound')
-> 1378             clonelist.append(obj.clone())  ## make sure to get current values of attributes
   1379             idxlist.append(clonelist[-1].idx)
   1380         args['obj_idxs'] = idxlist

vpython/vpython.py in clone(self, **args)
   1159         for k, v in args.items():   ## overrides and user attrs
   1160             newAtts[k] = v
-> 1161         dup = type(self)(**newAtts)
   1162         return dup
   1163 

vpython/vpython.py in __init__(self, **args)
   1495         self._v1 = None
   1496         self._v2 = None
-> 1497         super(triangle, self).setup(args)
   1498 
   1499     def __del__(self):

vpython/vpython.py in setup(self, args)
    812     # set values of user-defined attributes
    813         for key, value in args.items(): # Assign all other properties
--> 814             setattr(self, key, value)
    815 
    816         #cmd = {"cmd": objName, "idx": self.idx, "guid": self.guid, "attrs":[]}

vpython/vpython.py in axis(self, other)
    893     def axis(self,other):
    894         self._axis.value = other
--> 895         self._size._x = other.mag
    896         if not self._constructing:
    897             self.addattr('axis')

AttributeError: 'triangle' object has no attribute '_size'

This is with vpython 0.3.6. I made a mybinder notebook for reproducing the issue.

BruceSherwood commented 8 years ago

Thanks for the report. It is possible to compound triangles in the GlowScript library that is used by vpython, but there's an error in the way vpython is creating compound objects.

BruceSherwood commented 8 years ago

Can now use triangles and quads in creating a compound object.