If it can be done, this group can tell you:
http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/bd-p/130
What are you trying to accomplish? There may be a better/more simplified solution that a script to randomize segments. (You're talking a lot of possible answers -algorithm- to a relatively simple question)
@steve216586 wrote:What are you trying to accomplish? There may be a better/more simplified solution that a script to randomize segments. (You're talking a lot of possible answers -algorithm- to a relatively simple question)
Not sure how to respond to your comment/question, as I thought I was pretty clear in what I wanted to do. Break up a line segment into random lengths given the total number of segment pieces and the max and min of any one segment piece.
Just using your example: 20'-0" divided into 11 segments with segments < 36" and > 3", you can see there is a multitude of solutions, depending on the rounding. (whole inch thru 1/128" or less). Just using whole numbers, there are over 160,000 solutions. I just wondered if you were to describe a practical application, maybe there is a better way than lisp. Maybe through hatching for instance.
The coding would be enormous for infinite variable lengths combined with infinite variable segment counts also combined with infinite variable upper and lower limits.
If you understand autolisp then yes you can do it.
You'll need a function that generates a random number. A quick google search gave me this link.
Then you'll need to ask for the min and max length values as well as the number of pieces.
Having done that, you'll use a repeat loop so that it runs once for each "piece".
On each run through, you'll get a random lenght between the min and max, subtract it from the available lenght (first time through, it'll be the full length; second time, it'll be what's left after the first run etc).
On each run, you'll need to verify that there's actually enough length left to continue.
Beyond that basic description the autolisp forum (link noted in the first reply) is the best place to get help with this.
Don Ireland
Engineering Design Technician