MoI discussion forum
MoI discussion forum

Full Version: The script for chain

Show messages:  1-12  13-32  33-52  53-72  73-80

From: bemfarmer
19 Aug 2013   [#53] In reply to [#51]
Added checkboxes for Twist chain and Rigid chain.

Having a faulty input #5 for Flow, incorrect string instead of the proper true/false variable Rigid,
resulted in the very slow Flow timing!!
Now Flow take less than one second, instead of 3.5 seconds.

After Link1 and Link2 no longer needed for future factories, removed them from the geometry.

Need to do cleanup of removing the factory results, in the event the cancel button is pressed.

Need to do a Twisted link.

- Brian
From: BurrMan
19 Aug 2013   [#54] In reply to [#53]
I like the fact that you left the option to remove rigid. It allows you to make a "chainlike" form, which is cool too.
From: bemfarmer
19 Aug 2013   [#55] In reply to [#54]
Thank you BurrMan.
The script still needs more work.
The checkboxes are hard to access. Several factory (s) need to be canceled or cleared out...
Have to check Michaels scripts to do this properly...

Flowing a chain around a rectangle is so-so in rigid mode, and makes weird corners in non-rigid mode.
Small radii curves cause chain overlap in rigid mode, and curved links in non-rigid mode.

- Brian
From: BurrMan
20 Aug 2013   [#56] In reply to [#55]
The chain needs to be made in Rigid mode, and any small kinks will just have to be manaually manipulated. I dont think there will be anything you could do about that without extensive development.

The non rigid is good for that. We bent links all the time on heavy lifts, though "not recommended"... :o
From: bemfarmer
20 Aug 2013   [#57]
Took another look at LineWeb script, and Pipe2 script, which both use several factory(s).
(The plural of factory denoted with (s), because "factories" is used as an array in some scripts.)

LineWeb deals with points and objects made from points, and factories which are arrays.

Pipe2 has PushButton Update which I'll try to add to the chain script, including removing objects appropriately.

- Brian
From: bemfarmer
22 Aug 2013   [#58]
Hi Michael

I am having trouble removing three things from the geometryDatabase, in order to prevent the creation of multiple copies of chains.

The first one is chainobj, which is an input to the FLOW factory.

The second one is baselineobj, whose first item is baseline, an input to the FLOW factory. (I haven't tried removing baseline from the geometryDatabase.)

The third one is flowedchainobj, which is the output of the chain factory.

My current theory is that asynchronous FLOW factory is interfering with the removal from the geometry Database.

For example the command: moi.geometryDatabase.removeObjects( chainobj ); placed before FLOW, does remove the arrayed chain from the screen.
However, placing it after FLOW does not appear to have any removal effect, and multiple chains can be created on top of each other by repeated updates.

FLOW commit does not seem to help.

Any Ideas?

Thankyou
- Brian
From: Michael Gibson
22 Aug 2013   [#59] In reply to [#58]
Hi Brian, you probably want to avoid calling .commit() on the various in-between factories. For a regular command, factory.commit() signals to the factory that the command has completely finished and the factory is completely done, once you call .commit() any further call to .cancel() won't do anything. Basically .commit() and .cancel() are mutually exclusive to one another.

Also any factory that has been created during a command goes on the "active factory list", and if the command ends without .commit() ever getting called, it will get automatically canceled during the command end cleanup processing. Either a .commit() or a .cancel() will pull that factory off of the active factory list, since it's considered to be completed after either of those calls.

So anyway probably if you just don't call .commit() for the things you don't want to persist in the geometry database that may cover it.

Otherwise if you do call .commit() you will have to manually remove things you don't want from the geometry database.

If you want to have factories remove the stuff they were showing in response to .update(), you can either call .cancel() on them if you're going to still be running the command (like for parameters changing), or if the command is ending you can actually just not do anything and then .cancel() gets called automatically for any active factory at the command end.

Does that make sense? Let me know if you are still having problems.

- Michael
From: bemfarmer
22 Aug 2013   [#60] In reply to [#59]
Thank you Michael
EDIT: Your descriptions ARE helping.


My script is flawed, and also my understanding . The pipe2 script is becoming more understandable, so I am going to adopt
its methods even more. Lineweb is helpful too.

I think I will make some more changes in my script, and even use a javascript array or two, and more subroutines.

I'm starting to think that .calculate() is more user friendly than .getCreatedObjects() ?

EDIT: Making a little progress. I had left out a few important things, and put in a few poor things. :-)

- Brian
From: bemfarmer
23 Aug 2013   [#61]
Thought of the day: Chain links are like "Bones" in an animation program ?

Another thought: script to copy an object, based upon two points, to another location with two points... OK in 2D ?
Maybe ArrayGem does this.

- Brian
From: Michael Gibson
23 Aug 2013   [#62] In reply to [#61]
Hi Brian,

> Another thought: script to copy an object, based upon two points, to another location with two points... OK in 2D ?
> Maybe ArrayGem does this.

Check out Transform > Orient > Line to line - it does that kind of transformation, which is just basically a move from one line's start point to the other line's start point, and then a rotation by the angle between them (and optionally a scale by the difference in length between them too).

It works like this:




ArrayGem is a slightly different, it builds a "base frame" around the starting circle, and then figures out a target frame that is oriented around the surface normal and then does a frame-to-frame transformation which is also really just a move + rotation as well though.

- Michael
From: bemfarmer
23 Aug 2013   [#63] In reply to [#62]
Thanks Michael

I'll try it out.

(Still working on the chain script, slowly :-) )

- Brian
From: mattj (MATTJENN)
24 Aug 2013   [#64] In reply to [#63]
Keep up the good work on the chain script, its looking good!!
matt
From: bemfarmer
25 Aug 2013   [#65]
After a lot of failure, trying to delete flowed chain outside of the subroutine, FINALLY
got it to work, using example of spur gear script, by assigning a chainList = Update(...). So simple and hard. :-)
Fixed simple link length, non-Updateable missing code.

Now to work on twist.

- Brian
From: Ditto
25 Aug 2013   [#66] In reply to [#65]
Bravo, bravo, bravo! Hats off for your tenacity, Brian!
From: bemfarmer
25 Aug 2013   [#67]
Implemented the option to Twist the individual chain links.

Note that some trial and error, guided by the many helpful explanations of Michael, was necessary in order to discover
that Input "0" of the Twist factory would work with sweeplist, from var sweeplist = sweepfactory.calculate();,
but would not work with link1, from var link1 = sweeplist.item(0);.
Also, it was not necessary, in this case anyway, to add sweeplist to the moi.geometryDatabase with moi.geometryDatabase.addObjects( sweeplist );.

As an alternative test, the rail based upon a rounded rectangle worked well with the Twist factory, and would be another way to Twist the first chain link.
Twisting the rail is not done in the current version of the script.

There are several possibilities for the Twist axis. The one used seemed to look well.

The script worked well on one test 3d curve.


ArrayGem in 3d would need a surface for normal.
Chopping the curve up into points which are equally spaced in space, not necessarily equally spaced along the curve, and then
doing a copy to two points is another possibility, but probably needs normal also, in 3D.

This completes the chain script, for now.

I should probably delete old versions...?

- Brian

Attachments:
ChainMakerAug25_2013PM.7z


From: Michael Gibson
26 Aug 2013   [#68] In reply to [#67]
Seems to work really well Brian!





- Michael

Image Attachments:
chain1.jpg  chain2.jpg 


From: krass
27 Aug 2013   [#69] In reply to [#68]
WOW! Great job!
From: BurrMan
27 Aug 2013   [#70] In reply to [#67]
SWEET Bem,

""""""""""I should probably delete old versions...?""""""""""""

I would leave them, in case others are following. But, at some point, you'll need space. Might have to start using skydrive or something, or the future generatinons will loose your input! :o
From: bemfarmer
27 Aug 2013   [#71] In reply to [#70]
Thank you Burr. Maybe next winter for "skydrive" or some such.
- Brian
From: Michael Gibson
27 Aug 2013   [#72] In reply to [#71]
These particular files are super tiny though, like 3KB apiece, so they won't fill anything up for a long time...

Usually it's 3DM files with a lot of stuff in them that tends to fill up attachment space quickly. If you have a big 3DM file to share, that's what can be good to put on a file sharing service like skydrive or dropbox, etc...

- Michael

Show messages:  1-12  13-32  33-52  53-72  73-80