Script-Problem - Access to point-components
All  1  2-5

Previous
Next
 From:  Michael Gibson
6622.2 In reply to 6622.1 
Hi Karsten, so it looks like you almost have it - to get the components of a point you should use the .x .y .z properties just like you are doing currently.

I think the problem is on line 216, where you're trying to extract points from the result of the arraycurve:

var nx=moi.vectorMath.createPoint(arrayed_pts.item(iPts).pt);


The vectorMath.createPoint() function only expects to take 3 coordinates as its input - here it's being passed another point object instead of coordinates and so it's probably generating garbage out.

Try doing this on this line instead:

var nx=arrayed_pts.item(iPts).pt;



Also it looks like a proper array point of points is being assembled in the "pts" array, so you could try using that instead of ptx.

One of the things that's kind of confusing about these points is that there are 2 kinds of points being worked with here - one is a "point object" which is the type of thing that can be created in MoI under Draw curve > More > Point, and it can have all kinds of properties same as curves or solids like hidden, locked, name, style assignment, selection, etc... - then the second kind of point is a "point data structure" which is much more basic and only has .x .y .z properties and none of that other stuff with it. When you have a "point object" you can retreive the "data structure point" from it by the .pt property.

Hope this helps!

- 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)
6622.3 In reply to 6622.2 
Hello Michael,

thank you for the Information. I tried to use the pts-array instead of a new one, but the Loop "for ( var n = 0; n < (pts.length-2); ++n )" seems not to be processed. If I replace the expression pts.length with a fixed value I got an error-message in the line
"cp=csp(pts[n].x,pts[n].y,pts[n].z,pts[n+1].x,pts[n+1].y,pts[n+1].z,pts[n+2].x,pts[n+2].y,pts[n+2].z);" that the object "pts[n+1]" does not exist. It seems that the array is empty??? Any ideas!

Thank you very much!
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:  Michael Gibson
6622.4 In reply to 6622.3 
Hi Karsten, yeah it looks like you're missing one thing on the array curve factory - you need to set the number of items for the factory to build. The ReconstructCurve command that you're based off does this in an "Update()" function, like this:

Factories[i][0].setInput( 3, NumItems );


So before you call .calculate() on the arraycurve factory to generate the arrayed points, you need to set that input index 3 to have the number of points you want to generate, something like this (the >>>>>> <<<<< indicates the added line):

code:
       var Factory = moi.command.createFactory( 'arraycurve' ); //arraycurve erzeugt ein array entlang einer Kurve - Eingabe ist in der naechsten ZEile der Startpunkt der Kurve
       Factory.setInput( 0, startPtObject );		// object (list)
       Factory.setInput( 1, originalCrv );		// path
       Factory.setInput( 2, 'NumItems' );		// array mode

>>>>>> Factory.setInput( 3, 20 ); // Make 20 arrayed items <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

       Factories[i][0] = Factory;                      // in Factory sind die Punkte
       var arrayed_pts = Factories[i][0].calculate();





Does that help?

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

thank you very much for the information! Yes that helps! The frustration goes and the joy of experimenting is coming back:-)
Now I will try to understand how to integrate the function in the update-mechanism.

Thank You for that great software!

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
 

Reply to All Reply to All

 

 
 
Show messages: All  1  2-5