Home » Developers » ShapeJS » General suggestions/ideas
Search Search  
Show: Today's Messages    Show Polls    Message Navigator
General suggestions/ideas [message #87025] Tue, 01 April 2014 04:38 UTC Go to next message
avatar MrNib  is currently offline MrNib
Messages: 517
Registered: November 2012
Go to my shop
Senior Member
It would be great if there were a cylinder element that included two radius parameters, one for each end, creating tapered cylinder. It could also be used to create a cone of finite length.
Re: General suggestions/ideas [message #87083 is a reply to message #87025 ] Tue, 01 April 2014 23:33 UTC Go to previous messageGo to next message
avatar AlanHudson  is currently offline AlanHudson
Messages: 126
Registered: March 2010
Go to my shop
Senior Member
I work here
MrNib wrote on Tue, 01 April 2014 04:38

It would be great if there were a cylinder element that included two radius parameters, one for each end, creating tapered cylinder. It could also be used to create a cone of finite length.


Sure thing. We've coded it, should be released in the next couple days.


Director 3D Tools
Re: General suggestions/ideas [message #87114 is a reply to message #87083 ] Wed, 02 April 2014 07:38 UTC Go to previous messageGo to next message
avatar MrNib  is currently offline MrNib
Messages: 517
Registered: November 2012
Go to my shop
Senior Member
Excellent, I''ll be using that tapered cylinder as soon as it is available.

While I'm at it here's another question or suggestion as the case may be. Let's pretend I'm too lazy to use a third party package to combine x3db files from different scripts...

If you wanted to output 2 identical or slightly different objects it's relatively easy to duplicate, translate the copy, and then output both at the same time using the output commands at the end of the script. As far as I can tell you just need to establish an initial grid that is large enough to contain both objects before generating the output. Is there a better way to duplicate an item in the script after the first has been output so you don't need to use an enlarged grid? I'm thinking something like that might reduce overall computation time/memory usage.

And if you wanted to generate two wildly different sized yet related objects such that it doesn't make a lot of sense to use the same initial grid to contain both, is there a way to generate the different objects sequentially in the same script and then combine individual outputs at then end so they can be exported together into the same print file? For example, if you wanted a script to generate geometrically mismatched geometries like a long, narrow stirring stick and a big fat mug into the same output print file, what would you do?

Re: General suggestions/ideas [message #87180 is a reply to message #87025 ] Thu, 03 April 2014 06:12 UTC Go to previous messageGo to next message
avatar MrNib  is currently offline MrNib
Messages: 517
Registered: November 2012
Go to my shop
Senior Member
One more thing. Why is subtraction more complicated than addition?

If I can do this to simply add a cylinder to a structure:

structure.add(new Cylinder(blah-blah))

wouldn't it make sense to also have something simpler like this to subtract?:

structure.sub(new Cylinder(blah-blah))



Re: General suggestions/ideas [message #87559 is a reply to message #87114 ] Wed, 09 April 2014 15:15 UTC Go to previous messageGo to next message
avatar AlanHudson  is currently offline AlanHudson
Messages: 126
Registered: March 2010
Go to my shop
Senior Member
I work here
Tapered Cylinders are now available. Here is some sample code:

function main(args) {
var size = args[0];
var thickness = args[1];
var grid = createGrid(-16*MM,16*MM,-16*MM,16*MM,-16*MM,16*MM,0.1*MM);
var cylinder = new Cylinder(new Vector3d(0,0,0), new Vector3d(0,10*MM,0),5*MM,10*MM);
var maker = new GridMaker();
maker.setSource(cylinder);
maker.makeGrid(grid);
return grid;
}


Director 3D Tools
Re: General suggestions/ideas [message #87560 is a reply to message #87180 ] Wed, 09 April 2014 15:23 UTC Go to previous messageGo to next message
avatar AlanHudson  is currently offline AlanHudson
Messages: 126
Registered: March 2010
Go to my shop
Senior Member
I work here
MrNib wrote on Thu, 03 April 2014 06:12

One more thing. Why is subtraction more complicated than addition?

If I can do this to simply add a cylinder to a structure:

structure.add(new Cylinder(blah-blah))

wouldn't it make sense to also have something simpler like this to subtract?:

structure.sub(new Cylinder(blah-blah))






Not sure I follow this example.

To add things you use a Union operation:

var union = new Union(foo,bar);

or you can
var union = new Union();
union.add(foo);
union.add(bar);

To subtract you use a Subtraction operation:

var subtract = new Subtraction(foo,bar);

So the constructor methods are equal so perhaps your talking about chaining them together. In the union case it makes sense to union n objects together hence we have a .add() method. For subtract it's not clear what subtracting 3 things would do. if its a,b,c is that (a - b) - c?

I could conceive of a general boolean class that did something like this:

var bool = new Boolean().
bool.union(a,b);
bool.subtract(c);
bool.union(d).

This would be (a+b) - c + d.

Is this the type of style your wanting?


Director 3D Tools
Re: General suggestions/ideas [message #87586 is a reply to message #87560 ] Wed, 09 April 2014 19:15 UTC Go to previous messageGo to next message
avatar MrNib  is currently offline MrNib
Messages: 517
Registered: November 2012
Go to my shop
Senior Member
I need to review my code again to see exactly what was causing me heartburn. It seemed as though I was creating lots of temporary unions and subtractions when all I wanted to do was something simpler like this:

structureA = structureA - structureB

Since I was doing additions and subtractions conditionally I was getting more confused with the defining of multiple temporary unions and subtractions. However I'm sure if I fully review my code step by step I can clean things up myself. Mostly I think it's mostly a matter structuring and ordering things better. Not a "real" software guy so I need to stare at things a bit longer to get the coding more efficient with less brute force.

I'm probably also a victim of thinking along Tinkercad lines where an object can be a negative object so if I add a positive cube and an negative cylinder you end up with a cube with a hole cut out of it. I would imagine the main Tinkercad editor is doing something similar internally with union and subtraction definitions it's just that it's done graphically and sequentially in multiple paths with multiple discrete objects.

Regardless though, things are working and the ShapeJS scripting is awesome!

Re: General suggestions/ideas [message #87612 is a reply to message #87560 ] Wed, 09 April 2014 23:35 UTC Go to previous messageGo to next message
avatar MrNib  is currently offline MrNib
Messages: 517
Registered: November 2012
Go to my shop
Senior Member


[/quote]


I could conceive of a general boolean class that did something like this:

var bool = new Boolean().
bool.union(a,b);
bool.subtract(c);
bool.union(d).

This would be (a+b) - c + d.

Is this the type of style your wanting?
[/quote]


After deep contemplation at the grocery store that type of boolean method could simplify things. But why even require the necessity of explicitly defining different add or subtract commands? How about something like this?

var union = new Union();
union.add(foo);
union.add(-bar);

or

var union = new Union();
union.add(foo - bar);

The result in either case would be equal to "foo minus bar". Would that make any type of rational sense?
Re: General suggestions/ideas [message #87758 is a reply to message #87559 ] Fri, 11 April 2014 20:07 UTC Go to previous message
avatar MrNib  is currently offline MrNib
Messages: 517
Registered: November 2012
Go to my shop
Senior Member
AlanHudson wrote on Wed, 09 April 2014 15:15

Tapered Cylinders are now available. Here is some sample code:

function main(args) {
var size = args[0];
var thickness = args[1];
var grid = createGrid(-16*MM,16*MM,-16*MM,16*MM,-16*MM,16*MM,0.1*MM);
var cylinder = new Cylinder(new Vector3d(0,0,0), new Vector3d(0,10*MM,0),5*MM,10*MM);
var maker = new GridMaker();
maker.setSource(cylinder);
maker.makeGrid(grid);
return grid;
}


Taper!

https://images2.sw-cdn.net/model/picture/290x218_1851979_2523725_1397091273.jpg

 
   
Previous Topic:Saving scripts
Next Topic:Custom ShapewayJS

Logo

Hello.

We're sorry to inform you that we no longer support this browser and can't confirm that everything will work as expected. For the best Shapeways experience, please use one of the following browsers:

Click anywhere outside this window to continue.