Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Move to Surface - stubborn objects

Anonymous

Move to Surface - stubborn objects

Anonymous
Not applicable

I've been trying to solve this for a while and now the clock is catching up to me so I hope someone here can help.

 

I'm working on a large city model, the model contains thousands of buildings and a 3D terrain mesh. I want to move the buildings to the surface of the terrain so they all align to the mesh but whatever I try (short of manually aligning them all one by one), I can't quite get it to work.. So far I've tried a couple of scripts from scriptspot - Move to Surface and Scripted Glue but both yield the same result - I select all the buildings, apply the script, some buildings align to the terrain but most don't move at all. Here's a screen grab of the end result:

 

 

 

Untitled2.png

 

 

I can only assume that there is something broken/different about the objects that refuse to move but I can't figure out what it might be. A copy of the model can be downloaded here.

 

 

 

Many thanks Robot Happy

 

 

 

 

0 Likes
Reply
Accepted solutions (1)
3,337 Views
10 Replies
Replies (10)

miledrizk
Advisor
Advisor

Hi,

 

I couldn't open the file because i have max 2017,

 

But maybe there is a problem with the pivot points of those buildings,

 

It's possible that they are outside the boundary of the terrain or below its surface, etc,...

 

Anyway, to check if this is the case select all the buildings and go to Hierarchy panel,

 

Click Affect Pivot Only and press the Center To Object, then click Affect Pivot Only to turn it off,

 

And try the scripts.

 

Note: the buildings should be separate objects not in a group or something(even though some scripts may consider

this situation, but its better to keep them as separate objects) 

 

Also, in case the pivot point trick worked, the buildings might go half way in the ground in case those

script are made in a way that move the objects starting from their pivot points. But in that case it can be solved

easily by a three of 4 lines of a script i can write.

------------------------------------------------------
miledrizk@gmail.com
3DS Max 2025, V-Ray 7
3DS Max user since 2003 (3DS Max 7)
V-Ray user since 2008 (V-Ray 1.47)

Anonymous
Not applicable

Thanks for the suggestion but it didn't do the trick unfortunately. I've resaved the model for 2017 though if you're willing to take a look? This is the script I've been using..

 

 

Cheers

0 Likes

miledrizk
Advisor
Advisor

I just opened the file and it seems all buildings are on the ground

 

But i will check the script anyway

 

1.PNG

------------------------------------------------------
miledrizk@gmail.com
3DS Max 2025, V-Ray 7
3DS Max user since 2003 (3DS Max 7)
V-Ray user since 2008 (V-Ray 1.47)

Anonymous
Not applicable

Ah yes, they are roughly aligned but if you know where to look there are many buildings sitting just above or going through the terrain.. Robot Sad

0 Likes

miledrizk
Advisor
Advisor

ah ok,

 

And did you use the script Move To Surface or Scripted Glue to move them down?

------------------------------------------------------
miledrizk@gmail.com
3DS Max 2025, V-Ray 7
3DS Max user since 2003 (3DS Max 7)
V-Ray user since 2008 (V-Ray 1.47)

Anonymous
Not applicable

Neither script seems to work on this so I just manually lowered them down for now.. If you move the terrain down then try one of the scripts you can see the problem?

0 Likes

miledrizk
Advisor
Advisor
Accepted solution

Here is the Move To Surface script,

 

I added two lines of code that will do the trick,

 

The problem was in the pivot points of the buildings, like what i expected in the first Post.

 

Those two lines i added, will move the pivot point of each object to the bottom center

 

https://drive.google.com/file/d/16h6X4czyyriEFYFOwmxF2jlSzJn5T5JU/view?usp=sharing

 

 

------------------------------------------------------
miledrizk@gmail.com
3DS Max 2025, V-Ray 7
3DS Max user since 2003 (3DS Max 7)
V-Ray user since 2008 (V-Ray 1.47)

Anonymous
Not applicable

Amazing, it works! Thanks, really appreciate it Robot Very Happy

0 Likes

miledrizk
Advisor
Advisor

Welcome! 

Glad it worked! 🙂

------------------------------------------------------
miledrizk@gmail.com
3DS Max 2025, V-Ray 7
3DS Max user since 2003 (3DS Max 7)
V-Ray user since 2008 (V-Ray 1.47)

Anonymous
Not applicable

I came across this topic which tackles exactly what I'm trying to do. All Objects have different z-Values and I would like to move them on a surface or z zero value.

Thanks a lot for sharing the script. I'm not at all experienced with script and somehow I can't manage to make it work. Still after doing it step by step with the pivot points. Has someone an input?

I'd really appreciate.

 

The model is here: https://polybox.ethz.ch/index.php/s/P5DQEdC8QodAbod

0 Likes