Exemplo n.º 1
0
    def execute(self, context):
        item = context.scene.jewelcraft.measurements.add()

        item.type = self.type

        if self.type == "RING_SIZE":
            if self.object_name:
                item.object = bpy.data.objects[self.object_name]
        else:
            if self.collection_name:
                item.collection = bpy.data.collections[self.collection_name]

        if self.type == "WEIGHT":
            materials = context.scene.jewelcraft.weighting_materials
            mat = materials.values()[int(self.material)]
            item.name = mat.name
            item.material_name = mat.name
            item.material_density = mat.density
        elif self.type == "DIMENSIONS":
            item.name = "{} {}".format(self.collection_name, _("Dimensions"))
            item.x = self.x
            item.y = self.y
            item.z = self.z
        elif self.type == "RING_SIZE":
            size_format = UILayout.enum_item_name(self, "ring_size",
                                                  self.ring_size)
            item.name = "{} ({})".format(_("Ring Size"), size_format)
            item.ring_size = self.ring_size
            item.axis = self.axis

        context.area.tag_redraw()

        return {"FINISHED"}
Exemplo n.º 2
0
    def draw(self, context):
        d = self.get_driver()
        v0 = d.fcurve.driver.variables[0]
        layout = self.layout
        if d:
            scene = context.scene
            gui = d.driver_gui(scene)
            '''
            if gui is not None:
                self.layout.prop(gui, "gui_types",
                             text="",
                             expand=True,
                             icon_only=True)
            '''
            d.draw_slider(self.layout)
            #d.edit(self.layout, context)
            print("VARIABLE DIC", d.vd)
            target_dic, rubbish_vars = get_var_dic(d)
            row = layout.row(align=True)
            row.label("Variables")
            op = row.operator("driver.new_var_popup", text="", icon='ZOOMIN')
            op.dindex = d.index
            if target_dic:
                for targetname, data in target_dic.items():
                    if targetname == "None":
                        continue
                    variables = data["variables"]
                    layout.label(targetname, icon_value=data.get("icon"))
                    col = layout.column()
                    #col.scale_y = 0.4

                    for type, varnames in variables.items():
                        #print(name)
                        col.label(type)
                        for name in varnames:
                            var = d.fcurve.driver.variables.get(name)
                            draw_variable(d, var, col)
                        #var = variables.get(key)

            if rubbish_vars:
                col = layout.column()
                col.alert = True
                col.label("No Targets")
                types = rubbish_vars.get("variables")
                for type, vars in types.items():
                    col.label(UILayout.enum_item_name(v0, "type", type),
                              icon_value=enum_item_icon(v0, "type", type))
                    for var in vars:
                        var = d.fcurve.driver.variables.get(var)
                        draw_variable(d, var, col)

            self.check(context)
Exemplo n.º 3
0
    def draw(self, context):
        d = self.get_driver()
        v0 = d.fcurve.driver.variables[0]
        layout = self.layout
        if d:        
            scene = context.scene    
            gui = d.driver_gui(scene)
            '''
            if gui is not None:
                self.layout.prop(gui, "gui_types",
                             text="",
                             expand=True,
                             icon_only=True)
            '''
            d.draw_slider(self.layout)
            #d.edit(self.layout, context)
            print("VARIABLE DIC", d.vd)
            target_dic, rubbish_vars = get_var_dic(d)
            row = layout.row(align=True)
            row.label("Variables")
            op = row.operator("driver.new_var_popup", text="", icon='ZOOMIN')
            op.dindex = d.index
            if target_dic:                
                for targetname, data in target_dic.items():
                    if targetname == "None":
                        continue
                    variables = data["variables"]
                    layout.label(targetname, icon_value=data.get("icon"))
                    col = layout.column()
                    #col.scale_y = 0.4
                    
                    for type, varnames in variables.items():
                        #print(name)
                        col.label(type)
                        for name in varnames:
                            var = d.fcurve.driver.variables.get(name)
                            draw_variable(d, var, col)
                        #var = variables.get(key)

            if rubbish_vars:
                col = layout.column()
                col.alert = True
                col.label("No Targets")
                types = rubbish_vars.get("variables")
                for type, vars in types.items():
                    col.label(UILayout.enum_item_name(v0, "type", type), icon_value=enum_item_icon(v0, "type", type))
                    for var in vars:
                        var = d.fcurve.driver.variables.get(var)
                        draw_variable(d, var, col)
                
            self.check(context)