Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Random DIV?

5 REPLIES 5
Reply
Message 1 of 6
SteveMSILLC
229 Views, 5 Replies

Random DIV?

I have an interesting question, I think. Is there a way to use the DIV command (or any other similar command) to break a line segment up into pieces - but NOT into equal pieces. But rather to be able to enter a number to signify the number of pieces you want to break a segment up into and have ACAD break the segment up into that number of pieces - but each a random length. And even more ideally, have the ability to set and upper and lower limit on piece sizes. For example, let's say I have a line that is 20'-0" long. I'd like to tell ACAD to break this line up into 11 segments, with none larger than 3'-0" and none smaller than 9". Then have ACAD calculate the necessary individual random lengths and then draw it. I'm guessing this would have to be a custom LISP routine and probably not something ACAD can do out of the box? I could easily write a simple script in Excel or Filemaker Pro to do the calculations - but then I would still need to manually break the segment into pieces in ACAD. Any thoughts? Thanks! Steve
Steve Jones
Designer
Morgan Smith Industries
www.morgansmithllc.com
5 REPLIES 5
Message 2 of 6
Patchy
in reply to: SteveMSILLC

If it can be done, this group can tell you:

 

http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/bd-p/130

Message 3 of 6
steve216586
in reply to: SteveMSILLC

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)

"No one can make you feel inferior without your consent. "-Eleanor Roosevelt
Message 4 of 6
SteveMSILLC
in reply to: steve216586

 


@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.

Steve Jones
Designer
Morgan Smith Industries
www.morgansmithllc.com
Message 5 of 6
steve216586
in reply to: SteveMSILLC

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. 

"No one can make you feel inferior without your consent. "-Eleanor Roosevelt
Message 6 of 6
doni49
in reply to: steve216586

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.

 

http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-random-number-generator/td-p/261...

 

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




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost