Skip to content

Commit b66d391

Browse files
Merge pull request #186 from vpython/Fix_length_bug
Fix length bug
2 parents da4fd8a + 1b2336f commit b66d391

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

vpython/vpython.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -809,8 +809,13 @@ def length(self,value):
809809
if self._save_oldaxis is not None:
810810
self._axis = self._save_oldaxis
811811
self._save_oldaxis = None
812-
if self._size._x == 0: self.axis = vector(value, 0, 0)
813-
else: self.axis = value*self._axis.norm() # this will set length
812+
if self._size._x == 0:
813+
self.axis = vector(value, 0, 0)
814+
else:
815+
if self._sizing:
816+
self.axis = value*self._axis.norm() # this will set length if self._sizing
817+
else:
818+
self._size._x = value # for objects whose axis and size are not linked
814819
if not self._constructing:
815820
self.addattr('axis')
816821
self.addattr('size')
@@ -1522,7 +1527,7 @@ def __init__(self, objList, **args):
15221527
self.compound_idx += 1
15231528
args['_objName'] = 'compound'+str(self.compound_idx)
15241529
super(compound, self).setup(args)
1525-
self._sizing = False # no axis/size connection
1530+
self._sizing = False # no axis/size connection except that changing axis.mag changes compound length
15261531

15271532
for obj in objList:
15281533
# GlowScript will make the objects invisible, so need not set obj.visible

0 commit comments

Comments
 (0)