Javascript in the context of a drawing program opens a whole world of fun and useful possibilities for drawing things programmatically. My Draw Scripts folder is where I drop scripts which create new artwork according to user-defined parameters.
To me, these are the most fun kinds of scripts to build. They can turn into hours and hours of mind-absorbing puzzlement. I certainly have more "almost there" attempts than finished ones. But even the completely botched ones yield a certain pleasure, kind of like losing a good game of chess.
The Dimension_Arrow Graphic Style can be of any stroke color or stroke weight, but should use Illustrator's Arrowhead Effect number 3 at both ends in order to scale so that the arrowheads are inboard of the witness lines. To easily add the styles to your document, open the accompanying file named JET_DimensionStyles.ai, copy the Group that is in the middle of the Artboard, and paste it into your document. Turn on Smart Guides. Use the Line tool to draw a line between two points. Run the script.
Before using the script, create a Symbol named "Dot." Then select a raster image and Use the ObjectMosaic Filter to create an array of grayscale rectangles. Ungroup the results and leave the rectangles selected. Run the script. The script centers an instance of the Symbol named "Dot" on each rectangle, and then scales it according to the rectangle's grayscale value. The result is a "halftone" in which each dot is an instance of your Symbol. See the accompanying PDF for a full demonstration.
The document must have at least one Symbol defined. Simply select some objects. Then run the script.
Paths created by the script will have current fill/stroke appearances. Therefore, set current stroke to 1 pt or less. Set current fill to none. Run the script. Sphere will be drawn at the center of the Artboard, and will have diameter of 1".
Because the copies are placed randomly, cycling of the Reset and Test buttons yields different distributions. After clicking Reset, you can change the Sphere Radius and Number of Patches values; then click Test to generate new results based on the new values. If used on a Symbol Instance, the Replace Symbol command can then be run on the results, to replace each scaled and rotated copy with an Instance of another Symbol at the same scale and rotation.