Box Edit by Random Value - Feature Request

New BoxEdit in Rhino is now much faster - really enjoying it.

It would be helpful if it had an option to edit by a random value. For example, rotate all selected trees by a random degree.

1 Like

Here’s a script or two that might help…

RandomRotateObjsCPlaneZ.py (1008 Bytes)

RandomScaleObjsCtrPlane.py (1.5 KB)

5 Likes

Here’s another request for randomness in BoxEdit within Rhino.

Many times I’m trying to simulate controlled randomness of distributing objects.

Controlled angle, scale, rotation, positions etc.

This can be done in Grasshopper, but within boxedit could save time

-Jeremy

1 Like

Thanks Mitch, these scripts are so valuable <3

You seem to provide so much help with all these scripts; it’s truly appreciated :slight_smile:

-Jeremy

Hi Mitch

I’ve been using these scripts since yesterday and they work a charm. For the scale script, I’m wondering if there’s a way to scale objects non-uniformly?
For the rotate script, perhaps it could remember the previously used input numbers similar to the scale script?

Best,
Jeremy

Yes to both…

RandomScaleObjsCtrPlaneNU.py (2.7 KB)

RandomRotateObjsZAxis.py (1.5 KB)

3 Likes

Thanks again for your efforts Mitch; these scripts become a part of the workflow for pseudo simulating randomness seen in nature when modelling things like landscape elements etc. Probably better workflows, but as a landscape architecture student, Rhino is invaluable. Scattering and random scaling things adds a touch of realism.

With the rotate script; it ranges from 1 up to 180degrees.
Perhaps it could range from 0 to plus or minus 180degrees so that it doesn’t always shift to the left and can simulate full random rotation?


The scaleNU script works a charm.

Perhaps the icing on the cake might be if these scripts could treat individual objects separately; or when grouped, as group instances?

In grasshopper, one can reconstruct the group index using Human

Best,
Jeremy

Actually, there is no limit, the values presented are just the defaults which are set at 0° (no rotation) and 180°. You can actually enter any values you want at the command line. If you want to change the defaults, you can change the two values in the script:

    if "RROCPZ_Min" in sc.sticky: prev_min = sc.sticky["RROCPZ_Min"]
    else: prev_min = 0.0
    if "RROCPZ_Max" in sc.sticky: prev_max = sc.sticky["RROCPZ_Max"]
    else: prev_max = 180.00

Note, if you leave the minimum at 0 and change the max to 360° for example, it will have the same result as -180° to 180°…

I can look at groups at some point.

2 Likes

Hi there.

I have been using the scripts you’ve posted and they’ve come very useful.
One question about the scaling scripts; is there a way to scale to 0?
When using boxedit, it can’t seem to scale to 0 like grasshopper can with ScaleNU
Scaling to 0 comes handy when trying to create planar surfaces with projected closed curves

-Jeremy

Well the problem is that while the scripted scaling function does accept a scale factor of 0 (the normal Rhino Scale command does not), if the object is something like a box or a sphere - or even a simple vertical plane - scaling to 0 (flattening) will produce an invalid object. (This is perhaps why the normal Rhino Scale commands don’t accept 0 as a scale factor).

So what should be done in this case?

Here is something that might help - my ā€œMakePlanarā€ script. Accepts curves, open surfaces and meshes. If you use the the ActiveCPlaneParallel option and select your objects from the Top view, they will be flattened about their bounding box center like the Gumball does.

MakePlanar.py (5.1 KB)

1 Like

Thanks Mitch, the script works a charm.

Within the realms of random scaling objects, is it possible to also perform random moves in x,y,z uniform and non-uniform? These slight adjustments can be controlled to approximate randomness seen in nature.

-Jeremy

Of course… (edited to include point objects)

RandomMoveObjsNU.py (1.6 KB)

I also revised my MakePlanar script a bit, the new version has a filter that limits the selection to curves, open surfaces/polysurfaces and open meshes; it will also refuse to add any invalid results to the document. The limitation preventing the selection of closed volume objects is because they will almost universally result in bad geometry when flattened.

MakePlanar2.py (6.1 KB)

1 Like

Hey Mitch, thanks so much for your work :slight_smile:

I wonder what process McNeel undergo when deciding which feature would be included in upcoming releases. So many of the ones you have produced, along with other ones dotted on these forums, would probably take this software even further.
Having dozens of custom scripts is great, but having them native would make these features accessible to the whole audience.

Some of these scripts are truly indispensable to a quick workflow haha.

-Jeremy

1 Like

The Random Move script is pretty great. For example, one can scatter some rocks quite easily en masse.

Is it possible to make the values sticky from last use?

Also, not sure if this is possible, but can points and control points be moved randomly as well as objects? For example, a polyline control points can create a natural zigzag over large distances etc…

-Jeremy

The limits you set are already sticky (within the same session). If you want to change the defaults (between sessions), you can just edit the script by changing the three values (currently set at 10) to something else.

old_xmax = 10.0
old_ymax = 10.0
old_zmax = 10.0

Note that the Python random is an uncontrolled random, that means that every time you run it you will get a different result. This is different than Grasshopper’s Random component which is a controlled random that always gives the same pseudo-random result given the same input and the same seed value.

I’ve added point objects to the list of objects that can be selected - I don’t know why that was left off before. I will look at point clouds later, that’s a bit more complicated. You can re-download the revised version of the script from my edited post above.

Control points are another story, it is possible to get surface and curve ā€˜grips’ and move them around, it’s a bit more involved, plus also entais some risk of creating bad objects with stacked control points or self-intersecting curves. Polylines are very easy however, as they are just a list of connected points.

Edit: here is a quick polyline ā€œrandomizerā€:
RandomizePolylineVerts.py (2.0 KB)

1 Like

I’ve been getting this message when using the RandomScaleObjsCtrlPlaneNU script, and not sure why it’s happening. I downloaded the one on this forum to the desktop, and ran it straight from python script, but got this message.
image

Hang on, I’ll have a look… V7?

That’s odd… Line 51 is this:

The error message doesn’t make sense, this is a completely standard function. Are you running it via ScriptEditor in V8 by any chance? I am testing here in V7 and it seems to work fine. Also seems to work fine in V8. Is this happening with any file/collection of objects, or with one particular file? Can you post an example?

1 Like

Thanks for checking Mitch.

I just opened a new file, and it worked, even with blocks.

When I did it previously, I copied something from the working file over to a fresh file, and it didn’t work. But when creating them in a fresh file, it worked.

Curious as to why that’s the case

Either way, I will try to get it working in fresh files from now

-Jeremy

If you run into a problem file, you can post it or send it to me by PM, I will check…

Hi Helvetosaur,

I’ve been using these scripts frequently since this thread started.

I am wondering if the random scale and scaleNU can include the ability to work with hatches? Currently, It requires me to dupborder, then perform the script on the closed curve, then re-hatch which can add some time for large quantities of geometry. Random rotate seems to work with hatches

Best,
Jeremy