The script prints the number of points, curves and shapes in the layer in which it is embedded. Why is this script useful? Well, if you have made mistakes (or if you are revising Moho files from others), you can use this layer script for debugging.
Nothing fancy, nothing elaborate, just had a lot of fun creating it. And it is Public Domain, so you can change it however you like, as long as you keep the credits intact and add your name to it as a co-creator.
Here is the file for download as a ZIP archive (642 bytes):
• PrintNumberOfPointsCurvesAndShapes.lua.zip
And I have very little programming experience, so I guess if I can do this, many more people could do this as well.
Because the script is so small, I give you the code in this message:
Neat and simple, isn't it?PrintNumberOfPointsCurvesAndShapes.lua wrote:Code: Select all
-- ****************************************************************************** -- Print the Number of Points, Curves and Shapes in a layer -- Layer Script to help you debug your vector layer -- by Rene van Belzen -- -- Public Domain 2006 -- ****************************************************************************** function LayerScript(moho) local layerName = moho.layer:Name() if (NUM_POINTS == nil) then NUM_POINTS = {} NUM_POINTS[layerName] = 0 end if (NUM_CURVES == nil) then NUM_CURVES = {} NUM_CURVES[layerName] = 0 end if (NUM_SHAPES == nil) then NUM_SHAPES = {} NUM_SHAPES[layerName] = 0 end local mesh = moho:Mesh() if moho.frame == 0 and mesh ~= nil then local numPoints = mesh:CountPoints() local numCurves = mesh:CountCurves() local numShapes = mesh:CountShapes() if numPoints ~= NUM_POINTS[layerName] or numCurves ~= NUM_CURVES[layerName] or numShapes ~= NUM_SHAPES[layerName] then print("There are now "..numPoints.." points, "..numCurves.." curves and "..numShapes.." shapes in layer ""..layerName.."".") NUM_POINTS[layerName] = numPoints NUM_CURVES[layerName] = numCurves NUM_SHAPES[layerName] = numShapes end end end
You embed it into your Moho layer by double clicking the layer in the Layer Window, checking the Embedded script file checkbox in the Layer Settings window that appears, select the script file in the file dialogue and click on Open to select and click on OK to close the Layer Settings window.
The layer script only works on vector layers and in frame zero.
Have fun using it!
Peace,
René.