Need help with arraycurve factory

Next
 From:  Karsten (KMRQUS)
7784.1 
Hello,

I have a problem to get an arraycurve factory run in a script in 'ArrayCurveDistance' mode. The following code generates always points on the end of the curve. Is there an example script? The standard command script doesn't help me. The code should generate Points with individual distance depending on an array (NVA)


var NVA = NormalilzeVA(this.properties.DivNumProfile, 1);
var curvePts = moi.geometryDatabase.createObjectList();
var curvePt = moi.geometryDatabase.createObjectList();
var distlength;
for(i=0; i < NVA.length; i++)
{
distlength=NVA[i]*crvlength(profile);
var curvePtFac = moi.command.createFactory('arraycurve');
curvePtFac.setInput(0, curveStartPt); // geomobject to array on the curve
curvePtFac.setInput(1, profile.item(0)); // the profilecurve
curvePtFac.setInput(2,'ArrayCurveDistance'); // array mode Distance
curvePtFac.setInput(3, 2); // number of generated element (here startpoint of the curve and a second one at a distance on the curve
curvePtFac.setInput( 4, distlength); //distance between the startpoint and the calculated point on the curve
curvePt = curvePtFac.calculate();
curvePts.addObject(curvePt.item(0));
curvePtFac.cancel();
for (i = 0; i < curvePts.length; i++)
outObj.addObject(curvePts.item(i));
this.setOutputData(0, outObj);
}

Thanks in Advance!

Kind regards
Karsten
  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
7784.2 In reply to 7784.1 
The Chain script utilized Array Dir, so checking that thread and script may help.
Michael provided a huge amount of help.
- Brian

EDITED: 19 Dec 2015 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:  Karsten (KMRQUS)
7784.3 In reply to 7784.2 
Hello Brian,
Thanks a lot! I will have a look at this!

Kind regards
Karsten
  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
7784.4 In reply to 7784.3 
Good luck Karsten.
Family matters beckon.
I'd have to do some study to even attempt to help :-)
- 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:  Michael Gibson
7784.5 In reply to 7784.1 
Hi Karsten, so from a quick look over it, you need to modify how you're setting input index number 2:

Array curve input 2 is the mode, it can be either 'NumItems' or 'Distance'. Don't use 'ArrayCurveDistance' - that's something separate from the factory, the ArrayCurve.js script stores a property for 'ArrayCurveDistance' to remember the last used distance to re-initialize the distance the next time the command is run.

Array curve input 3 is an integer for the number of items in 'NumItems' mode.

Array curve input 4 is the distance value for 'Distance' mode.

Let me know if you are still stuck after that.

- 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:  Karsten (KMRQUS)
7784.6 In reply to 7784.5 
Hello Michael,

thank You for your reply. I have tested 'Distance' also, but have also a problem.
First I would explain what I want to do. I want to take an array of values.
If the array has only one value, I want to generate a arraycurve in 'NumItems' mode.(works)
If the array has more than one value, it should generate points for every value in the array.
The value itself should control the position on the curve. The idea was to use arraycurve for
every value and use only the first generated point,
store it and throw the rest away.
I didn't get an error, but the Moi crashes.
My last try was to generate a separate Factory for every value - without success. I've attached my actual file.

It would help me a lot, if you would have a look.

Thanks in advance!

Kind regards
Karsten
Attachments:

  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
7784.7 In reply to 7784.6 
Hi Karsten, I tried running your SubDiv.js file as a command in MoI, and I get an error:

ReferenceError: Can't find variable: LiteGraph

SubDiv.js line 186


Looks like your file has dependencies on a lot of other stuff possibly?

Can you narrow down your script to just have a self contained runnable piece that tries to do the ArrayCurve stuff that you're talking about? That would make it a lot easier for me to test it and figure out what's going wrong with just that one area of the script.

- 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
7784.8 In reply to 7784.6 
Hi Karsten,

Since you have "NumItems" mode working, the script problem would seem to not be a problem with arraycurve, rather with other logic.

The "Distance" mode is very busy. Can it not be simplified until it works, then add the complications?
Say NVA has 5 distance items. I agree that arraycurve should be ran 5 times. You create Factory 5 times, and save them to an javascript array called curvePtFactories,
and then later do another loop. Why not incorporate this loop into the "Distance" arraycurve for loop, and run one factory at a time?

- Brian

Do you have SubD/Sweep Node examples?

In debug mode, I was wondering where this.setOutputData( 3, NVA ) shows up? On Screen? In Editor?
What Editor do you use?

EDITED: 20 Dec 2015 by BEMFARMER

Image Attachments:
Size: 20.9 KB, Downloaded: 42 times, Dimensions: 583x209px
  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:  Karsten (KMRQUS)
7784.9 In reply to 7784.8 
Hello Brian,

Thank You for your reply. It was an act of desperation. I've tried a lot of different ways to do that, but till now, nothing works for me. That's why the file is so chaotic. At the moment, I think, my problem is to store/evaluate points from the factory output. I don't know - I'm very confused about JavaSript and the moi-api at the moment. Since yesterday I use netbeans. Before I used SciTE. I agree with you about the load of many factories, but for exact solution I don't know another way. At the moment I try to make an approximation to do that. One factory with lots of points - and find nearest for the parameter in the valuearray - that's leads me to the supposition, that the right access to the factory output is my problem, because I have the same problem.

-Karsten
  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:  Karsten (KMRQUS)
7784.10 In reply to 7784.9 
p.s.: The debug option is not controlled by the editor - I did it manually, to check the state of some inner stuff. For me it's a good way to find that later and erase it.
  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
7784.11 In reply to 7784.9 
Hi Karsten, if you can simplify your script to just stuff relating to your array curve question, that would help me to give you some advice on what to do. I could not run your script you posted above because it triggers a script error as described above.

Right now it's hard for me to see what's wrong with your script since I can't run it over here.

- 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:  Karsten (KMRQUS)
7784.12 
Hello Michael, Hello Brian,

I've solved my problems and there were a lot:-( Bugs with naming, logic, wrong types, and so on .... Nevertheless the notices you have got - reduce complexity, test only the functionality has bring me back on my way.

Thanks for that.

I have attached a picture , which shows what the function should do earlier:-)

Have a nice day
Krsten


Attachments:

  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
7784.13 In reply to 7784.12 
Hi Karsten, that's great that you've got it figured out now!

- 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
 From:  Frenchy Pilou (PILOU)
7784.14 
Appetizing! :)
  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