MoI discussion forum
MoI discussion forum

Full Version: The script for chain

Show messages:  1-20  21-40  41-60  61-80

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
From: Mauro (M-DYNAMICS)
28 Aug 2013   [#73]
Thank you Brian ! :)
From: bemfarmer
28 Aug 2013   [#74]
If anyone wants to "hang" a chain, there is a catenary script on the forum, which works fairly well with a good radius guess.
I want to improve it by adding bisection, and re-examine the code.

- Brian
From: Bravlin
11 Nov 2018   [#75]
If i want "arraydir" command to start in "Extent, Count" mode, what Key script should i use ?
From: Michael Gibson
11 Nov 2018   [#76] In reply to [#75]
Hi Bravlin,

re:
> If i want "arraydir" command to start in "Extent, Count" mode, what Key script should i use ?

It's not possible currently because of the space character in there. I should be able to fix this for the next v4 beta though by making quote " " characters affect the parameter parsing for command parameters.

The current method breaks things into separate parameters just by spaces so it breaks that "Extent, Count" into 2 parameters instead of just keeping it as one.

I'll see if I can make both "mode=Extent, Count" or mode="Extent, Count" work.

- Michael
From: Bravlin
11 Nov 2018   [#77] In reply to [#76]
If key script with args is not available, maybe you can give us an advice on how to build simple .js plugins for this purpose ?
From: Michael Gibson
11 Nov 2018   [#78] In reply to [#77]
Hi Bravlin, yes a hack that will work right now would be to make copies of the 2 files ArrayDir.js and ArrayDir.htm which are in the commands subfolder. Name the copies something like ArrayDir2.js and ArrayDir2.htm and that will then make a command named ArrayDir2 available.

Inside ArrayDir2.htm find line 33 which makes the mode dropdown, it currently looks like this:
code:
	<moi:Select id="Mode">
		<moi:Option value="Offset, Count" textid="ArrayDir mode Offset, Count" />
		<moi:Option value="Extent, Count" textid="ArrayDir mode Extent, Count" />
		<moi:Option value="Offset, Extent" textid="ArrayDir mode Offset, Extent" />
	</moi:Select>


That will default to the first one in the list, but you can add a default="" attribute to control the initial default, so you want it to look like this:

code:
	<moi:Select id="Mode" default="Extent, Count">
		<moi:Option value="Offset, Count" textid="ArrayDir mode Offset, Count" />
		<moi:Option value="Extent, Count" textid="ArrayDir mode Extent, Count" />
		<moi:Option value="Offset, Extent" textid="ArrayDir mode Offset, Extent" />
	</moi:Select>


- Michael
From: Bravlin
15 Nov 2018   [#79] In reply to [#78]
Thanks Michael. It helps a lot. Maybe you also have some guides to moi script or hints & tricks page ?
From: Michael Gibson
15 Nov 2018   [#80] In reply to [#79]
Hi Bravlin, there isn't very much on scripting documentation, what is available is here though: http://moi3d.com/wiki/Scripting .

I do have a fix for the next v4 beta where you'll be able to use " " characters in a shortcut key for values that have spaces in them.

- Michael

Show messages:  1-20  21-40  41-60  61-80