Draping long components across landscape, including rotation to account for changing terrain elevation?

I am familiar with DropGC, which “drops” selected groups/components onto the geometry below. This works by aligning a single point of a component with the Z axis of the geometry/landscape below.

I need to align two points of a component with the landscape/geometry and to have the component rotate appropriately along a chosen axis. I have thousands of prebuilt fence sections (components) that are about 150’ feet long, and I want to drape them across the uneven terrain such that either end of the fence is touching the ground, not just the center or one edge. This way, the fence follows the landscape contours, sloping uphill and downhill appropriately. This means that both ends (or two points) need to be lowered to the landscape/geometry below, and the component rotated accordingly, for thousands of components.

Is there an easy way to do this? An extension I’m unfamiliar with?

Not sure it would work for the fence objects but for everything else you could look at the Skatter plugin. It works well with terrain.

Here is their website: Lindalë

Profile Builder 3 has spans (between posts) that can shear and the posts can stay vertical.
One can draw the path in a flat plane above the site and then drape that path on the underlying surface.

1 Like

Update: I ended up writing a Ruby script (first time in Ruby!) that does this successfully. For a selected component, the script determines two “feet” (points on the component) that will be set down onto the landscape below it based on a selected axis and an “inches in from the outer edge”. For example, let’s say I have a 10 meter long rectangle that is long on the green axis. I can select the red axis for rotation in this script and the two “feet” will be the outer edges (furthest out on the green axis) on the bottom of the object. If I set the “inches in from the outer edge” to, say, 24 inches, then these “feet” will actually be 24 inches inward from these outer/lower middle points.

The script let’s me select a bunch of components, that are up above the terrain, set the rotation axis and “inches in from the outer edge”, and the script will go through each component, determine the “feet”, rotate the object along the desired axis, and lower it such that both “feet” are now resting on the terrain. This effectively “drapes” all selected objects across the terrain.

The script is still a mess, but works, and is 400+ lines of code, so I’m not sure how to post it here. Ideally, someone could take this code and fix it up to allow the user to select something other than just the red or green axis, or “all” axes (so that the object rotates about the correct axis to lay flat on the terrain, like if you set a big block down on a hill), also they could try to get my “maximum allowed clearance” working, which is supposed to check if any concavity in the hill goes up “into” the object more than an allowed clearance and automatically moves the object upwards to compensate.

1 Like

Would you be willing to share your code? Could be attached as a file rather than 400 lines here.

Quick reply, sorry for the delay, I can share it but I’m still tweaking the code here and there to suit my purpose. Msg me in a week and hopefully it’ll be more complete and I can post it. If you, or someone else, thinks they can attack it this week to improve upon it, I’ll happily share earlier in hopes of not having to try to figure out more Ruby code.

# Draper: Drapes objects onto terrain, setting them down on two feet and rotat - Pastebin.com ← Current code

Imgur: The magic of the Internet ← I’m using it for draping long (100’) solar panel racks across the terrain. These racks have several legs (“piles”), and the outermost piles are around 15’ from the outer edge of the rack, thus the “$feet_from_edge = 189 # INCHES from outside of component to middle of first pile”.

Code only works for rotating about the red axis (east/west) because solar panel racking like this typically is oriented north/south. I haven’t touched the code since last week but if I recall, it looks at the object like a rectangular bounding box, and finds the lowest side (lowest z), then the outermost edges on the green axis (perpendicular to the red axis), and the middle. Those points are called the two “feet” (moved inward by $feet_from_edge if non-zero). The code lowers the components down onto the terrain and rotates it about the lower center along the red axis, such that the end result is that the two “feet” are touching the ground. A non-working part of the code that I haven’t gotten working is a “negative allowed clearance”, such that after setting the component on the ground, it checks along a line between the two feet to see if any terrain goes up INTO the object more than X feet/inches, and if so, moves the whole component up to compensate. The operations are all performed as one so you can just do “undo” to restore it.

The code only works for multiple components when you select a bunch of components that are NOT in a group. I spent far too much time trying to get it working with groups and nested groups and it just kept having issues so I gave up.

Ideally someone would fix this up to allow the user to select the axis (red or green, or solar north/south or solar east/west, or a custom axis), or to establish FOUR feet (north/south/east/west, etc) and to put all four on the ground. Other features that would be handy would be allowing this to work on groups or nested groups, not just a selection of multiple components. Perhaps a GUI and integrating it as a plugin. If someone goes that far, credit for the initial coding would be appreciated.

(Note: Once all of the components have been “draped”, you can’t easily undo it some time after the fact. I have code that I haven’t shared that tries to “undrape” them by lifting the components up 100’ above the terrain and unrotating but it just doesn’t work and I don’t have time to get it working right now.)

To test:

  1. Get a geolocated area with some varied terrain, or make a terrain mesh.
  2. Make a bunch of rectangles that are long in the north/south direction. (I have only tested the code on components, so you may need to make each rectangle an instance of a component)
  3. Select all of the components (do NOT group them)
  4. Run the code in the Ruby console (be sure to adjust the $feet_from_edge to 0, or whatever you want)

Please let me know what you think! I hope to make some time to make it into a plugin myself, but I won’t be able to get to it for a while.

1 Like

You can try the tt Raytracer extension.

2 Likes

I added a toolbar button.

Screenshot 2023-10-18 014913

Screenshot 2023-10-18 014941

I’ll clean it up and then try to get user input for the user_settings.

1 Like

Bit of an issue. I set up a bunch of ACT cameras and my code drapes onto the hidden geometry. I’ve found a workaround of saving the camera data elsewhere and restoring it afterwards, but still, it’s a bit annoying.

I wish I had seen that sooner! That said, I’ve tried it and it doesn’t seem to work the way I need. Still, that may have given me something to work off of and saved me some time. Thanks for sharing!

Still tinkering around. Added an Html Dialog and going to fiddle with user input. I didn’t fully understand your last post.