def execute(self, context): obj = bpy.data.objects[self.object_name] group_bp = utils.get_assembly_bp(obj) wall_bp = utils.get_wall_bp(obj) if group_bp: group = fd_types.Assembly(group_bp) elif wall_bp: group = fd_types.Wall(wall_bp) hooklist = [] for child in group.obj_bp.children: if child.type == 'EMPTY' and child.mv.use_as_mesh_hook: hooklist.append(child) if obj.mode == 'EDIT': bpy.ops.object.editmode_toggle() utils.apply_hook_modifiers(obj) for vgroup in obj.vertex_groups: if vgroup.name == 'X Dimension': utils.hook_vertex_group_to_object(obj,'X Dimension',group.obj_x) elif vgroup.name == 'Y Dimension': utils.hook_vertex_group_to_object(obj,'Y Dimension',group.obj_y) elif vgroup.name == 'Z Dimension': utils.hook_vertex_group_to_object(obj,'Z Dimension',group.obj_z) else: for hook in hooklist: if hook.mv.name_object == vgroup.name: utils.hook_vertex_group_to_object(obj,vgroup.name,hook) obj.lock_location = (True,True,True) return {'FINISHED'}
def execute(self, context): context.window_manager.mv.use_opengl_dimensions = True self.font = opengl_dim.get_custom_font() self.create_linestyles() self.main_scene = context.scene context.scene.name = "_Main" if self.use_single_scene: self.create_single_elv_view(context) else: bpy.ops.fd_scene.clear_2d_views() self.create_plan_view_scene(context) for obj in self.main_scene.objects: if obj.mv.type == 'BPWALL': wall = fd_types.Wall(obj_bp=obj) if len(wall.get_wall_groups()) > 0: self.create_elv_view_scene(context, wall) self.clear_unused_linestyles() bpy.context.screen.scene = self.main_scene wm = context.window_manager.mv wm.elevation_scene_index = 0 return {'FINISHED'}
def create_wall(self): con = None if self.previous_wall: con = self.previous_wall.obj_x self.wall = fd_types.Wall() self.wall.create_wall() obj_mesh = self.wall.build_wall_mesh() self.wall.obj_bp.location = self.starting_point obj_mesh.draw_type = 'WIRE' self.wall.obj_z.location.z = bpy.context.scene.mv.default_wall_height self.wall.obj_y.location.y = bpy.context.scene.mv.default_wall_depth self.wall.obj_bp.mv.item_number = self.get_wall_count() if con: utils.connect_objects_location(con,self.wall.obj_bp) width = self.wall.get_var("dim_x","width") height = self.wall.get_var("dim_z","height") depth = self.wall.get_var("dim_y","depth") dim = fd_types.Dimension() dim.parent(self.wall.obj_bp) dim.start_y('depth+INCH(5)',[depth]) dim.start_z('height+INCH(5)',[height]) dim.end_x('width',[width]) dim.anchor.hide = True
def execute(self, context): largest_x = 0 largest_y = 0 smallest_x = 0 smallest_y = 0 wall_groups = [] height = 0 for obj in context.visible_objects: if obj.mv.type == 'BPWALL': wall_groups.append(fd_types.Wall(obj)) for group in wall_groups: start_point = (group.obj_bp.matrix_world[0][3], group.obj_bp.matrix_world[1][3], 0) end_point = (group.obj_x.matrix_world[0][3], group.obj_x.matrix_world[1][3], 0) height = group.obj_z.location.z if start_point[0] > largest_x: largest_x = start_point[0] if start_point[1] > largest_y: largest_y = start_point[1] if start_point[0] < smallest_x: smallest_x = start_point[0] if start_point[1] < smallest_y: smallest_y = start_point[1] if end_point[0] > largest_x: largest_x = end_point[0] if end_point[1] > largest_y: largest_y = end_point[1] if end_point[0] < smallest_x: smallest_x = end_point[0] if end_point[1] < smallest_y: smallest_y = end_point[1] x = (math.fabs(largest_x) - math.fabs(smallest_x)) / 2 y = (math.fabs(largest_y) - math.fabs(smallest_y)) / 2 z = height - unit.inch(.01) width = math.fabs(smallest_y) + math.fabs(largest_y) length = math.fabs(largest_x) + math.fabs(smallest_x) if width == 0: width = unit.inch(-48) if length == 0: length = unit.inch(-48) bpy.ops.object.lamp_add(type='AREA') obj_lamp = context.active_object obj_lamp.location.x = x obj_lamp.location.y = y obj_lamp.location.z = z obj_lamp.data.shape = 'RECTANGLE' obj_lamp.data.size = length + unit.inch(20) obj_lamp.data.size_y = width + unit.inch(20) for node in obj_lamp.data.node_tree.nodes: if node.type == 'EMISSION': node.inputs[1].default_value = max( unit.meter_to_active_unit(largest_x), unit.meter_to_active_unit(largest_y)) return {'FINISHED'}
def execute(self,context): wall_bp = utils.get_wall_bp(context.active_object) if wall_bp: self.previous_wall = fd_types.Wall(wall_bp) self.starting_point = (self.previous_wall.obj_x.matrix_world[0][3], self.previous_wall.obj_x.matrix_world[1][3], self.previous_wall.obj_x.matrix_world[2][3]) self.create_wall() bpy.ops.mesh.primitive_plane_add() plane = context.active_object plane.location = (0,0,0) self.drawing_plane = context.active_object self.drawing_plane.draw_type = 'WIRE' self.drawing_plane.dimensions = (100,100,1) context.window_manager.modal_handler_add(self) return {'RUNNING_MODAL'}
def write_walls(self,project_node): elm_walls = self.xml.add_element(project_node,"Walls") for obj_wall in self.walls: wall = fd_types.Wall(obj_wall) wall_name = wall.obj_bp.mv.name_object if wall.obj_bp.mv.name_object != "" else wall.name elm_wall = self.xml.add_element(elm_walls,'Wall',wall_name) self.xml.add_element_with_text(elm_wall,'LinkID',obj_wall.name) self.xml.add_element_with_text(elm_wall,'LinkIDLocation',obj_wall.users_scene[0].name) self.xml.add_element_with_text(elm_wall,'Width',self.distance(wall.obj_x.location.x)) self.xml.add_element_with_text(elm_wall,'Height',self.distance(wall.obj_z.location.z)) self.xml.add_element_with_text(elm_wall,'Depth',self.distance(wall.obj_y.location.y)) self.xml.add_element_with_text(elm_wall,'XOrigin',self.location(obj_wall.matrix_world[0][3])) self.xml.add_element_with_text(elm_wall,'YOrigin',self.location(obj_wall.matrix_world[1][3])) self.xml.add_element_with_text(elm_wall,'ZOrigin',self.location(obj_wall.matrix_world[2][3])) self.xml.add_element_with_text(elm_wall,'Angle',self.angle(obj_wall.rotation_euler.z))
def execute(self, context): largest_x = 0 largest_y = 0 smallest_x = 0 smallest_y = 0 wall_groups = [] for obj in context.visible_objects: if obj.mv.type == 'BPWALL': wall_groups.append(fd_types.Wall(obj)) for group in wall_groups: start_point = (group.obj_bp.matrix_world[0][3], group.obj_bp.matrix_world[1][3], 0) end_point = (group.obj_x.matrix_world[0][3], group.obj_x.matrix_world[1][3], 0) if start_point[0] > largest_x: largest_x = start_point[0] if start_point[1] > largest_y: largest_y = start_point[1] if start_point[0] < smallest_x: smallest_x = start_point[0] if start_point[1] < smallest_y: smallest_y = start_point[1] if end_point[0] > largest_x: largest_x = end_point[0] if end_point[1] > largest_y: largest_y = end_point[1] if end_point[0] < smallest_x: smallest_x = end_point[0] if end_point[1] < smallest_y: smallest_y = end_point[1] loc = (smallest_x, smallest_y, 0) width = math.fabs(smallest_y) + math.fabs(largest_y) length = math.fabs(largest_x) + math.fabs(smallest_x) if width == 0: width = unit.inch(-48) if length == 0: length = unit.inch(-48) obj_plane = utils.create_floor_mesh('Floor', (length, width, 0.0)) obj_plane.location = loc #SET CONTEXT context.scene.objects.active = obj_plane return {'FINISHED'}
def execute(self, context): obj_bools = [] obj = context.object obj_bp = utils.get_parent_assembly_bp(obj) if obj_bp: obj_list = [] obj_list = utils.get_child_objects(obj_bp,obj_list) bpy.ops.object.select_all(action='DESELECT') for obj in obj_list: obj.hide = False obj.select = True bpy.ops.object.duplicate() for obj in context.selected_objects: if obj.type == 'EMPTY': obj.hide = True #COLLECT BOOLEAN OBJECTS FROM GROUP if obj.mv.use_as_bool_obj: obj_bools.append(obj) obj.location = obj.location for obj in obj_list: if obj.type == 'EMPTY': obj.hide = True obj.location = obj.location bpy.ops.object.select_all(action='DESELECT') #ASSIGN BOOLEAN MODIFIERS TO WALL if obj_bp.parent: if obj_bp.parent.mv.type == 'BPWALL': wall = fd_types.Wall(obj_bp.parent) mesh = wall.get_wall_mesh() for obj_bool in obj_bools: mod = mesh.modifiers.new(obj_bool.name,'BOOLEAN') mod.object = obj_bool mod.operation = 'DIFFERENCE' obj_bp.select = True context.scene.objects.active = obj_bp return {'FINISHED'}
def create_plan_view_scene(self, context): bpy.ops.scene.new('INVOKE_DEFAULT', type='EMPTY') pv_scene = context.scene pv_scene.name = "Plan View" pv_scene.mv.name_scene = "Plan View" pv_scene.mv.plan_view_scene = True self.create_linesets(pv_scene) grp = bpy.data.groups.new("Plan View") for obj in self.main_scene.objects: #Add Floor and Ceiling Obstacles to Plan View if obj.mv.type == 'OBSTACLE': pv_scene.objects.link(obj) for child in obj.children: child.hide_render = False pv_scene.objects.link(child) if obj.mv.type == 'BPWALL': pv_scene.objects.link(obj) #Only link all of the wall meshes for child in obj.children: if child.mv.is_wall_mesh: child.select = True pv_scene.objects.link(child) grp.objects.link(child) wall = fd_types.Wall(obj_bp=obj) if wall.obj_bp and wall.obj_x and wall.obj_y and wall.obj_z: dim = fd_types.Dimension() dim.parent(wall.obj_bp) dim.start_y(value=unit.inch(4) + wall.obj_y.location.y) dim.start_z(value=wall.obj_z.location.z + unit.inch(8)) dim.end_x(value=wall.obj_x.location.x) self.ignore_obj_list.append(dim.anchor) self.ignore_obj_list.append(dim.end_point) bpy.ops.object.text_add() text = context.active_object text.parent = wall.obj_bp text.location = (wall.obj_x.location.x / 2, unit.inch(1.5), wall.obj_z.location.z) text.data.size = .1 text.data.body = wall.obj_bp.mv.name_object text.data.align_x = 'CENTER' text.data.font = self.font self.ignore_obj_list.append(dim.anchor) self.ignore_obj_list.append(dim.end_point) obj_bps = wall.get_wall_groups() #Create Cubes for all products for obj_bp in obj_bps: if obj_bp.mv.plan_draw_id != "": eval('bpy.ops.' + obj_bp.mv.plan_draw_id + '(object_name=obj_bp.name)') else: assembly = fd_types.Assembly(obj_bp) assembly_mesh = utils.create_cube_mesh( assembly.obj_bp.mv.name_object, (assembly.obj_x.location.x, assembly.obj_y.location.y, assembly.obj_z.location.z)) assembly_mesh.parent = wall.obj_bp assembly_mesh.location = assembly.obj_bp.location assembly_mesh.rotation_euler = assembly.obj_bp.rotation_euler assembly_mesh.mv.type = 'CAGE' distance = unit.inch(14) distance += wall.obj_y.location.y dim = fd_types.Dimension() dim.parent(assembly_mesh) dim.start_y(value=distance) dim.start_z(value=0) dim.end_x(value=assembly.obj_x.location.x) self.ignore_obj_list.append(dim.anchor) self.ignore_obj_list.append(dim.end_point) if wall and wall.get_wall_mesh(): wall.get_wall_mesh().select = True camera = self.create_camera(pv_scene) camera.rotation_euler.z = math.radians(-90.0) bpy.ops.object.select_all(action="SELECT") bpy.ops.view3d.camera_to_view_selected() camera.data.ortho_scale += self.pv_pad