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 draw_product_size(self,layout): row = layout.row() box = row.box() col = box.column(align=True) row1 = col.row(align=True) if self.object_has_driver(self.product.obj_x): row1.label('Width: ' + str(unit.meter_to_active_unit(math.fabs(self.product.obj_x.location.x)))) else: row1.label('Width:') row1.prop(self,'width',text="") row1.prop(self.product.obj_x,'hide',text="") row1 = col.row(align=True) if self.object_has_driver(self.product.obj_z): row1.label('Height: ' + str(unit.meter_to_active_unit(math.fabs(self.product.obj_z.location.z)))) else: row1.label('Height:') row1.prop(self,'height',text="") row1.prop(self.product.obj_z,'hide',text="") row1 = col.row(align=True) if self.object_has_driver(self.product.obj_y): row1.label('Depth: ' + str(unit.meter_to_active_unit(math.fabs(self.product.obj_y.location.y)))) else: row1.label('Depth:') row1.prop(self,'depth',text="") row1.prop(self.product.obj_y,'hide',text="")
def draw_product_size(self, layout): row = layout.row() box = row.box() col = box.column(align=True) row1 = col.row(align=True) if self.object_has_driver(self.product.obj_x): row1.label('Width: ' + str( unit.meter_to_active_unit( math.fabs(self.product.obj_x.location.x)))) else: row1.label('Width:') row1.prop(self, 'width', text="") row1.prop(self.product.obj_x, 'hide', text="") row1 = col.row(align=True) if self.object_has_driver(self.product.obj_z): row1.label('Height: ' + str( unit.meter_to_active_unit( math.fabs(self.product.obj_z.location.z)))) else: row1.label('Height:') row1.prop(self, 'height', text="") row1.prop(self.product.obj_z, 'hide', text="") row1 = col.row(align=True) if self.object_has_driver(self.product.obj_y): row1.label('Depth: ' + str( unit.meter_to_active_unit( math.fabs(self.product.obj_y.location.y)))) else: row1.label('Depth:') row1.prop(self, 'depth', text="") row1.prop(self.product.obj_y, 'hide', text="")
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 = math.fabs(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 modal(self, context, event): self.set_type_value(event) wall_length_text = str(unit.meter_to_active_unit(round(self.wall.obj_x.location.x,4))) wall_length_unit = '"' if context.scene.unit_settings.system == 'IMPERIAL' else 'mm' context.area.header_text_set(text=self.header_text + ' (Current Wall Length = ' + wall_length_text + wall_length_unit + ')') context.window.cursor_set('PAINT_BRUSH') context.area.tag_redraw() selected_point, selected_obj = utils.get_selection_point(context,event,objects=[self.drawing_plane]) #Pass in Drawing Plane bpy.ops.object.select_all(action='DESELECT') self.wall.obj_y.location.y = bpy.context.scene.mv.default_wall_depth if selected_obj: if event.ctrl: self.is_disconnected = True self.wall.obj_bp.constraints.clear() self.wall.obj_bp.location.x = selected_point[0] self.wall.obj_bp.location.y = selected_point[1] self.wall.obj_bp.location.z = 0 self.wall.obj_y.location.y = 0 self.wall.obj_x.location.x = 0 self.starting_point = (self.wall.obj_bp.location.x, self.wall.obj_bp.location.y, 0) else: selected_obj.select = True self.position_wall(selected_point) if self.event_is_place_wall(event): self.place_wall() if event.type in {'MIDDLEMOUSE', 'WHEELUPMOUSE', 'WHEELDOWNMOUSE'}: return {'PASS_THROUGH'} if self.event_is_cancel(event): return self.cancel_drop(context,event) return {'RUNNING_MODAL'}
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index): layout.label(text=item.name) if item.Type == 'NUMBER': layout.label(str(item.NumberValue)) if item.Type == 'CHECKBOX': layout.label(str(item.CheckBoxValue)) if item.Type == 'QUANTITY': layout.label(str(item.QuantityValue)) if item.Type == 'COMBOBOX': layout.label(str(item.EnumIndex)) if item.Type == 'DISTANCE': layout.label(str(unit.meter_to_active_unit(item.DistanceValue))) if item.Type == 'ANGLE': layout.label(str(item.AngleValue)) if item.Type == 'PERCENTAGE': layout.label(str(item.PercentageValue)) if item.Type == 'PRICE': layout.label(str(item.PriceValue))
def add_prompt(prompt): if prompt.Type == 'NUMBER': prompts[prompt.name] = str(prompt.NumberValue) if prompt.Type == 'QUANTITY': prompts[prompt.name] = str(prompt.QuantityValue) if prompt.Type == 'COMBOBOX': prompts[prompt.name] = str(prompt.COL_EnumItem[prompt.EnumIndex].name) if prompt.Type == 'CHECKBOX': prompts[prompt.name] = str(prompt.CheckBoxValue) if prompt.Type == 'TEXT': prompts[prompt.name] = str(prompt.TextValue) if prompt.Type == 'DISTANCE': prompts[prompt.name] = str(round(unit.meter_to_active_unit(prompt.DistanceValue),4)) if prompt.Type == 'ANGLE': prompts[prompt.name] = str(prompt.AngleValue) if prompt.Type == 'PERCENTAGE': prompts[prompt.name] = str(prompt.PercentageValue) if prompt.Type == 'PRICE': prompts[prompt.name] = str(prompt.PriceValue)
def location(self,location): return str(round(unit.meter_to_active_unit(location),4))
def distance(self,distance): return str(math.fabs(round(unit.meter_to_active_unit(distance),4)))
def write_solid_stock_material(self,project_node): elm_solid_stocks = self.xml.add_element(project_node,"SolidStocks") for solid_stock in self.solid_stock_materials: solid_stock_name = solid_stock if solid_stock != "" else "Unnamed" elm_solid_stock = self.xml.add_element(elm_solid_stocks,'SolidStock',solid_stock_name) self.xml.add_element_with_text(elm_solid_stock,'Thickness',str(unit.meter_to_active_unit(self.solid_stock_materials[solid_stock])))
def draw(self, context): layout = self.layout layout.label(self.product.obj_bp.mv.name_object) self.draw_product_size(layout) col = layout.column(align=True) box = col.box() row = box.row() left_fin_end = self.product.get_prompt("Left Fin End") right_fin_end = self.product.get_prompt("Right Fin End") if left_fin_end and right_fin_end: row.label("Finished Ends:") left_fin_end.draw_prompt(row,split_text=False) right_fin_end.draw_prompt(row,split_text=False) left_side_wall_filler = self.product.get_prompt("Left Side Wall Filler") right_side_wall_filler = self.product.get_prompt("Right Side Wall Filler") if left_side_wall_filler and right_side_wall_filler: box = col.box() row = box.row() row.label("Fillers:") left_side_wall_filler.draw_prompt(row) row = box.row() row.label(" ") right_side_wall_filler.draw_prompt(row) add_backsplash = self.product.get_prompt("Add Backsplash") add_left_backsplash = self.product.get_prompt("Add Left Backsplash") add_right_backsplash = self.product.get_prompt("Add Right Backsplash") ctop_overhang_front = self.product.get_prompt("Countertop Overhang Front") ctop_overhang_back = self.product.get_prompt("Countertop Overhang Back") ctop_overhang_left = self.product.get_prompt("Countertop Overhang Left") ctop_overhang_right = self.product.get_prompt("Countertop Overhang Right") ctop_overhang_left_back = self.product.get_prompt("Countertop Overhang Left Back") ctop_overhang_right_back = self.product.get_prompt("Countertop Overhang Right Back") side_splash_setback = self.product.get_prompt("Side Splash Setback") if ctop_overhang_front: box = col.box() row = box.row() row.label("Countertop:") row = box.row() if add_backsplash: add_backsplash.draw_prompt(row,split_text=False) if add_left_backsplash: add_left_backsplash.draw_prompt(row,text="Add Left",split_text=False) if add_right_backsplash: add_right_backsplash.draw_prompt(row,text="Add Right",split_text=False) if side_splash_setback: side_splash_setback.draw_prompt(row,text="Setback",split_text=False) row = box.row(align=True) row.label("Overhang:") ctop_overhang_front.draw_prompt(row,text="Front",split_text=False) if ctop_overhang_back: ctop_overhang_back.draw_prompt(row,text="Back",split_text=False) if ctop_overhang_left: ctop_overhang_left.draw_prompt(row,text="Left",split_text=False) if ctop_overhang_right: ctop_overhang_right.draw_prompt(row,text="Right",split_text=False) if ctop_overhang_left_back: row = box.row(align=True) ctop_overhang_left_back.draw_prompt(row,text="Back Left",split_text=False) if ctop_overhang_right_back: ctop_overhang_right_back.draw_prompt(row,text="Back Right",split_text=False) base_inset_front = self.product.get_prompt("Base Inset Front") base_inset_rear = self.product.get_prompt("Base Inset Rear") base_inset_left = self.product.get_prompt("Base Inset Left") base_inset_right = self.product.get_prompt("Base Inset Right") toe_kick_height = self.product.get_prompt("Toe Kick Height") toe_kick_setback = self.product.get_prompt("Toe Kick Setback") if toe_kick_height: box = col.box() row = box.row() row.label("Base Assembly:") base_inset_front.draw_prompt(row,text="Front",split_text=False) base_inset_rear.draw_prompt(row,text="Rear",split_text=False) base_inset_left.draw_prompt(row,text="Left",split_text=False) base_inset_right.draw_prompt(row,text="Right",split_text=False) row = box.row() row.label(" ") toe_kick_height.draw_prompt(row,split_text=False) toe_kick_setback.draw_prompt(row,split_text=False) col.separator() if self.insert and self.insert.obj_bp: box = col.box() row = box.row() row.label("Front Options:") inset_front = self.insert.get_prompt("Inset Front") door_swing = self.insert.get_prompt("Door Swing") no_pulls = self.insert.get_prompt("No Pulls") if door_swing: door_swing.draw_prompt(row) if inset_front: row = box.row() inset_front.draw_prompt(row,split_text=False) if no_pulls: no_pulls.draw_prompt(row,split_text=False) drawer_front_height = self.insert.get_prompt("Drawer Front Height") if drawer_front_height: drawer_front_height.draw_prompt(row) top_door_height = self.insert.get_prompt("Top Door Height") if top_door_height: top_door_height.draw_prompt(row) col = box.column(align=True) for i in range(1,7): drawer_front_height = self.insert.get_prompt("Drawer Front " + str(i) + " Height") if drawer_front_height: row = col.row() if drawer_front_height.equal: row.label("Drawer Front " + str(i) + " Height") row.label(str(unit.meter_to_active_unit(drawer_front_height.value())) + '"') else: drawer_front_height.draw_prompt(row) row.prop(drawer_front_height,'equal',text="")