[IDEA] Platform / Street levelling / fixing script
-
hi@all!
i got an idea for a possible ruby script, some sort of "platform/ramp/street/... levelling script".
story:
as we all know, streets (i'm gonna use streets as the major example) are supposed to be more or less level, at least diagonally to the course of the road. if you extract terrain out of google earth, it's sometimes not level where streets run. adjusting it along the street is - depending on the size of the area - a very time consuming task.how the script should work:
- select some lines at the side of the streets where its "crooked"
- run the script
- the result is a smooth ground
function of the script:
it checks the highest/lowest point of each end of the selected lines. that way it finds out the difference in height. it checks how many connecting points are along those lines and divides the height difference by the amount of connecting points, which results in a steady decline/increase of heights, which the connecting points have to be adjusted by. if possible, the script should check the distances between connecting points along the lines to adjust the height "steps" properly (since most will not have the same distance to the following one).further improvements to the script:
in a later stage, it could ask for a percentage amount which adjusts the slope to a more realistic ramp (not just falling straight, but with a decent starting and ending curve).final words:
it's kinda hard to explain for me. i hope you understand what i mean. check out the attached screenshots, that's how i get it pretty often and then i have to correct it point by point to make it a nice, level road as seen in the second screenshot...last but not least: does such a script already exist?
cheers!
-
i just wanted to add: if there is nobody which can realize such a script (which i would understand), does anybody have a hint how to do this kind of thing easier in any possible way to save some time? any suggestions are more than welcome!
-
The terrain is generated from a 3D CAD drawing?
- Extract the road edges.
- Stitch together the road surface. (I think there's plugins that will help you do this)
- Stamp the road onto the terrain. With optional radius
-
I have a script JS Align that can kind of do this.
Select edges and run plugin.
There might be issues with non triangle surfaces and such so be sure you backup before use.
http://www.pixero.com -
thanks for your replies guys!
@thomthom
yep, the terrain was made from a 2d cad file (containing contours only). the streets are a seperate 2d file and don't have any kind of height information. the way you describe it would work for straight/level streets indeed, but not if there is any difference in height.@pixero
your script is basically the perfect start for the script i am looking for. it just needs the calculation routine to be able to make slopes, additionally to just aligning it to one chosen level (max, mid, min). it does help me with the level roads though, same as thomthom's idea. actually, it solves the problem seen on my screenshots.both your methods work perfectly to get 100% level areas, but that doesn't occure as often as slopes in this terrain. i guess there is not ruby to get around that out yet.
[edit] i see what you mean with your script might cause problems pixero. i just tried it as seen on the attached screenshots. it makes a nice and smooth road, but there are lots of faces lost afterwards. and in a weird way. they are not just deleted (which would leave empty, white holes), something still seems to be there, but i can't select anything.
-
godswife, have you seen this thread?
Road on terrain: http://forums.sketchucation.com/viewtopic.php?f=18&t=19522Thomthom, maybe you could tweak something useful out of my script.
Like adding falloff based on a gauss curve and averaging the points position?
(I'm in the middle of rendering a looong animation and dont have time to look into it at the moment.) -
no, i haven't see that topic yet, but the tutorial in it describes almost the same way i am doing it now. for small areas okay, but if you have a terrain with a couple of square kilometers and lots of roads, it's a huge time consumer.
it would be awesome if somebody could enhance your already nice script. i have not enough experience in coding to try myself
it sure would be a huge plus for the community.
any idea why it messed up those faces when i tried your align ruby?
-
@godswife said:
any idea why it messed up those faces when i tried your align ruby?
I think it has to do with the fact that when used on lines/points it moves them one by one thus making polygons nonplanar even if its just while the script is running. There was another topic in this forum about how to move several items at the same time. I think that would help. Cant remember the name of the poster now.
-
It might have been a thread I was involved in. Use entities.transform_by_vectors to move multiple entities at the same time, but by different distances.
http://code.google.com/apis/sketchup/docs/ourdoc/entities.html#transform_by_vectors
You build an array that holds your entities and an array that holds a vector that describes the direction and distance to move each entity. The vector array needs to be in the same order as the entity array.
That makes SU move them all at the same time, making for a MUCH cleaner move.
Chris
-
Chris, I have done the transform_by_vectors changes and that seem to work fine.
However there still is the problem when using the script on edges inside a group. Then the face gets put outside the group and at 0,0,0.
Any idea how to fix that? -
thanks, i understand the cause of the error now. initially i thought it does the same as i am doing (higher/lower each POINT, not LINE). is it going to work when i explode the group before i use your script? is it possible to change the script to the way that it only changes the height at the connecting points instead of working with the lines?
-
I think I have fixed it in the updated version here: http://forums.sketchucation.com/viewtopic.php?f=180&t=20080
-
nicely done, works like a charm now! what i like even better: it's possible to undo it with one click (before it was undoing point by point). now we just have to find somebody, who can integrate the discussed functions to make it perfect.
-
nobody got time for this at the moment?
how hard is it to get this programmed on a scale from let's say 1 to 10? let me know and it might be easier to stay patient!
Advertisement