Getting all points of a curve using a script
 1-12  13-32  33-42

Previous
Next
 From:  Max Smirnov (SMIRNOV)
6257.13 
I've found solution of this problem several months ago.
This method is stupid, but it's works. :)

en code:
function GetCurveControlPoints(curve)
{
	var gd = moi.geometryDatabase;
	var obj = gd.getObjects();
	obj.setProperty( 'showPoints', false); 
	curve.showPoints = true; 
	gd.selectAll();
	obj.setProperty( 'selected', false);
	
	var objectpicker = moi.ui.createObjectPicker();
	objectpicker.allowEditPoints();
	objectpicker.done();
	gd.copyToClipboardCommand( objectpicker.objects );
	gd.pasteFromClipboard();	
	var points = gd.getSelectedObjects();

	gd.removeObjects(points);	
	curve.showPoints = false; 
	return points;
}

/* example */
var curves = moi.geometryDatabase.getSelectedObjects().getCurves();	
if (curves.length === 1)
{
	pts = GetCurveControlPoints(curves.item(0));
	/* let's build polyline through control points */
	var factory = moi.command.createFactory( 'curve' );
	for ( var p = 0; p < pts.length; ++p)
	{
		factory.createInput('point');	
		factory.setInput(factory.numInputs - 1, pts.item(p).pt); // point
		factory.createInput('bool');	
		factory.setInput(factory.numInputs - 1, true);  // corner
	}
	if  (curves.item(0).isClosed)
	{
		factory.createInput('point');	
		factory.setInput(factory.numInputs - 1, pts.item(0).pt);
		factory.createInput('bool');	
		factory.setInput(factory.numInputs - 1, true);
	}
	factory.commit();
}

EDITED: 7 Mar 2022 by SMIRNOV

  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:  Martin (MARTIN3D)
6257.14 In reply to 6257.13 
Hi Max,

although it doesn't do what I need (I don't care about control points and need in between points ON the curve. The next Beta will allow this.) your script is very interesting. 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
6257.15 In reply to 6257.14 
Hey Martin,
After you get your points by array on curve or whatever method, you can get the xyz coords for your router in a file by using "savePointFile".

You can then use a spreadsheet program like excel to add any particular command values to the xyz coords listed.
  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:  Martin (MARTIN3D)
6257.16 In reply to 6257.15 
Thanks BurrMan.
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Message 6257.17 deleted 7 Mar 2022 by SMIRNOV

Previous
Next
 From:  Max Smirnov (SMIRNOV)
6257.18 
Martin, this is exactly what you want :))
code:
function GetCurveControlPoints(curve)
{
	var gd = moi.geometryDatabase;
	var obj = gd.getObjects();
	obj.setProperty( 'showPoints', false); 
	curve.showPoints = true; 
	gd.selectAll();
	obj.setProperty( 'selected', false);
	
	var objectpicker = moi.ui.createObjectPicker();
	objectpicker.allowEditPoints();
	objectpicker.done();
	gd.copyToClipboardCommand( objectpicker.objects );
	gd.pasteFromClipboard();	
	var points = gd.getSelectedObjects();
	gd.removeObjects(points);			
	
	curve.showPoints = false; 
	return points;
}

var curves = moi.geometryDatabase.getObjects().getCurves();	
for ( var f = 0; f < curves.length; ++f)
{
	pts = GetCurveControlPoints(curves.item(f));
	for ( var p = 0; p < pts.length; ++p)
	{
		var factory = moi.command.createFactory( 'text' );
		factory.setInput(0, moi.VectorMath.createFrame ( pts.item(p).pt) );
		factory.setInput(1, ' xyz('+ Math.round(pts.item(p).pt.x*10)/10 + ', ' + Math.round(pts.item(p).pt.y*10)/10 + ', ' + Math.round(pts.item(p).pt.z*10)/10+ ')');
		factory.setInput(2, 'Arial');
		factory.setInput(5, 'curves' );
		factory.setInput(6, 0.5);
		factory.setInput(7, 1);
		factory.commit();
	}
}

EDITED: 7 Mar 2022 by SMIRNOV

  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
6257.19 In reply to 6257.18 
Max,
He wants the points "on the curve", not the weighted control points. Thats a great script.
Image Attachments:
Size: 108.2 KB, Downloaded: 64 times, Dimensions: 542x605px
  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:  Max Smirnov (SMIRNOV)
6257.20 In reply to 6257.19 
Ops, sorry.. Now I see.
Anyway, no problem :) I know how to get 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:  BurrMan
6257.21 In reply to 6257.20 
""""""" I know how to get it.""""""""

I would be happy to get that. It would be a very cool script.

Maybe a way to set the tolerance of the "samples" would be very cool too, so it's adjustable. May need a gui for 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

Message 6257.22 deleted 7 Mar 2022 by SMIRNOV

Previous
Next
 From:  Frenchy Pilou (PILOU)
6257.23 
Excellent!

EDITED: 11 Nov 2013 by PILOU

  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
6257.24 In reply to 6257.22 
Those are the points Max.

Do you think you could make a checkbox to add/leave the point data labels(Like in the previous script)? That would make it ultimate for me....

Thanks again for sharing your scripts.
  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:  Lordfox
6257.25 
Waht is the correct shortcut for this script?!;)

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
6257.26 In reply to 6257.25 
You can put that script in a text file with an extension of .js and give it any name you want, like "anyname.js", then place that in the commands folder, then in the shortcut editor, you add your shortcut with a command of anyname. (leave the js part out of the command)
  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
6257.27 In reply to 6257.26 
I sure would love to have the labels option version of the last one posted..............
  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:  Lordfox
6257.28 In reply to 6257.27 
ok, commands folder, I did made in in the ui folder, ok, sorry ... but I was a long abstinent ;) and I use first time scripts in moi
  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:  Max Smirnov (SMIRNOV)
6257.29 In reply to 6257.21 
new version of the script.

EDITED: 7 Mar 2022 by SMIRNOV

  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
6257.30 In reply to 6257.29 
The zip file appears to be empty. ?
-Brian

EDITED: 15 Nov 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:  Max Smirnov (SMIRNOV)
6257.31 In reply to 6257.30 
Brian, thank you. Reuploaded. :)
  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
6257.32 In reply to 6257.31 
Max,
That is Banner! Thanks for taking the time to do that, and also share it....

I see you made a "copy to clipboard" for the labels which is very slick.....

I suppose there would need to be one more tweak to the labeling? I didn't think about how they would stack up on various curves/situations and MoI's texts are not "blocks", so they can become kindof unmanageable.

I was trying to imagine how that would/could be handled. It may get too complex/unwieldy to give each text block an "object name" of it's value, as it's created? Or it would have to be a vertically constrained list. The only real option would be to have them orient off the positions normal, and have a "distance away from point" value for closer sets, to remain separated.

It may just remain a great option for points that aren't too close....... It can provide some quick communication in the viewport.....

Anyway, thanks again. Nice.
  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-12  13-32  33-42