Is this script idea possible?
Moderators: Víctor Paredes, Belgarath, slowtiger
Is this script idea possible?
Could a script be written that reduces points in an object? I know LightWave modeler has a plugin that does this for 3D objects. I find it frustrating having to crop hundreds of needless points by hand when inserting text in AS. Is there another way maybe to do this already i don't know of?
Cheers
D.K
Cheers
D.K
I suppose something could be created to do this. It wouldn't be very "intelligent". Possibly something that deletes every other point or every 3rd point... something like that.
Also it wouldn't take into account "curve" integrity. If a bunch of points define a curve and you delete them the curve would be lost or changed. AS doesn't handle curves the way other drawing apps do.
-vern
Also it wouldn't take into account "curve" integrity. If a bunch of points define a curve and you delete them the curve would be lost or changed. AS doesn't handle curves the way other drawing apps do.
-vern
I think the point count in letters are already pretty well optimized. There are two curvature values used for converting characters into vectors for AS (you can check those yourself with Fazek's tools), 0.0010 for straight lines, and 0.0300 for curves. Reducing the point count any further would probably distort the original vector shape of the characters too much (it is already a bit distorted). It is really a limitation of the method LM has chosen to implement vectors in AS (for details, see this thread started by Fazek).
Now about point count reduction in general. There is no substitute for manual point removal. A script would only go so far. A skilled human can take far more intelligent decisions about how to do it then a script ever could. Having claimed that, here is a strategy I can see that can help you remove points, and which could be incorporated into a script:
Now about point count reduction in general. There is no substitute for manual point removal. A script would only go so far. A skilled human can take far more intelligent decisions about how to do it then a script ever could. Having claimed that, here is a strategy I can see that can help you remove points, and which could be incorporated into a script:
- look for a sequence of points that have the same curvature value, and merge some of the neighboring points between the end points
Last edited by Rasheed on Mon Jan 22, 2007 11:55 am, edited 1 time in total.
Heyvern, I just had a thought that a point reduction tool would also be really handy when importing illustrator files. Sometimes the amount of points that are imported are massive. Most times the workload in reducing the points has been so dauntimg to me i've just opted to simply import a jpg and trace it in AS.
Just my thoughts.
D.K
Just my thoughts.
D.K
DK, I feel your pain. I guess the import filter used by LM doesn't really optimize the curves, because that would take far too much time. I see two solutions:
There are some problems in converting Adobe Illustrator files. One problem seems to be that, current versions of Adobe Illustrator export in PDF format, instead of the former EPS format. Another problem seems to be that AI uses several types of Bézier curves, while AS uses one type, which hasn't have its handles exposed to the user or scripting interface, while AI has. This makes the .ai and .anme formats rather incompatible, and drives up the point count, even for an optimized import filter.
And even if you trace a bitmap of the original AI artwork, you can only go so far to approximate the original curve. The less points you use, the more the AS artwork is going to deviate from the AI artwork. For accurate representation, you still would need a lot of points.
I wonder, isn't there a way to optimize the artwork in AI, like there is a AS export filter for Photoshop?
- write an import filter in LUA, as a script, which does an optimized (read: slow) import
- optimize the drawing after AS has imported the file
There are some problems in converting Adobe Illustrator files. One problem seems to be that, current versions of Adobe Illustrator export in PDF format, instead of the former EPS format. Another problem seems to be that AI uses several types of Bézier curves, while AS uses one type, which hasn't have its handles exposed to the user or scripting interface, while AI has. This makes the .ai and .anme formats rather incompatible, and drives up the point count, even for an optimized import filter.
And even if you trace a bitmap of the original AI artwork, you can only go so far to approximate the original curve. The less points you use, the more the AS artwork is going to deviate from the AI artwork. For accurate representation, you still would need a lot of points.
I wonder, isn't there a way to optimize the artwork in AI, like there is a AS export filter for Photoshop?
I think you nailed it there Rasheed. If some sort of point reduction script was made available, it would be a great tool to help reduce that time spent on such a tedious task and allow more time for the creative energy. I felt my so drained from doing this repetetive task tonight it actually sapped away part of my enthusiasm for the project so I thought I should bring it up on the forum.
We're, (the not do tech minded), are so lucky to have guys like Heyverne and Rasheed here to winge to
D.K
We're, (the not do tech minded), are so lucky to have guys like Heyverne and Rasheed here to winge to

D.K
Well, it all depends on what algorithm is used to convert the TrueType fonts into Moho vectors. If a corner isn't sharp enough, 0.03 curvature values are used to pad the corner, instead of a single point with a 0.001 curvature value.DK wrote:Hi Rasheed, I was just playing with a few fonts and I think it's where the points bunch up that is the greatest problem. It's generally around the curved areas of the text obviously. Sometimes there are huge amounts of points grouped together depending on what font you use.
Mind you, the 0.03 value is the value you'll get if you use Smooth, and the 0.001 value is the value for Peak.
If you want to look at this example. This is the enlarged view of the letter p in Comic Sans MS

After deleting some points and Peaking the corner point, you'll get this:

I've looked at this in more detail, and it seems that there is a feature called font hinting, which obviously isn't used by AS, because it is a vector drawing program, and not an image editor. However, if you use font hinting in The Gimp (and I assume Photoshop as well), the legibility becomes better, and probably the point count as well in vector drawing programs. Because font hinting is supplied with the font (if I understood that part correctly), it should be possible to use this to improve the font's legibility and decrease the point count at the same time.
I think that LM hasn't included font hinting, because some fonts have their font hinting patented, and you'll probably need to pay a hefty fee to be able to use it in your own programs. Those patents probably also explain in part why Adobe Illustrator is so expensive. However, I'm just guessing here.
So, for the moment, it is much better to use an image editor like The Gimp or Photoshop to create exact representations of fonts. Play around with anti-aliasing and font hinting to create the most optimal results.
Rasheed wrote:
- look for a sequence of points that have the same curvature value, and merge some of the neighboring points between the end points

- look for a sequence of points, in which the formula describing how to go from one point to the next is the same, merge some of the neighboring points between the end points, and adjust the curvature of the remaining points so, that the new curve fits the old curve
Well, after the bone copying tool, it will be next on my list. I guess a tool script is best, because you can then select the points you want to optimize directly, instead of first select them, and next run a menu script.
Now I come to think of it, it might just become the opposite of the Split Curve menu script, in which you add points to a curve. Studying that script could give the aspiring script writer some clues how to write an Optimize Curve tool.
Re: Is this script idea possible?
I was so caught up in the details, that I forgot to answer your question. Yes, in principle, such a script can be written.DK wrote:Could a script be written that reduces points in an object?
No one has done it already, AFAIK, so whoever comes up with a solution first, can win a lot of appreciation from the many Adobe Illustrator fans out there. It would speed up production time enormously, and help to continue the flow of creativity for animators. I guess there is a real need.
So, go script this, please

The other solution could be to do the programming in AI, to create a Moho/AS file from within Adobe Illustrator. The AS script would still be necessary, because not all people use AI to create AI files.
This is a somewhat trickier road, because the cross-platform (Mac, Windows) JavaScripting doesn't seem powerful enough, so you might have to write a plug in for both Windows and Mac OS X (both Power PC and Intel processor) separately to do the conversion.
And, of course, Linux users would be left out in the cold, because Adobe doesn't have a Linux desktop version of Adobe Illustrator CS 2, while the Linux desktop is slowly gaining popularity.
Perhaps I'm not too smart, but how does this menu script work?
I created a curve with a lot of points, using the Split Curve tool, then used 7Feet's script, and none of the points were deleted, nor selected. Nothing, ziltch.
The user interface is also very unclear.
A good script should be clear and easy to use, even for non-programmers. This scripts is not yet in that category of "good scripts".
I created a curve with a lot of points, using the Split Curve tool, then used 7Feet's script, and none of the points were deleted, nor selected. Nothing, ziltch.
The user interface is also very unclear.
- Minimum separation
- Pointiness to retain
- Angle tolerance
- Minimum points per curve
- Minimum points per curve
- Avoid selecting sequential points
- Avoid selecting entire curves
A good script should be clear and easy to use, even for non-programmers. This scripts is not yet in that category of "good scripts".