def execute(self, context):
        obj_bp = utils.get_assembly_bp(context.active_object)
        assembly = fd_types.Assembly(obj_bp)
        obj_bp = assembly.obj_bp
        dim_x = assembly.obj_x.location.x
        dim_y = assembly.obj_y.location.y
        dim_z = assembly.obj_z.location.z

        obj_mesh = utils.create_cube_mesh(self.mesh_name,
                                          (dim_x, dim_y, dim_z))

        if obj_mesh:
            obj_mesh.mv.name_object = self.mesh_name
            context.scene.objects.active = obj_mesh
            bpy.ops.object.editmode_toggle()
            bpy.ops.mesh.select_all(action='SELECT')
            bpy.ops.mesh.normals_make_consistent(inside=False)
            bpy.ops.object.editmode_toggle()
            if obj_bp:
                obj_mesh.parent = obj_bp

            update_vector_groups(obj_bp)
            bpy.ops.fd_assembly.load_active_assembly_objects(
                object_name=obj_bp.name)
        return {'FINISHED'}
Example #2
0
    def create_elv_view_scene(self, context, wall):
        bpy.ops.scene.new('INVOKE_DEFAULT', type='EMPTY')
        wall_group = bpy.data.groups.new(wall.obj_bp.mv.name_object)

        new_scene = context.scene
        new_scene.name = wall_group.name
        new_scene.mv.name_scene = wall.obj_bp.mv.name_object
        new_scene.mv.elevation_img_name = wall.obj_bp.name
        new_scene.mv.plan_view_scene = False
        new_scene.mv.elevation_scene = True

        self.group_children(wall_group, wall.obj_bp)
        wall_mesh = utils.create_cube_mesh(
            wall.obj_bp.mv.name_object,
            (wall.obj_x.location.x, wall.obj_y.location.y,
             wall.obj_z.location.z))
        wall_mesh.parent = wall.obj_bp
        wall_group.objects.link(wall_mesh)

        instance = bpy.data.objects.new(
            wall.obj_bp.mv.name_object + " " + "Instance", None)
        new_scene.objects.link(instance)
        instance.dupli_type = 'GROUP'
        instance.dupli_group = wall_group

        new_scene.world = self.main_scene.world

        self.link_dims_to_scene(new_scene, wall.obj_bp)

        bpy.ops.object.text_add()

        text = context.active_object
        text.parent = wall.obj_bp
        text.location.x = unit.inch(-2)
        text.location.z = unit.inch(-10)
        text.rotation_euler.x = math.radians(90)
        text.data.size = .1
        text.data.body = wall.obj_bp.mv.name_object
        text.data.align = 'RIGHT'
        text.data.font = self.font

        camera = self.create_camera(new_scene)
        camera.rotation_euler.x = math.radians(90.0)
        camera.rotation_euler.z = wall.obj_bp.rotation_euler.z
        bpy.ops.object.select_all(action='DESELECT')
        wall_mesh.select = True
        bpy.ops.view3d.camera_to_view_selected()
        camera.data.ortho_scale += self.pv_pad
    def execute(self, context):
        obj_bp = utils.get_assembly_bp(context.active_object)
        assembly = fd_types.Assembly(obj_bp)
        obj_bp = assembly.obj_bp
        dim_x = assembly.obj_x.location.x
        dim_y = assembly.obj_y.location.y
        dim_z = assembly.obj_z.location.z

        obj_mesh = utils.create_cube_mesh(self.mesh_name,(dim_x,dim_y,dim_z))
                
        if obj_mesh:
            obj_mesh.mv.name_object = self.mesh_name
            context.scene.objects.active = obj_mesh
            bpy.ops.object.editmode_toggle()
            bpy.ops.mesh.select_all(action='SELECT')
            bpy.ops.mesh.normals_make_consistent(inside=False)
            bpy.ops.object.editmode_toggle()
            if obj_bp:
                obj_mesh.parent = obj_bp

            update_vector_groups(obj_bp)
            bpy.ops.fd_assembly.load_active_assembly_objects(object_name=obj_bp.name)
        return {'FINISHED'}
Example #4
0
    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
Example #5
0
 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