Created
May 15, 2018 23:26
-
-
Save Dodotree/ccdf95b2531ac6a2e0c7b9e29c08f4fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import bpy, bmesh | |
| from mathutils import Vector | |
| ''' | |
| Several problems solved: | |
| 1) no need to activate or select the object | |
| 2) no need to change origin after bpy.ops.object.transform_apply(location=True, rotation=True, scale=True) | |
| 3) only 2 walls to check inside | |
| ''' | |
| def meshBox(c1): | |
| bb = [c1.matrix_world * Vector(corner) for corner in c1.bound_box] | |
| mesh = bpy.data.meshes.new( "bb1_mesh_" + c1.name ) | |
| clone = bpy.data.objects.new("BB_" + c1.name, mesh) | |
| clone.data.from_pydata( bb, [[0,1], [1,2], [2,3], [3,0], [4,5], [5,6], [6,7], [7,4], [4,0], [5,1],[6,2], [7,3]], [[0,1,2,3], [4,5,6,7]]) | |
| scene = bpy.context.scene | |
| scene.objects.link(clone) | |
| scene.update() | |
| meshBox( bpy.data.objects['object_name'] ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment