def appliance_drop(self, context, event): selected_point, selected_obj = utils.get_selection_point( context, event) bpy.ops.object.select_all(action='DESELECT') sel_assembly_bp = utils.get_assembly_bp(selected_obj) if sel_assembly_bp: selected_assembly = fd_types.Assembly(sel_assembly_bp) self.assembly.obj_bp.parent = selected_assembly.obj_bp.parent self.assembly.obj_bp.location = selected_assembly.obj_bp.location self.assembly.obj_z.location.z = selected_assembly.obj_z.location.z self.assembly.obj_y.location.y = selected_assembly.obj_y.location.y self.assembly.obj_x.location.x = selected_assembly.obj_x.location.x else: self.assembly.obj_bp.parent = None self.assembly.obj_bp.location = selected_point if event.type == 'LEFTMOUSE' and event.value == 'PRESS': if sel_assembly_bp: selected_assembly = fd_types.Assembly(sel_assembly_bp) selected_assembly.replace(self.assembly) utils.set_wireframe(self.assembly.obj_bp, False) bpy.context.window.cursor_set('DEFAULT') bpy.ops.object.select_all(action='DESELECT') context.scene.objects.active = self.assembly.obj_bp self.assembly.obj_bp.select = True return {'FINISHED'} return {'RUNNING_MODAL'}
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 write_nested_subassemblies(self,elm_subassembly,obj_bp,spec_group): for child in obj_bp.children: if child.mv.export_as_subassembly: assembly = fd_types.Assembly(child) hide = assembly.get_prompt("Hide") if hide: if hide.value(): continue #SKIP HIDDEN SUBASSEMBLIES comment = "" for achild in assembly.obj_bp.children: if achild.mv.comment != "": comment = achild.mv.comment break sub_name = assembly.obj_bp.mv.name_object if assembly.obj_bp.mv.name_object != "" else assembly.obj_bp.name elm_item = self.xml.add_element(elm_subassembly,'Subassembly',sub_name) self.xml.add_element_with_text(elm_item,'LinkID',assembly.obj_bp.name) self.xml.add_element_with_text(elm_item,'IsBuyout','False') self.xml.add_element_with_text(elm_item,'XLocation',self.location(assembly.obj_bp.location.x)) self.xml.add_element_with_text(elm_item,'YLocation',self.location(assembly.obj_bp.location.y)) self.xml.add_element_with_text(elm_item,'ZLocation',self.location(assembly.obj_bp.location.z)) self.xml.add_element_with_text(elm_item,'XDimension',self.distance(assembly.obj_x.location.x)) self.xml.add_element_with_text(elm_item,'YDimension',self.distance(assembly.obj_y.location.y)) self.xml.add_element_with_text(elm_item,'ZDimension',self.distance(assembly.obj_z.location.z)) self.xml.add_element_with_text(elm_item,'Comment',comment) elm_prompts = self.xml.add_element(elm_item,"Prompts") self.write_prompts_for_assembly(elm_prompts, assembly) elm_parts = self.xml.add_element(elm_item,"Parts") self.write_parts_for_subassembly(elm_parts,assembly.obj_bp,spec_group) elm_hardware = self.xml.add_element(elm_item,"Hardware") self.write_hardware_for_assembly(elm_hardware,assembly.obj_bp)
def sink_drop(self, context, event): selected_point, selected_obj = utils.get_selection_point( context, event) bpy.ops.object.select_all(action='DESELECT') sel_product_bp = utils.get_bp(selected_obj, 'PRODUCT') sel_assembly_bp = utils.get_assembly_bp(selected_obj) if sel_product_bp and sel_assembly_bp: product = fd_types.Assembly(sel_product_bp) if product: product_depth = math.fabs(product.obj_y.location.y) assembly_depth = math.fabs(self.assembly.obj_y.location.y) self.assembly.obj_bp.parent = product.obj_bp if product.obj_z.location.z < 0: self.assembly.obj_bp.location.z = unit.inch( 1.5) #SUSPENDED CABINETS else: self.assembly.obj_bp.location.z = product.obj_z.location.z + unit.inch( 1.5) #BASE CABINETS self.assembly.obj_bp.location.y = -math.fabs( product_depth - assembly_depth) / 2 self.assembly.obj_bp.location.x = product.obj_x.location.x / 2 - self.assembly.obj_x.location.x / 2 if event.type == 'LEFTMOUSE' and event.value == 'PRESS': self.assign_boolean(selected_obj) utils.set_wireframe(self.assembly.obj_bp, False) bpy.context.window.cursor_set('DEFAULT') bpy.ops.object.select_all(action='DESELECT') context.scene.objects.active = self.assembly.obj_bp self.assembly.obj_bp.select = True return {'FINISHED'} return {'RUNNING_MODAL'}
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'}
def invoke(self,context,event): # This gets called first and is used as an init call obj = context.scene.objects[self.object_name] obj_product_bp = utils.get_bp(obj,'PRODUCT') self.product = fd_types.Assembly(obj_product_bp) wm = context.window_manager return wm.invoke_props_dialog(self, width=utils.get_prop_dialog_width(480))
def execute(self, context): ui = context.scene.mv.ui self.group = fd_types.Assembly(bpy.data.objects[self.object_name]) if ui.group_driver_tabs == 'LOC_X': self.group.obj_bp.driver_remove('location', 0) if ui.group_driver_tabs == 'LOC_Y': self.group.obj_bp.driver_remove('location', 1) if ui.group_driver_tabs == 'LOC_Z': self.group.obj_bp.driver_remove('location', 2) if ui.group_driver_tabs == 'ROT_X': self.group.obj_bp.driver_remove('rotation_euler', 0) if ui.group_driver_tabs == 'ROT_Y': self.group.obj_bp.driver_remove('rotation_euler', 1) if ui.group_driver_tabs == 'ROT_Z': self.group.obj_bp.driver_remove('rotation_euler', 2) if ui.group_driver_tabs == 'DIM_X': obj_x = self.group.obj_x obj_x.select = True obj_x.driver_remove('location', 0) if ui.group_driver_tabs == 'DIM_Y': obj_y = self.group.obj_y obj_y.select = True obj_y.driver_remove('location', 1) if ui.group_driver_tabs == 'DIM_Z': obj_z = self.group.obj_z obj_z.select = True obj_z.driver_remove('location', 2) if ui.group_driver_tabs == 'PROMPTS': prompt = self.group.obj_bp.mv.PromptPage.COL_Prompt[ self.group.obj_bp.mv.PromptPage.PromptIndex] if prompt.Type == 'DISTANCE': self.group.obj_bp.driver_remove('mv.PromptPage.COL_Prompt["' + prompt.name + '"].DistanceValue') if prompt.Type == 'ANGLE': self.group.obj_bp.driver_remove('mv.PromptPage.COL_Prompt["' + prompt.name + '"].AngleValue') if prompt.Type == 'PERCENTAGE': self.group.obj_bp.driver_remove('mv.PromptPage.COL_Prompt["' + prompt.name + '"].PercentageValue') if prompt.Type == 'PRICE': self.group.obj_bp.driver_remove('mv.PromptPage.COL_Prompt["' + prompt.name + '"].PriceValue') if prompt.Type == 'NUMBER': self.group.obj_bp.driver_remove('mv.PromptPage.COL_Prompt["' + prompt.name + '"].NumberValue') if prompt.Type == 'QUANTITY': self.group.obj_bp.driver_remove('mv.PromptPage.COL_Prompt["' + prompt.name + '"].QuantityValue') if prompt.Type == 'COMBOBOX': self.group.obj_bp.driver_remove('mv.PromptPage.COL_Prompt["' + prompt.name + '"].EnumIndex') if prompt.Type == 'CHECKBOX': self.group.obj_bp.driver_remove('mv.PromptPage.COL_Prompt["' + prompt.name + '"].CheckBoxValue') return {'FINISHED'}
def invoke(self, context, event): bp = bpy.data.objects[self.object_name] self.assembly = fd_types.Assembly(bp) utils.set_wireframe(self.assembly.obj_bp,True) context.window.cursor_set('PAINT_BRUSH') context.scene.update() # THE SCENE MUST BE UPDATED FOR RAY CAST TO WORK context.window_manager.modal_handler_add(self) return {'RUNNING_MODAL'}
def invoke(self, context, event): self.reset_variables() obj = bpy.data.objects[self.object_name] obj_bp = utils.get_assembly_bp(obj) if obj_bp: self.group = fd_types.Assembly(obj_bp) self.get_part_prompts() wm = context.window_manager return wm.invoke_props_dialog(self, width=utils.get_prop_dialog_width(400))
def execute(self, context): group = fd_types.Assembly() group.create_assembly() group.obj_x.location.x = self.assembly_size[0] group.obj_y.location.y = self.assembly_size[1] group.obj_z.location.z = self.assembly_size[2] group.build_cage() bpy.ops.object.select_all(action='DESELECT') group.obj_bp.select = True context.scene.objects.active = group.obj_bp return {'FINISHED'}
def write_products(self,project_node): specgroups = bpy.context.scene.mv.spec_groups elm_products = self.xml.add_element(project_node,"Products") item_number = 1 for obj_product in self.products: spec_group = specgroups[obj_product.cabinetlib.spec_group_index] product = fd_types.Assembly(obj_product) product_name = product.obj_bp.mv.name_object if product.obj_bp.mv.name_object != "" else product.obj_bp.name elm_product = self.xml.add_element(elm_products,'Product',product_name) self.xml.add_element_with_text(elm_product,'LinkID',obj_product.name) self.xml.add_element_with_text(elm_product,'LinkIDWall',obj_product.parent.name if obj_product.parent else 'None') self.xml.add_element_with_text(elm_product,'IsBuyout','False') self.xml.add_element_with_text(elm_product,'IsCorner','False') self.xml.add_element_with_text(elm_product,'LinkIDLocation',obj_product.users_scene[0].name) self.xml.add_element_with_text(elm_product,'LinkIDSpecificationGroup',spec_group.name) if obj_product.mv.item_number == 0: self.xml.add_element_with_text(elm_product,'ItemNumber',str(item_number)) item_number += 1 else: self.xml.add_element_with_text(elm_product,'ItemNumber',str(obj_product.mv.item_number)) self.xml.add_element_with_text(elm_product,'LinkIDLibrary',obj_product.mv.library_name) self.xml.add_element_with_text(elm_product,'Width',self.distance(product.obj_x.location.x)) self.xml.add_element_with_text(elm_product,'Height',self.distance(product.obj_z.location.z)) self.xml.add_element_with_text(elm_product,'Depth',self.distance(product.obj_y.location.y)) self.xml.add_element_with_text(elm_product,'XOrigin',self.location(obj_product.matrix_world[0][3])) self.xml.add_element_with_text(elm_product,'YOrigin',self.location(obj_product.matrix_world[1][3])) self.xml.add_element_with_text(elm_product,'ZOrigin',self.location(self.get_product_z_location(product))) self.xml.add_element_with_text(elm_product,'Comment',obj_product.mv.comment) self.xml.add_element_with_text(elm_product,'Angle',self.angle(obj_product.parent.rotation_euler.z + obj_product.rotation_euler.z) if obj_product.parent else self.angle(obj_product.rotation_euler.z)) #PRODUCTS MARKED TO EXPORT SUBASSEMBLIES WILL EXPORT A STRUCTURE #NESTED ONLY THREE LEVELS DEEP #PRODUCTS NOT MARKED WILL EXPORT A FLAT STRUCTURE ONE LEVEL DEEP if product.obj_bp.mv.export_product_subassemblies: use_recursive = False else: use_recursive = True elm_prompts = self.xml.add_element(elm_product,"Prompts") self.write_prompts_for_assembly(elm_prompts, product) elm_parts = self.xml.add_element(elm_product,"Parts") self.write_parts_for_product(elm_parts,obj_product,spec_group,recursive=use_recursive) elm_hardware = self.xml.add_element(elm_product,"Hardware") self.write_hardware_for_assembly(elm_hardware,obj_product,recursive=use_recursive) if not use_recursive: elm_subassemblies = self.xml.add_element(elm_product,"Subassemblies") self.write_subassemblies_for_product(elm_subassemblies,obj_product,spec_group)
def make_opening_available(self,obj_bp): insert = fd_types.Assembly(obj_bp) if obj_bp.parent: for child in obj_bp.parent.children: if child.mv.type_group == 'OPENING' and insert.obj_bp.location == child.location: if insert.obj_bp.mv.placement_type == 'SPLITTER': child.mv.interior_open = True child.mv.exterior_open = True break if insert.obj_bp.mv.placement_type == 'INTERIOR': child.mv.interior_open = True break if insert.obj_bp.mv.placement_type == 'EXTERIOR': child.mv.exterior_open = True break
def execute(self, context): obj = bpy.data.objects[self.object_name] scene = context.scene.mv for current_obj in scene.children_objects: scene.children_objects.remove(0) group = fd_types.Assembly(obj) group.set_object_names() scene.active_object_name = obj.name for child in obj.children: if child.mv.type not in {'VPDIMX','VPDIMY','VPDIMZ','CAGE'}: list_obj = scene.children_objects.add() list_obj.name = child.name return {'FINISHED'}
def execute(self, context): obj = bpy.data.objects[self.object_name] obj_bp = utils.get_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 for obj in obj_list: if obj.type == 'EMPTY': obj.hide = True if obj.mv.type == 'BPASSEMBLY': obj.hide = True obj.location = obj.location bpy.ops.object.select_all(action='DESELECT') obj_bp.select = True context.scene.objects.active = obj_bp assembly = fd_types.Assembly(obj_bp) if assembly.obj_bp.mv.drop_id != "": self.clear_drivers(assembly) eval('bpy.ops.' + assembly.obj_bp.mv.drop_id + '("INVOKE_DEFAULT",object_name=assembly.obj_bp.name)') return {'FINISHED'} if assembly.obj_bp.mv.type_group == 'PRODUCT': self.clear_drivers(assembly) eval('bpy.ops.fd_general.drop_product("INVOKE_DEFAULT",object_name=assembly.obj_bp.name)') return {'FINISHED'} if assembly.obj_bp.mv.type_group == 'INSERT': self.clear_drivers(assembly) eval('bpy.ops.fd_general.drop_insert("INVOKE_DEFAULT",object_name=assembly.obj_bp.name)') return {'FINISHED'} return {'FINISHED'}
def execute(self, context): obj = context.object assembly = fd_types.Assembly() assembly.create_assembly() assembly.set_name(self.assembly_name) assembly.obj_bp.location = obj.location assembly.obj_bp.rotation_euler = obj.rotation_euler obj.parent = assembly.obj_bp obj.location = (0,0,0) obj.rotation_euler = (0,0,0) assembly.obj_x.location.x = obj.dimensions.x assembly.obj_y.location.y = -obj.dimensions.y assembly.obj_z.location.z = obj.dimensions.z cage = assembly.get_cage() bpy.ops.object.select_all(action='DESELECT') assembly.obj_bp.select = True context.scene.objects.active = assembly.obj_bp return {'FINISHED'}
def invoke(self, context, event): obj = bpy.data.objects[self.object_name] obj_product_bp = utils.get_bp(obj, 'PRODUCT') self.product = fd_types.Assembly(obj_product_bp) if self.product.obj_bp: self.depth = math.fabs(self.product.obj_y.location.y) self.height = math.fabs(self.product.obj_z.location.z) self.width = math.fabs(self.product.obj_x.location.x) self.start_x = self.product.obj_bp.location.x self.x_loc = self.product.obj_bp.location.x self.start_width = math.fabs(self.product.obj_x.location.x) self.array_x_prompt = self.product.get_prompt("Array X") self.array_x = self.array_x_prompt.value() self.array_x_offset_prompt = self.product.get_prompt( "Array X Offset") self.array_x_offset = self.array_x_offset_prompt.value() wm = context.window_manager return wm.invoke_props_dialog(self, width=480)
def execute(self, context): obj_bp = utils.get_assembly_bp(context.active_object) group = fd_types.Assembly(obj_bp) dim_x = group.obj_x.location.x bpy.ops.curve.primitive_bezier_curve_add(enter_editmode=False) obj_curve = context.active_object obj_curve.data.show_handles = False obj_curve.data.splines[0].bezier_points[0].co = (0,0,0) obj_curve.data.splines[0].bezier_points[1].co = (dim_x,0,0) bpy.ops.object.editmode_toggle() bpy.ops.curve.select_all(action='SELECT') bpy.ops.curve.handle_type_set(type='VECTOR') bpy.ops.object.editmode_toggle() obj_curve.data.dimensions = '2D' if obj_curve: obj_curve.mv.name_object = self.curve_name obj_curve.parent = obj_bp bpy.ops.fd_assembly.load_active_assembly_objects(object_name=obj_bp.name) return {'FINISHED'}
def invoke(self, context, event): obj = bpy.data.objects[self.object_name] obj_product_bp = utils.get_bp(obj, 'PRODUCT') self.product = fd_types.Assembly(obj_product_bp) if self.product.obj_bp: self.depth = math.fabs(self.product.obj_y.location.y) self.height = math.fabs(self.product.obj_z.location.z) self.width = math.fabs(self.product.obj_x.location.x) try: self.open_door_prompt = self.product.get_prompt( "Door Rotation") self.door_rotation = self.open_door_prompt.value() except: pass try: self.door_swing_prompt = self.product.get_prompt("Door Swing") self.door_swing = self.door_swing_prompt.value() except: pass wm = context.window_manager return wm.invoke_props_dialog(self, width=480)
def execute(self, context): obj = context.active_object wall_bp = utils.get_wall_bp(obj) wall_bps = [] for obj in context.visible_objects: if obj.mv.type == 'BPWALL': wall_bps.append(obj) for wall in wall_bps: if wall != wall_bp: children = [] children = utils.get_child_objects(wall) for child in children: child.hide = True else: wall_assembly = fd_types.Assembly(wall) wall_assembly.obj_x.select = True wall_assembly.obj_y.select = True wall_assembly.obj_z.select = True bpy.ops.view3d.view_selected() 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
def execute(self, context): obj = bpy.data.objects[self.object_name] obj_bp = utils.get_assembly_bp(obj) if obj_bp: self.group = fd_types.Assembly(obj_bp) for DR in obj.animation_data.drivers: if self.data_path in DR.data_path and DR.array_index == self.array_index: DR.driver.show_debug_info = False if self.x_loc: var = DR.driver.variables.new() var.name = 'loc_x' var.targets[0].id = self.group.obj_bp var.targets[0].data_path = 'location.x' if self.y_loc: var = DR.driver.variables.new() var.name = 'loc_y' var.targets[0].id = self.group.obj_bp var.targets[0].data_path = 'location.y' if self.z_loc: var = DR.driver.variables.new() var.name = 'loc_z' var.targets[0].id = self.group.obj_bp var.targets[0].data_path = 'location.z' if self.x_rot: var = DR.driver.variables.new() var.name = 'rot_x' var.targets[0].id = self.group.obj_bp var.targets[0].data_path = 'rotation_euler.x' if self.y_rot: var = DR.driver.variables.new() var.name = 'rot_y' var.targets[0].id = self.group.obj_bp var.targets[0].data_path = 'rotation_euler.y' if self.z_rot: var = DR.driver.variables.new() var.name = 'rot_z' var.targets[0].id = self.group.obj_bp var.targets[0].data_path = 'rotation_euler.z' if self.x_dim: var = DR.driver.variables.new() var.name = 'dim_x' var.targets[0].id = self.group.obj_x var.targets[0].data_path = 'location.x' if self.y_dim: var = DR.driver.variables.new() var.name = 'dim_y' var.targets[0].id = self.group.obj_y var.targets[0].data_path = 'location.y' if self.z_dim: var = DR.driver.variables.new() var.name = 'dim_z' var.targets[0].id = self.group.obj_z var.targets[0].data_path = 'location.z' # if self.spec_group_index: # var = DR.driver.variables.new() # var.name = 'sgi' # var.targets[0].id = obj_bp # var.targets[0].data_path = 'mv.spec_group_index' for prompt in self.COL_prompt: if prompt.add: var = DR.driver.variables.new() var.name = prompt.name.replace(" ", "") var.targets[0].id = obj_bp if prompt.type == 'NUMBER': var.targets[ 0].data_path = 'mv.PromptPage.COL_Prompt["' + prompt.name + '"].NumberValue' if prompt.type == 'QUANTITY': var.targets[ 0].data_path = 'mv.PromptPage.COL_Prompt["' + prompt.name + '"].QuantityValue' if prompt.type == 'NUMBER': var.targets[ 0].data_path = 'mv.PromptPage.COL_Prompt["' + prompt.name + '"].NumberValue' if prompt.type == 'COMBOBOX': var.targets[ 0].data_path = 'mv.PromptPage.COL_Prompt["' + prompt.name + '"].EnumIndex' if prompt.type == 'CHECKBOX': var.targets[ 0].data_path = 'mv.PromptPage.COL_Prompt["' + prompt.name + '"].CheckBoxValue' if prompt.type == 'DISTANCE': var.targets[ 0].data_path = 'mv.PromptPage.COL_Prompt["' + prompt.name + '"].DistanceValue' if prompt.type == 'PERCENTAGE': var.targets[ 0].data_path = 'mv.PromptPage.COL_Prompt["' + prompt.name + '"].PercentageValue' if prompt.type == 'PRICE': var.targets[ 0].data_path = 'mv.PromptPage.COL_Prompt["' + prompt.name + '"].PriceValue' if prompt.type == 'ANGLE': var.targets[ 0].data_path = 'mv.PromptPage.COL_Prompt["' + prompt.name + '"].AngleValue' var.type = 'SINGLE_PROP' for target in var.targets: target.transform_space = 'LOCAL_SPACE' return {'FINISHED'}
def write_part_node(self,node,obj,spec_group,recursive=False): if obj.mv.type == 'BPASSEMBLY': assembly = fd_types.Assembly(obj) else: assembly = fd_types.Assembly(obj.parent) if assembly.obj_bp.mv.type_group != "PRODUCT": if obj.type == 'CURVE': curve_name = obj.mv.name_object if obj.mv.name_object != "" else obj.name elm_part = self.xml.add_element(node,'Part',curve_name) else: obj_name = assembly.obj_bp.mv.name_object if assembly.obj_bp.mv.name_object != "" else assembly.obj_bp.name elm_part = self.xml.add_element(node,'Part',obj_name) if obj.cabinetlib.type_mesh == 'CUTPART': self.xml.add_element_with_text(elm_part,'PartType',"2") if obj.cabinetlib.type_mesh == 'BUYOUT': self.xml.add_element_with_text(elm_part,'PartType',"4") if utils.get_material_name(obj) not in self.buyout_materials: self.buyout_materials.append(utils.get_material_name(obj)) if obj.cabinetlib.type_mesh == 'SOLIDSTOCK': self.xml.add_element_with_text(elm_part,'PartType',"3") if utils.get_material_name(obj) not in self.solid_stock_materials: self.solid_stock_materials[utils.get_material_name(obj)] = utils.get_part_thickness(obj) self.xml.add_element_with_text(elm_part,'LinkID',assembly.obj_bp.name) self.xml.add_element_with_text(elm_part,'Qty',self.get_part_qty(assembly)) self.xml.add_element_with_text(elm_part,'MaterialName',utils.get_material_name(obj)) self.xml.add_element_with_text(elm_part,'Thickness',self.distance(utils.get_part_thickness(obj))) self.xml.add_element_with_text(elm_part,'UseSMA','True' if obj.mv.use_sma else 'False') self.xml.add_element_with_text(elm_part,'LinkIDProduct',utils.get_bp(obj,'PRODUCT').name) self.xml.add_element_with_text(elm_part,'LinkIDParent',assembly.obj_bp.parent.name) self.xml.add_element_with_text(elm_part,'PartLength',self.get_part_length(assembly)) self.xml.add_element_with_text(elm_part,'PartWidth',self.get_part_width(assembly)) self.xml.add_element_with_text(elm_part,'Comment',self.get_part_comment(assembly.obj_bp)) if recursive: self.xml.add_element_with_text(elm_part,'XOrigin',self.get_part_x_location(assembly.obj_bp,assembly.obj_bp.location.x)) self.xml.add_element_with_text(elm_part,'YOrigin',self.get_part_y_location(assembly.obj_bp,assembly.obj_bp.location.y)) self.xml.add_element_with_text(elm_part,'ZOrigin',self.get_part_z_location(assembly.obj_bp,assembly.obj_bp.location.z)) else: loc_pos = assembly.obj_bp.parent.matrix_world.inverted() * assembly.obj_bp.matrix_world x_loc = self.location(loc_pos[0][3]) y_loc = self.location(loc_pos[1][3]) z_loc = self.location(loc_pos[2][3]) self.xml.add_element_with_text(elm_part,'XOrigin',x_loc) self.xml.add_element_with_text(elm_part,'YOrigin',y_loc) self.xml.add_element_with_text(elm_part,'ZOrigin',z_loc) self.xml.add_element_with_text(elm_part,'XRotation',self.angle(assembly.obj_bp.rotation_euler.x)) self.xml.add_element_with_text(elm_part,'YRotation',self.angle(assembly.obj_bp.rotation_euler.y)) self.xml.add_element_with_text(elm_part,'ZRotation',self.angle(assembly.obj_bp.rotation_euler.z)) self.xml.add_element_with_text(elm_part,'EdgeWidth1',self.get_edgebanding_name(obj, obj.mv.edge_w1, spec_group)) self.xml.add_element_with_text(elm_part,'EdgeWidth2',self.get_edgebanding_name(obj, obj.mv.edge_w2, spec_group)) self.xml.add_element_with_text(elm_part,'EdgeLength1',self.get_edgebanding_name(obj, obj.mv.edge_l1, spec_group)) self.xml.add_element_with_text(elm_part,'EdgeLength2',self.get_edgebanding_name(obj, obj.mv.edge_l2, spec_group)) self.xml.add_element_with_text(elm_part,'DrawToken3D',"DRAW3DBOX CABINET") self.xml.add_element_with_text(elm_part,'ElvToken2D',"DRAW2DBOX CABINET") self.xml.add_element_with_text(elm_part,'BasePoint',self.get_part_base_point(assembly)) self.xml.add_element_with_text(elm_part,'MachinePoint',"1") self.xml.add_element_with_text(elm_part,'Par1',"") self.xml.add_element_with_text(elm_part,'Par2',"") self.xml.add_element_with_text(elm_part,'Par3',"") self.write_machine_tokens(elm_part, obj)
def execute(self, context): obj_bp = bpy.data.objects[self.object_name] obj_bp.mv.name_object = self.new_name group = fd_types.Assembly(obj_bp) group.set_object_names() return {'FINISHED'}