Linear Motion

In this next example, a flow-driven, linear motion object is created. A spring-type resistive force is also defined:

a.selectionMode = "Volume";

m = new Motion("Flow-Driven Linear");

m.setDirection(1.0, 0.0, 0.0);

m.initialPosition = -0.2;

m.minimum = 0.0;

m.maximum = 0.7;

p = m.property("Resistive Force");

v = p.variation("Spring");

v.setValue("Engagement Displacement", 0.0, "inch");

v.setValue("Compression Displacement", 0.7, "inch");

v.setValue("Engagement Force", 0.5, "lbf");

v.setValue("Compression Force", 10, "lbf");

p.apply(v);

a.select("VALVE-DOOR");

a.applyMotion(m);

A line-by-line description follows:

The selection mode is set to volume, and a new motion object called “m” is created. The object is set to flow-driven linear:

a.selectionMode = "Volume";

m = new Motion("Flow-Driven Linear");

The direction of motion, initial position, and bounds are set. These commands are found on the Motion task manager in the User Interface:

m.setDirection(1.0, 0.0, 0.0);

m.initialPosition = -0.2;

m.minimum = 0.0;

m.maximum = 0.7;

A property object called “p” is created, and is set to type Resistive Force. A variation method called “v” is created, and is set to type Spring. The parameters of the spring are then defined. These commands are found on the Motion Editor of the User Interface:

p = m.property("Resistive Force");

v = p.variation("Spring");

v.setValue("Engagement Displacement", 0.0, "inch");

v.setValue("Compression Displacement", 0.7, "inch");

v.setValue("Engagement Force", 0.5, "lbf");

v.setValue("Compression Force", 10, "lbf");

p.apply(v);

The part called VALVE-DOOR is selected, and the motion applied to it.

a.select("VALVE-DOOR");

a.applyMotion(m);