MoI discussion forum
MoI discussion forum

Full Version: Loft factory question

Show messages: All  1-15  16-20

From: Martin (MARTIN3D)
22 Oct 2012   [#16] In reply to [#15]
Hi Michael,

I'm actually quite happy with the way scripting MoI works right now. When I use it in the same way as I would do things manually i.e. just use .commit() and a .selectAll() / .invertSelection() / deselectAll() combo to put things into the next factory I already can do anything I want. It just requires careful planning and keeping track of whats selected and whats not.

If in the next beta the .update() / getCreatedObjects() / .cancel() combo works for sweeps and booleans using variables will make scripting even easier because I can use object.selected = true; or objectlist.setProperty('selected', true);


And if its just for easier coding I can already have that with an external Javascript file.
Your line example could already be as simple as

code:
#include "scriptLibrary.js"
drawLine( pt(0,0,0), pt(10,10,0) );


by using an external scriptLibrary.js file:
code:
function pt(x, y, z) {
	var pt = moi.vectorMath.createPoint( x, y, z );
	return pt;
}

function drawLine(pt1, pt2) {
	var factory = moi.command.createFactory( "line" );
	factory.setInput( 0, pt1 );
	factory.setInput( 1, pt2 );
	factory.commit();
}


or a circle:
code:
function pt(x, y, z) {
	var pt = moi.vectorMath.createPoint( x, y, z );
	return pt;
}

function drawCircle(orientation, center, radius) {
	switch (orientation) {
	case "Top":
		var frame = moi.vectorMath.createTopFrame();
		break;
	case "Front":
		var frame = moi.vectorMath.createFrontFrame();
		break;
	case "Right":
		var frame = moi.vectorMath.createRightFrame();
		break;
}
	
	frame.origin = center;
	var factory = moi.command.createFactory( 'circle' );
	factory.setInput( 1, frame );
	factory.setInput( 3, radius );
	factory.commit();
}

drawCircle("Front", pt(0,0,0), 100);


I can see many factories simplyfied like this and not neccessarily a need for an additional simplyfied scripting layer that would break backwards compatibility.
From: bemfarmer
4 Feb 2018   [#17] In reply to [#6]
Hi Michael,
I'd forgotten about this old subject, but have a question.

Rather than dragging the marker point of the seam, shown during Loft, is it possible to just enter a point, or coordinates or object list of a previously picked
point on the curve for, say, the orientations list input of Loft, or say the EditOrientations.js?

I'm trying to script changing the start point of an ellipse, using the loft method that has been previously posted.
http://moi3d.com/forum/index.php?webtag=MOI

- Brian
From: Michael Gibson
4 Feb 2018   [#18] In reply to [#17]
Hi Brian,

> Rather than dragging the marker point of the seam, shown during Loft, is it possible to just enter
> a point, or coordinates or object list of a previously picked
> point on the curve for, say, the orientations list input of Loft, or say the EditOrientations.js?

So you mean in your own script that you're making, not typing in coordinates in the regular Loft command, right?

I'm not sure if that's possible currently - one thing you can try though is if you run .update() on the Loft factory, the curve orientation input (input index 1 on the loft factory) should get filled in with a default orientation list. It should then be possible to modify that list, you can get it I think by factory.getInput(1).getValue(); that will be a list object, each item in the list is a CurveOrientation object which has 2 properties: flipped and seam which can be modified.

The seam point though is a normalized parameter value, with 0.0 meaning the start of the original curve and 1.0 meaning the end of the curve, and 0.5 meaning the middle of the curve's parameter space, not necessarily the middle of the arc length distance of the curve.

- Michael
From: bemfarmer
4 Feb 2018   [#19] In reply to [#18]
Thank you Michael.

I'll do some tests.

I guess that the "curve's parameter space" has to do with the NURBS representation?

- Brian

Using cPlane at the centerpoint, I'm intersecting the "waist" of an extruded (or lofted) pair of circles, (an oblique cylinder), with
a plane, which is a "belt" ellipse. (Like a person with a belt around the waist.)
The ellipse formed often has a different start point than the starting cylinder. I'm trying to move the start point to match the cylinder seam.
It is easy interactively, with a specific cylinder...
From: Michael Gibson
4 Feb 2018   [#20] In reply to [#19]
Hi Brian,

> I guess that the "curve's parameter space" has to do with the NURBS representation?

Yup, there is a range of numbers called the "knot vector" which sets a minimum and maximum value for the parameter space range. Evaluating the curve at the start parameter yields the start point of the curve, evaluating the curve at the end parameter gives the end point of the curve.

- Michael

Show messages: All  1-15  16-20