Map Cleaner Script

by Tuğrul Yazar | December 3, 2022 16:46

Map Cleaner Script

The dwg format maps in Turkey are often problematic. You need to clean these for architectural studios. Maps mostly contain height information of buildings. But the contours of the buildings are distorted and polylines are generally exploded. The map of the region where we worked in the studio I conducted in the Fall 2021 term was also problematic. I created a Map Cleaner Script in Rhino Python[1] and converted the building drawings on the map into solid 3D models.

Map Cleaner Script
Map Cleaner Script

We then used this Map Cleaner Script to create a model for 3D printing the terrain. There was no way to manually create hundreds of building blocks one by one. That’s why the Python script worked very well. I don’t know if this script will work in your case. The version of the meshoutline command in the Rhinoscriptsyntax module has some errors. Therefore I called this command with Rhino.command. And it works miraculously. You can see the video I took while working on the Instagram post below. The top view must be active while the script is running and you must select only the building lines after running the script.

Here[2] is a video, showing the script in action.

# Convert mesh to polysurface buildings in 3d
import rhinoscriptsyntax as rs
objects = rs.GetObjects()
for object in objects:
	if rs.ObjectType(object) == 32: # is mesh
#		f = rs.MeshOutline(r, "Top") is problematic.
		rs.SelectObject(object)
		rs.Command("MeshOutline") # you must be in top view!
		results = rs.SelectedObjects()
		h = rs.MeshAreaCentroid(object)
		for result in results:
			surface = rs.ExtrudeCurveStraight(result, [h[0],h[1],0], h)
			rs.CapPlanarHoles(surface)
			rs.ObjectLayer(surface, "New")
			rs.DeleteObject(result)
		rs.DeleteObject(object)

In this simple example, I chose Python over Grasshopper. Both languages ​​have their advantages. The reason I chose Python is to not forget this language and to show that it is still usable. Indeed, although Rhino Python seems like a dead language because the module cannot be loaded, it can be very useful sometimes.

Endnotes:
  1. Rhino Python: https://www.designcoding.net/category/tools-and-languages/rhino-python/
  2. Here: https://www.instagram.com/tv/CXuEXtrlB05Mko7hC1xFyD4L8zNTqP3vxX_v1M0/

Source URL: https://www.designcoding.net/map-cleaner-script/