CoffeeSCad icon indicating copy to clipboard operation
CoffeeSCad copied to clipboard

Problem .clone()ing a user defined object

Open Thav opened this issue 11 years ago • 3 comments

Code here: https://www.dropbox.com/sh/nzkay28ov4nksqz/u08II_ga3C

I have a part that I've defined as a subclass of Part. When I try to .clone() (on line 106 of filletsCloneProblem.coffee in the code in Dropbox) the part, I get the error: File: line 215: _ref is undefined

There is no line 215 in the code. I am able to clone the objects created in the objectOriented/defining_parts example, but don't see what the problem is here.

Thav avatar Feb 05 '14 14:02 Thav

sadly the line numbers can be misleading with some errors because of the coffeescript -> javascript compiling, future versions should in theory have less of those issues.

about the issue itself not 100% sure, I am investigating where it comes from (something seems to not be initiated correctly in the filletPlank class from what I traced down so far...very weird

kaosat-dev avatar Feb 05 '14 15:02 kaosat-dev

okay, if you replace @defaults = {} with @defaults = {size:[0,0,0]}

in the constructor of filletPlank class you get a "degenerate polygon" error (self intersecting etc) which is already a lot less obscure :)

kaosat-dev avatar Feb 05 '14 15:02 kaosat-dev

Different initializations of size gets different results.

[0,0,1], [0,1,1] and similar - these result in "cube size should be non negative". This seems to be because of the lines [@x,@y,@r] = @size @plank = new Cube({size:[@x-@r,@y,@r],center:true}).translate([-@r/2,0,0]) So you get 0-1 as one of the dimensions of the cube created with the default values (even though the cloned object should be getting values other than the default)

[1,1,1] gets maximum stack size exceeded, maybe it's breaking at 0 as one of the dimensions.

[2,1,1] makes it work, and the object is cloned as expected, not using the default values set.

I tried to understand javascript prototypal inheritance, but I don't, and I fear the unknown.

Thav avatar Feb 06 '14 01:02 Thav