The script for chain
 1-20  21-40  41-60  61-80

Previous
Next
 From:  bemfarmer
6087.41 In reply to 6087.40 
Latest ChainMaker script.
Array Dir works to array the links on a base line.
Still cannot get Flow to work. One of the inputs must be wrong. It gets to a point were I run out of things to try.

EDITED: 19 Aug 2013 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  BurrMan
6087.42 In reply to 6087.41 
Hey Bem,
Thats a great result already. Unwrapping the flow curve and leaving it allows to just run a rigid flow with the 2 curves quickly and get a result.

I suppose if you automate the flow it will be complete, but it's already a great command...

Thanks.
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  BurrMan
6087.43 In reply to 6087.42 
I wonder if you can just get to that point there, Have the end of your command select all solids, then launch the regular flow command? Pick the curves and done.
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  BurrMan
6087.44 In reply to 6087.43 
So for instance, I just made a copy of the flow command and named it ChainFlow, then I copied the code for ChainMaker js and htm to the top part of the new ChainFlow.

It "looks" like it could work, but both commands are running at the same time.

Is there a "pause here until finished" that could be added? The flow is waiting while chainmaker is running. Once chanmaker is done, it accepts the input curve, but wont pick the target. So they need to be seperated...

Michael,
Can a js call "DoChainMaker();" wait, then call "DoFlow();"? (Or "Function DoChain, FunctionDoFlow) with includes or something like that?
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
6087.45 In reply to 6087.43 
Thank you Burr :-)
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
6087.46 In reply to 6087.44 
Hi Burr,

> Michael,
> Can a js call "DoChainMaker();" wait, then call "DoFlow();"? (Or "Function DoChain, FunctionDoFlow)
> with includes or something like that?

Not really just by including just the existing flow command, because usually the regular commands are pretty intertwined with their UI as well.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
6087.47 In reply to 6087.41 
Hi Brian, so I looked into why Flow is not working, and one thing is for flow input index 1, the base curve that should be a curve object and not an object list, so these lines:

code:
	factory.setInput( 0, chainobj );
//	var baseline = baselineobj.item(0);
	factory.setInput( 1, baselineobj );
	factory.setInput( 2, targetCurve );


should have these 2 lines changed like this:

code:
	factory.setInput( 0, chainobj );
	var baseline = baselineobj.item(0);   // <<< enable this line that you tried before.
	factory.setInput( 1, baseline );       // <<< put in the curve, not the object list here.
	factory.setInput( 2, targetCurve );



But then there's an additional problem which is that the results from arraydir are not returned back to you - that's because of a mechanism in the array commands where during calls to .update(), they don't actually create full object copies and instead make a special lightweight "proxy" object (sort of like an instance) that can be constructed more quickly than an actual full object copy and so that keeps the display more interactive while doing some large number of arrayed items and placing points around. But it's messing up your script in this case because at the time the script calls getCreatedObjects() the system doesn't think any full objects have been created yet because of this special proxy object creation being done instead.

Proxy making is turned off when you do a .commit() but then also at that point the factory considers itself to be completely finished and clears its created object list at that time so you can't call .getCreatedObjects() at that time. Proxy generation is also turned off though if you call .calculate() so for now the solution will be to call .calculate() on the arraydir factory rather than update/getCreatedObjects/commit and also you'll need to add the results of calculate into the geometry database so they will work with the async flow factory.

So that means changing the array section from this:
code:
	var arrayfactory = moi.command.createFactory( 'arraydir' );
	arrayfactory.setInput( 0, linklist1 );
//	arrayfactory.setInput( 1, 5 );
	arrayfactory.setInput( 2, baseStartPt );
	arrayfactory.setInput( 3, offsetPt2 );
	arrayfactory.setInput( 4, baseExtentEndPt );
	arrayfactory.setInput( 5, "Offset, Extent" );
	arrayfactory.update();
	var chainobj = arrayfactory.getCreatedObjects();
//	var chain = chainobj.item(0);  This line does not help.
	arrayfactory.commit();
	factories.push( arrayfactory );	


To this instead:

code:
	var arrayfactory = moi.command.createFactory( 'arraydir' );
	arrayfactory.setInput( 0, linklist1 );
//	arrayfactory.setInput( 1, 5 );
	arrayfactory.setInput( 2, baseStartPt );
	arrayfactory.setInput( 3, offsetPt2 );
	arrayfactory.setInput( 4, baseExtentEndPt );
	arrayfactory.setInput( 5, "Offset, Extent" );
	var chainobj = arrayfactory.calculate();   // <<<<<
	moi.geometryDatabase.addObjects( chainobj ); // <<<<<


After those 2 changes then the flow part should work.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
6087.48 In reply to 6087.47 
Thank you again Michael.

I started a text file of a bunch of your script explanations. It is good for review and recollection.

There is no way I would ever have figured it out!

Installed the changes, and Flow does work! It took about 3.5 seconds.

Some tentative observations:
The first two links are missing...I think.
I think end selection of the target curve selection is not working either.

I think there is some cleanup to do on the script also.
Undo leaves link2 persisting...

More work to do tomorrow.

:-)

-Brian

EDITED: 19 Aug 2013 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
6087.49 In reply to 6087.48 
Hi Brian, yeah really the whole current system is tuned more for a combination of some script more for "control flow" plus some C++ backend that does the actual geometry creation. It's not really specifically tuned for someone who's doing all script for everything as you've been doing.

I had been originally hoping that just one "factory" mechanism would work for everything but I think it's getting fairly clear that it would be better for larger scripts to have their own methods to call like createLine( start, end ) and stuff like that rather than running everything through the factory mechanism. The factory mechanism has some complexity to it since it's tuned for generating each thing in an interactive way like how the line command runs rather than just creating a specific line for example.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
6087.50 In reply to 6087.49 
Good morning Michael.
Thank you again for all of your help with this scripting.
Your MoI interactive programming is top knotch. To me the interactive programming seems
that it must have been ten times harder to do and understand than doing these bulk scripts, which work pretty well,
once the inputs are figured out.


Last night, I tried to attach or append link1 and link2 to the array chainobj, but was unable to do it properly, so this morning
I moved the flow base line over to the right by 2 links, to get around the array "leaving out" link1 and link2, and now the
flow works properly, starting from the start of the target curve.

The flow takes about 3 seconds for a 15 link chain, which is normal.

Have not done a twisted chainlink option yet. Undo leaves a link2 residue.
Need to clean up the script a bit also. Factories are not needed.

Note that this script does not adjust the chain length, nor the link length, to match the endpoint. So there is
"left over" chain link portion at the end.

Edit: Hmm, Rigid is not working...

- Brian

EDITED: 19 Aug 2013 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
6087.51 In reply to 6087.50 
Hi Brian, re: rigid not working -

The factory is expecting a boolean true/false property for that parameter, not a string, so change:

factory.setInput( 5, 'rigid' );

to instead be:

factory.setInput( 5, true );


If you see in the UI that it's using a checkbox control hooked into the property, that's going to give a true/false value out of it.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
6087.52 In reply to 6087.51 
:-)
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
6087.53 In reply to 6087.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

EDITED: 7 Jul 2014 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  BurrMan
6087.54 In reply to 6087.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.
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
6087.55 In reply to 6087.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
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  BurrMan
6087.56 In reply to 6087.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
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
6087.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
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
6087.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

EDITED: 22 Aug 2013 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
6087.59 In reply to 6087.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
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
6087.60 In reply to 6087.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

EDITED: 22 Aug 2013 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All

 

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