Fixing 'illegal' curves?

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
Víctor Paredes
Site Admin
Posts: 5646
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Fixing 'illegal' curves?

Post by Víctor Paredes »

Is there any way to remove 'illegal' curves?
Some times there are shapes that can't be filled because there's a line bent in a bad way, making some kind of loop, or there are two lines across the same points or other possibilities that escape to my mind right now.
Many times it requires a lot of trial and error to find the specific points where the problem is happening.
Do you know if a script could detect and fix those problems? or maybe just select the points with possible issues?

Thanks :)
Image Image Image Image
Moho Product Manager

www.mohoanimation.com
Rigged animation supervisor in My father's dragon - Lead Moho artist in Wolfwalkers - Cartoon Saloon - My personal Youtube Channel
User avatar
hayasidist
Posts: 3492
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Fixing 'illegal' curves?

Post by hayasidist »

It should be feasible to identify points that are "illogically" connected in a curve … my test harness has some curve-crawling diagnostics in it -- I'll tweak that into a stand-alone tool over the next few days. At this stage I'll aim to highlight (=select) points that are in more than 2 segments of the same curve (e.g. two separate segments of the same curve have the same pair of points). That should go someway to framing the next questions -- are there other 'illegal' configurations; is it feasible to come up with an automatic and reliable way of resolving such situations.

but/and any other ideas / input are always welcome..
User avatar
hayasidist
Posts: 3492
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Fixing 'illegal' curves?

Post by hayasidist »

Here's a first stab at this:

http://www.mediafire.com/file/wpw4mewsd ... s.lua/file

It's a menu script (I'll suggest it goes in "Draw", but wherever ..).

Run it with a vector layer active.

If it finds a point that is in the same curve twice (even if the point is hidden) it will unhide and select it.

I've run it in a few test scenarios - the "least obvious" is where two or more points are all at the same position - this can take some unpicking - but the tool actually does its job.

There are several "validly unfillable" types of curve -- the tool doesn't try to find these, but if that's a desired function, please say.

some other ideas for a further iteration of this include:
> better indication where there are multiple points at the same location;
> more diagnostic info on "rogue" curves
> working on selected curves and/or whole documents (i.e. at a granularity higher and/or lower than the active layer)




Please give it a whirl.... Feedback would be very much appreciated -- and, especially in cases where the tool fails to find a rogue curve, a copy of the layer / curve in question would be really helpful.
User avatar
DK
Posts: 2849
Joined: Mon Aug 09, 2004 6:06 am
Location: Australia

Re: Fixing 'illegal' curves?

Post by DK »

This script might be a hard one to test. It's only rarely I get a bad curve but when I do it's a PITA!
How do you go about creating a bad curve so we can test the script?

Cheers
D.K
User avatar
slowtiger
Posts: 6067
Joined: Thu Feb 16, 2006 6:53 pm
Location: Berlin, Germany
Contact:

Re: Fixing 'illegal' curves?

Post by slowtiger »

Freehand tool? Usually I get some loops at the beginning or close of a curve. Not a big deal to correct manually.

I think the important part is to find the troublemakers. Then highlight them, and let the user decide how to correct. As I wrote in that other post, some search for too-close points could be helpful, additional to the identical positioned ones.
AS 9.5 MacPro Quadcore 3GHz 16GB OS 10.6.8 Quicktime 7.6.6
AS 11 MacPro 12core 3GHz 32GB OS 10.11 Quicktime 10.7.3
Moho 13.5 iMac Quadcore 2,9GHz 16GB OS 10.15

Moho 14.1 Mac Mini Plus OS 13.5
User avatar
slowtiger
Posts: 6067
Joined: Thu Feb 16, 2006 6:53 pm
Location: Berlin, Germany
Contact:

Re: Fixing 'illegal' curves?

Post by slowtiger »

Freehand tool? Usually I get some loops at the beginning or close of a curve. Not a big deal to correct manually.

I think the important part is to find the troublemakers. Then highlight them, and let the user decide how to correct. As I wrote in that other post, some search for too-close points could be helpful, additional to the identical positioned ones.
AS 9.5 MacPro Quadcore 3GHz 16GB OS 10.6.8 Quicktime 7.6.6
AS 11 MacPro 12core 3GHz 32GB OS 10.11 Quicktime 10.7.3
Moho 13.5 iMac Quadcore 2,9GHz 16GB OS 10.15

Moho 14.1 Mac Mini Plus OS 13.5
User avatar
hayasidist
Posts: 3492
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Fixing 'illegal' curves?

Post by hayasidist »

here's the next rev http://www.mediafire.com/file/wpw4mewsd ... s.lua/file (same link, but repeated here)

as requested - this one also selects points that are "too close" (and the definition of "too close" depends on the zoom level of the work area - IOW if you've zoomed in and the points are individually discernible they don't get selected).

I've used an arbitrary pixel separation for "too close" -- it works "ok" on the (1920*1080) monitor I tested this on, but haven't done a rigorous test on monitors with different resolutions - so apologies in advance if this isn't quite right -- please let me know!
Post Reply