MoI discussion forum
MoI discussion forum

Full Version: Parametric design in MoI?

Show messages:  1-10  …  231-250  251-270  271-290  291-310  311-330  331-350  351-370  …  911-912

From: Max Smirnov (SMIRNOV)
12 May 2016   [#291] In reply to [#289]
Pilou, check the new version ;)
From: Max Smirnov (SMIRNOV)
12 May 2016   [#292]
Added properties fix for Output node for back compatibility with old .nod files.
From: Sharif (SR13765)
12 May 2016   [#293] In reply to [#289]
Hi Pilou

See attached, Includes:

Series
Range
DegToRad ( degree to Radian Conversion, You can use Math node for this )
RadToDeg ( Radian to Degree Conversion, You can use Math node for this )

Thanks,
sharif

Attachments:
nodeTest.js


From: Frenchy Pilou (PILOU)
12 May 2016   [#294] In reply to [#288]
@Sharif: thx!

@Max

Any of previous nodes works with this new version ???

Result of expression "This properties style" [undefined] is not an object.
From: Max Smirnov (SMIRNOV)
12 May 2016   [#295] In reply to [#294]
Pilou, yes, I'm sure.


Replace original litegraph-editor.js with the attached file
Now you need to press New button longer to reset the editor.
From: Frenchy Pilou (PILOU)
12 May 2016   [#296] In reply to [#295]
OK I have now several colors for the Style but not this "Draft" :)

but always all previous nodes loaded don't work with this version 6.5
Result of expression "This properties style" [undefined] is not an object.

Nodes saved with this version 6.5 work fine!
From: Karsten (KMRQUS)
12 May 2016   [#297] In reply to [#292]
Hello Max,

I'm not sure that the pushFrame works:

pointArray.prototype.pushFrame = function(frame)
{
var rx=ry=rz=0;
if ( frame.zaxis.y === 0 && frame.zaxis.z === 0) { ry = ( frame.xaxis.z > 0 )?90:-90; }
else
{
rx = Math.atan2(frame.zaxis.y, frame.zaxis.z);
ry = -Math.asin(frame.zaxis.x);
rz = Math.atan2(frame.xaxis.z*Math.sin(rx)-frame.xaxis.y*Math.cos(rx), frame.xaxis.x*Math.cos(ry)+(frame.xaxis.y*Math.sin(rx)+frame.xaxis.z*Math.cos(rx))*Math.sin(ry));
}

this.data.push(frame.origin.x); this.data.push(frame.origin.y); this.data.push(frame.origin.z);
this.data.push(rx); this.data.push(ry); this.data.push(rz);
this.data.push(1);
this.xlength++;
}
I'm missing the conversion to deg?
What works for me at the moment is something like:

pointArray.prototype.pushFrame = function (frame)
{
this.data.push(frame.origin.x);
this.data.push(frame.origin.y);
this.data.push(frame.origin.z);

var rx=ry=rz=0;
if ( frame.zaxis.y === 0 && frame.zaxis.z === 0) { ry = ( frame.xaxis.z > 0 )?Math.PI/4:-Math.PI/4; }
else
{
rx = Math.atan2(frame.zaxis.y, frame.zaxis.z);
ry = -Math.asin(Math.round(frame.zaxis.x*10000)/10000);
rz = Math.atan2(frame.xaxis.z*Math.sin(rx)-frame.xaxis.y*Math.cos(rx), frame.xaxis.x*Math.cos(ry)+(frame.xaxis.y*Math.sin(rx)+frame.xaxis.z*Math.cos(rx))*Math.sin(ry));
}
/////////////////////////
this.data.push(rx * 180 / Math.PI);
this.data.push(ry * 180 / Math.PI);
this.data.push(rz * 180 / Math.PI);

this.data.push(1);
// this.xlength++;
}
Although, for the gimbal lock is a calculation vor rx or rz is missing?? e.g. rz = Math.atan2(frame.yaxis.z,frame.yaxis.y); with rx=0;???

Nevertheless, tomorrow is a new day!
Karsten
From: BurrMan
12 May 2016   [#298] In reply to [#297]
Hey Max,
If you try and set output style property "before" running the node it will produce an error. If you run node first, then style is applied great!

I ran old "jitter node"... But example node and others like motor error out. Hopefully you are just making those future changes now...
From: Max Smirnov (SMIRNOV)
12 May 2016   [#299]
Pilou, BurrMan
http://moi3d.com/forum/index.php?webtag=MOI&msg=7713.292

Karsten,
Yes, I forgot about rad-deg translation :)
Thank you
From: Frenchy Pilou (PILOU)
12 May 2016   [#300] In reply to [#299]
Works now like a charm! :)

It's always no need to translate what is out of the lang.js file ?
(for the Info or some info node message like "(input locked)" when you Right Click on an input node point
From: BurrMan
12 May 2016   [#301] In reply to [#299]
Hey Max,
Here's the workflow error with the new styles element:



And then a quick error on the old "example" node:


From: Karsten (KMRQUS)
12 May 2016   [#302] In reply to [#301]
Hello Burrman,

please try to replace the marked area with shown line in nodes\basic.js - and give a feedback:-)


MoIOutput.prototype.updateObjects = function()
{
this.onClear();
var changeStyle = (this.properties.style[0] !== this.properties.style[1] && this.sIndex !== -1);
var inObj = this.getInputData(0, moi.geometryDatabase.createObjectList());
/////////////////////////////////////////////////
if(inObj!==null){for ( var i = 0; i<inObj.length; i++) this.tempobjects.addObject(changeStyle?inObj.item(i).clone():inObj.item(i));};
/////////////////////////////////////////////////
for ( var i=this.tempobjects.length; i>0; i-- ) this.tempobjects.item(i-1).setHitTest(0);
if (changeStyle) this.tempobjects.setProperty( 'styleIndex', this.sIndex);
moi.geometryDatabase.addObjects(this.tempobjects);
}

Have a nice day
Karsten
From: BurrMan
12 May 2016   [#303] In reply to [#302]
That worked..... That eliminated the workflow error. Should ask Max to take a look.

Thanks Karsten.
From: BurrMan
12 May 2016   [#304] In reply to [#303]
The example node error still exists in the construct.js file though.

I'm not going to be running all the created nodes because of such heavy development right now... Maybe Max should just keep "example" updated as needed with any major release... So I don't bug him about "an old node doesn't work...." stuff, when he already knows that, etc....
From: Karsten (KMRQUS)
12 May 2016   [#305] In reply to [#304]
Yes, I had also a look to that node, but I can't see any problems ... recreate it:-)
From: Karsten (KMRQUS)
13 May 2016   [#306] In reply to [#304]
Hello Burrman,

I had another look into the v.0.4 code: The problem is quiet simple - loft node in V0.4 hasn't the feature for closed:-)

Have a nice day
Karsten
From: mkdm
13 May 2016   [#307] In reply to [#288]
Hi Max,

>> added Style property in the Output node

Thank you very much for this new feature!

It's exactly what i wanted.

P.S.

I noticed that the "Circle" node only generates one single circle whatever the input "pointarray" is.

So i wrote a little modified version called "Circles" that generates as many as the points contained in the array.

Furthermore, it is possible to limit the total number of generated circle, to a specified amount.

This amount can be >=1 AND <= the number of points contained in the array.

And is also possible to specify a step amount for the for-loop.

Here's the code :

code:
// Circles
function Circles()
{
	this.addInput("Center","pointarray");
	this.addInput("Radius","number");
	this.addInput("Elements","number");
	this.addInput("Step","number");
	this.addOutput("Out","objectlist");
	this.properties = { radius:1, elements:1, step:1 };
}

Circles.title = "Circles";
Circles.desc = "Circles";

Circles.prototype.onExecute = function()
{
	var output = moi.geometryDatabase.createObjectList();
	var centers = this.getInputData(0, new pointArray());
	var len = centers.getLength();
	this.properties.radius = this.getInputData(1, this.properties.radius);
	this.properties.elements = this.getInputData(2, this.properties.elements);
	if (this.properties.elements <= 0) this.properties.elements = 1;
	this.properties.step = this.getInputData(3, this.properties.step);
	if (this.properties.step <= 0) this.properties.step = 1;
	if (this.properties.step > len) this.properties.step = len;
	for (i = 0; i < len && i < this.properties.elements; i += this.properties.step) {
		var cir = factory( 'circle', true, centers.getFrame(i), null, this.properties.radius );
		output.addObject(cir.item(0));
	}	
	this.setOutputData(0, output);
}

LiteGraph.registerNodeType("Curves/Circles", Circles);



I've also done the "GetBBoxes" node that follow the same logic.

Here's the code :

code:
function GetBBoxes()
{
	this.addInput("In","objectlist");
	this.addInput("Elements","number");
	this.addInput("Step","number");	
	this.addOutput("Out","objectlist");
	this.addOutput("BBox Center","pointarray");
	this.properties = { elements:0, step:1 };

}

GetBBoxes.title = "BoundingBoxes";
GetBBoxes.desc = "Get BoundingBoxes";

GetBBoxes.prototype.onExecute = function()
{
	var input = this.getInputData(0, moi.geometryDatabase.createObjectList());
	var len = input.length;
	var bbox = new pointArray();
	
	this.properties.elements = this.getInputData(1, this.properties.elements);
	if ((this.properties.elements <= 0) || (this.properties.elements > len)) this.properties.elements = len;
	this.properties.step = this.getInputData(2, this.properties.step);
	if (this.properties.step <= 0) this.properties.step = 1;
	if (this.properties.step > len) this.properties.step = len;
		
	this.setOutputData(0, input);
	
	for (i = 0; i < len && i < this.properties.elements; i += this.properties.step) {
		bbox.pushPoint(input.item(i).getBoundingBox().center);
	}
	this.setOutputData(1, bbox);
}

LiteGraph.registerNodeType("Objects/GetBBoxes", GetBBoxes);


Have a nice day.

Marco.

Attachments:
BBoxes.nod
Circles.nod


From: mkdm
13 May 2016   [#308] In reply to [#285]
Hi Karsten,

and thank you for code.

I was examining the code but i must admit that i can't figure out what are the data types that it accepts in input.

code:
function PtArrayConcat()
{
	this.labels = "abcdef";
	this.size = [60,20];
	this.internal = {a:1, b:1};
	this.addOutput("Out", "pointarray");
}


Could you kindly explain ?

Anyway...thanks for your reply.

Nice day.

Marco.
From: Karsten (KMRQUS)
13 May 2016   [#309] In reply to [#308]
Hello Marco,
since yesterday the code is obsolete - Max has implemented the node also in his new version. Nevertheless, inputs are of type pointarray.

A nice weekend
Karsten
From: mkdm
13 May 2016   [#310] In reply to [#309]
Hi Karsten,

thanks anyway and, if you want, take a look at my "Circles" and "GetBBoxes" nodes
that i posted some minutes ago.

Ciao!

Marco.

P.S.

How funny can be playing with nodes !!

Here's my other 3 nodes that follow the same rules of my "Circles" and "GetBBoxes" :

code:
// Cones
function Cones()
{
	this.addInput("Center","pointarray");
	this.addInput("Radius","number");
	this.addInput("Height","number");
	this.addInput("Elements","number");
	this.addInput("Step","number");	
	this.addOutput("Out","objectlist");
	this.properties = { radius:1, height:1, elements:1, step:1 };
}

Cones.title = "Cones";
Cones.desc = "Cones";

Cones.prototype.onExecute = function()
{
	var output = moi.geometryDatabase.createObjectList();
	var centers = this.getInputData(0, new pointArray());
	this.properties.radius = this.getInputData(1, this.properties.radius);
	this.properties.height = this.getInputData(2, this.properties.height);
	var len = centers.getLength();
	this.properties.elements = this.getInputData(3, this.properties.elements);
	if ((this.properties.elements <= 0) || (this.properties.elements > len)) this.properties.elements = len;
	this.properties.step = this.getInputData(4, this.properties.step);
	if (this.properties.step <= 0) this.properties.step = 1;
	if (this.properties.step > len) this.properties.step = len;
	
	for (i = 0; i < len && i < this.properties.elements; i += this.properties.step) {
		var frame = centers.getFrame(i);
		var cone = factory('cone', true, frame, null, this.properties.radius, frame.evaluate(0,0,this.properties.height));
		output.addObject(cone.item(0));
	}
	
	this.setOutputData(0, output);
	
}

LiteGraph.registerNodeType("Solids/Cones", Cones);

// Cylinders
function Cylinders()
{
	this.addInput("Center","pointarray");
	this.addInput("Radius","number");
	this.addInput("Height","number");
	this.addInput("Elements","number");
	this.addInput("Step","number");	
	this.addOutput("Out","objectlist");
	this.properties = { radius:1, height:1, elements:1, step:1 };
}

Cylinders.title = "Cylinders";
Cylinders.desc = "Cylinders";

Cylinders.prototype.onExecute = function()
{
	var output = moi.geometryDatabase.createObjectList();
	var centers = this.getInputData(0, new pointArray());
	this.properties.radius = this.getInputData(1, this.properties.radius);
	this.properties.height = this.getInputData(2, this.properties.height);
	var len = centers.getLength();
	this.properties.elements = this.getInputData(3, this.properties.elements);
	if ((this.properties.elements <= 0) || (this.properties.elements > len)) this.properties.elements = len;
	this.properties.step = this.getInputData(4, this.properties.step);
	if (this.properties.step <= 0) this.properties.step = 1;
	if (this.properties.step > len) this.properties.step = len;
	
	for (i = 0; i < len && i < this.properties.elements; i += this.properties.step) {
		var frame = centers.getFrame(i);
		var cylF = moi.command.createFactory( 'cylinder' );
		cylF.setInput(0, true);
		cylF.setInput(1, frame);
		cylF.setInput(3, this.properties.radius);
		cylF.setInput(4, frame.evaluate(0,0,this.properties.height));
		var cyl = cylF.calculate();	
		output.addObject(cyl.item(0));
		cylF.cancel();
	}
	
	this.setOutputData(0, output);	
}

LiteGraph.registerNodeType("Solids/Cylinders", Cylinders);

// Spheres
function Spheres()
{
//	this.size = [60,20];
	this.addInput("Center","pointarray");
	this.addInput("Radius","number");
	this.addInput("Elements","number");
	this.addInput("Step","number");		
	this.addOutput("Out","objectlist");
	this.properties = { radius:1, height:1, elements:1, step:1 };
	
}

Spheres.title = "Spheres";
Spheres.desc = "Spheres";

Spheres.prototype.onExecute = function()
{
	var output = moi.geometryDatabase.createObjectList();
	var centers = this.getInputData(0, new pointArray());
	this.properties.radius = this.getInputData(1, this.properties.radius);
	var len = centers.getLength();
	this.properties.elements = this.getInputData(2, this.properties.elements);
	if ((this.properties.elements <= 0) || (this.properties.elements > len)) this.properties.elements = len;
	this.properties.step = this.getInputData(3, this.properties.step);
	if (this.properties.step <= 0) this.properties.step = 1;
	if (this.properties.step > len) this.properties.step = len;
	
	for (i = 0; i < len && i < this.properties.elements; i += this.properties.step) {
		var frame = centers.getFrame(i);
		var sphF = moi.command.createFactory( 'sphere' );
		sphF.setInput(0, true);
		sphF.setInput(1, frame);
		sphF.setInput(3, this.properties.radius);
		var sph = sphF.calculate();	
		output.addObject(sph.item(0));
		sphF.cancel();
	}
	
	this.setOutputData(0, output);
	
}

LiteGraph.registerNodeType("Solids/Spheres", Spheres);

Attachments:
CylsAndCones.nod


Show messages:  1-10  …  231-250  251-270  271-290  291-310  311-330  331-350  351-370  …  911-912