MoI discussion forum
MoI discussion forum

Full Version: Sharp points delete, script request.

From: Andrei Samardac
1 Sep 2014   [#1]
Michael, could you pleas make script that will delete all the sharp points in the selected curves or replace them to simple points?

If it possible could you pleas make also to replace all sharp points to 2 or 3 simple points? just make simple box where you can set amount of replaced points.

If nothing is imposible may be just select sharp corners?
From: Michael Gibson
1 Sep 2014   [#2] In reply to [#1]
Hi Andrei, sorry but currently there is no script interface set up to allow scripts to access the individual edit points of a curve, so it's just not possible at this time to make a script to do things that involve individual specific edit points.

The closest thing to automatically removing sharp points is to use the Rebuild command.

- Michael
From: Andrei Samardac
2 Sep 2014   [#3] In reply to [#2]
Hi Michael,
This scrip made Max Smirnov, it replace sharp corners to regular points.
It has to be improved a bit, Max has no time now so I asking you.

1. it keep curves with sharp points and you have to delete them by hands, but it wiil be good to delete them automaticly.

2. Now before script starts it allows you to deselect sharp points and they will be deleated insted of replaced to normal points. So if I have a lot of curves to modify I have to skip this step one by one, it take a lot of time and in the end if I press enter after I skip last curve script runs again, and it becom big pain...

So it will be possible to select all curves run script and all sharp points will be replaced with regular and initial curves will be deleated.

3. This script works great after you aplly fillet to sharp points if you want to keep shape. It keeps very good shapes of curves. So could you pleas some how incorporate this script with fillet, so first run fillet after that script.

Also fillet now works only on 1 curve for this script will be great to have fillet for multiple curves at once it will be great not only for this script.

Thank you.

http://www.datafilehost.com/d/06b9c073
From: Andrei Samardac
2 Sep 2014   [#4] In reply to [#3]
I think no need for filet, it is better to run it separatly becouse some times you need diffrent fillet radius.
From: Michael Gibson
2 Sep 2014   [#5] In reply to [#3]
Hi Andrei, Max's script works by doing a "select all" and then a copy to the clipboard of the points and then a paste back in of those points. That is indeed a way for a script to access the points without there being a proper script interface, but it's limited in what it can recover, it only gets a big bunch of points and isn't able to access additional information like being able to determine which particular points are actually corner points or not.

Just in general it's difficult to make scripts that do control point manipulation since things are not currently set up to make all the information about the points accessible to a script.

re: #1 - delete the curves, you can modify Max's script to delete the original curves at the end by adding in one additional line right near the end like so (line to add marked with >>>, don't include the >>> characters):

code:
		for ( var i = 0; i < curves.length; ++i ) { curves.item(i).selected = true;}				// âêëþ÷àåì îòáðàòíî âûäåëåíèå èñõîäíûõ êðèâûõ
		
>>>		g.removeObjects( curves );
}

DelCorners();


re: #2 - sorry I don't understand this part, do you mean you don't want it to wait for you to change the point selection and just immediately proceed with processing each curve?

re: #3 - adding fillets, this is possible but will unfortunately be fairly time consuming to set up so I'm sorry I will not be able to do that one for you right now.

- Michael
From: Andrei Samardac
2 Sep 2014   [#6] In reply to [#5]
Thank you!
>>>re: #2 - sorry I don't understand this part, do you mean you don't want it to wait for you to change the point selection and just immediately proceed with processing each curve?

Yes!
Just want to run script and replace all shar points without any other steps.
From: Michael Gibson
2 Sep 2014   [#7] In reply to [#6]
Hi Andrei,

> Yes!
> Just want to run script and replace all shar points without any other steps.

Try using the attached version, it has that point picking step removed.

- Michael

Attachments:
DelCorners.js


From: Andrei Samardac
2 Sep 2014   [#8] In reply to [#7]
Great Michael, thank you very much!!!
From: Andrei Samardac
2 Sep 2014   [#9] In reply to [#8]
Michael is it possible to make fillet work on multyple curves at the same time?
From: Michael Gibson
2 Sep 2014   [#10] In reply to [#9]
Hi Andrei,

> Michael is it possible to make fillet work on multyple curves at the same time?

One difficulty with that is that fillet works in a different way currently if you pick 2 different curves, it does a fillet just between those curves like for example if you have 2 individual separate line segments selected that cross each other.

That fillet between 2 individual lines is the sort of old style AutoCAD type curve fillet method.

- Michael
From: Andrei Samardac
2 Sep 2014   [#11] In reply to [#10]
It will be nice, to fix it in the future.
From: Andrei Samardac
2 Sep 2014   [#12]
Some Tips on how to use DelCorners.
http://moi3d.com/forum/index.php?webtag=MOI&msg=6058.43

1
From: Max Smirnov (SMIRNOV)
2 Sep 2014   [#13] In reply to [#2]
>> currently there is no script interface set up to allow scripts to access the individual edit points of a curve

Hi Michael!

Could you implement this interface in the future versions of MoI?
It will be very powerfull tool for scripting.
Something like this:

curve.getControlPointCount()
curve.getControlPoint(index)
curve.setControlPoint(index, newcoords)

and for surfaces:
surface.getUControlPointCount()
surface.getVControlPointCount()
surface.getControlPoint(U_index, V_index)
surface.setControlPoint(U_index, V_index, newcoords)
From: Michael Gibson
2 Sep 2014   [#14] In reply to [#13]
Hi Max, yes I do want to add something like that in the future. If you can bring it up again during the v4 development cycle that would be a good time for me to dig into it.

- Michael
From: Frenchy Pilou (PILOU)
2 Sep 2014   [#15]

From: Michael Gibson
2 Sep 2014   [#16] In reply to [#15]
Hi Pilou, for the case you show there, just draw in a new 3 point curve using Draw curve > Freeform > Control points, you'll then have the new segment in the shape you want.

Or another possibility is to use Edit > Separate and then Edit > Join and only join the ending 2 segments together and then run DelCorners on that...

- Michael
From: Frenchy Pilou (PILOU)
2 Sep 2014   [#17] In reply to [#16]
Yes :)
It was just for know! :)

First method is more suitable and easy!
Mine is draw a new "no corner point" near the old corner then kill the corner point and move the new on the old! :)
From: Frenchy Pilou (PILOU)
3 Sep 2014   [#18]
French version :) http://moiscript.weebly.com/delcorners.html
English one