Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- layout.column().prop(view, "cursor_location", text="Location")
- class path_mesh_viewer_panel(bpy.types.Panel):
- bl_label = "Path Node"
- bl_space_type = 'PROPERTIES'
- bl_region_type = 'WINDOW'
- bl_context = "scene"
- @classmethod
- def poll(cls, context):
- return (context.active_object is not None and
- context.mode=="EDIT_MESH")
- def draw(self, context):
- layout = self.layout
- ob = bpy.context.active_object
- me = ob.data
- bm = bmesh.from_edit_mesh(me)
- node_width_key = bm.verts.layers.float['node_width']
- bm.verts.ensure_lookup_table()
- bm.edges.ensure_lookup_table()
- if bm.select_mode != {'VERT'}:
- layout.label("Vertex select only", icon = 'INFO')
- return
- selected = [vert.index for vert in bm.verts if vert.select]
- if not selected:
- layout.label("Nothing selected", icon = 'INFO')
- else:
- for i in selected:
- # I would like to have UI element here so I can edit the vertex layers
- layout.column().prop(bm.verts[i][node_width_key], "", text = 'INFO')
- Traceback (most recent call last):
- File "E:paths-visualizerblenderview.py", line 94, in draw
- layout.column().prop(bm.verts[i][node_area_id], "", text = 'INFO')
- TypeError: UILayout.prop(): error with argument 1, "data" - Function.data expected a AnyType type, not int
- location: <unknown location>:-1
- import bpy
- import bmesh
- class MeshVertLayerList(bpy.types.UIList):
- def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
- if self.layout_type in {'DEFAULT', 'COMPACT'}:
- layout.label(item.name)
- layout.prop(item, "value", text="", emboss=False)
- elif self.layout_type in {'GRID'}:
- layout.alignment = 'CENTER'
- layout.label(text="")
- class MESH_OT_vert_layer_add(bpy.types.Operator):
- """Tooltip"""
- bl_label = "Add Vertex Layer"
- bl_idname = "mesh.vert_layer_add"
- @classmethod
- def poll(cls, context):
- return (context.object is not None and
- context.object.type == 'MESH' and
- context.object.mode == 'EDIT')
- def execute(self, context):
- bm = bmesh.from_edit_mesh(context.object.data)
- try:
- bm.verts.layers.float['test']
- except KeyError:
- bm.verts.layers.float.new('test')
- else:
- return {'CANCELLED'}
- return {'FINISHED'}
- class HelloWorldPanel(bpy.types.Panel):
- """Creates a Panel in the Object properties window"""
- bl_label = "Hello World Panel"
- bl_idname = "OBJECT_PT_hello"
- bl_space_type = 'PROPERTIES'
- bl_region_type = 'WINDOW'
- bl_context = "data"
- @classmethod
- def poll(cls, context):
- return (context.object is not None and
- context.object.type == 'MESH' and
- context.object.mode == 'EDIT')
- def draw(self, context):
- layout = self.layout
- wm = context.window_manager
- ob = context.object
- me = ob.data
- bm = bmesh.from_edit_mesh(me)
- try:
- l = bm.verts.layers.float['test']
- except KeyError:
- layout.label("No custom data layer 'test'.")
- layout.operator("mesh.vert_layer_add")
- return
- wm.mesh_vert_layer.verts.clear()
- for v in bm.verts:
- if v.select:
- item = wm.mesh_vert_layer.verts.add()
- item.name = "Vertex #%i" % v.index
- item.index = v.index
- item.value = v[l]
- layout.template_list("MeshVertLayerList", "", wm.mesh_vert_layer, "verts", wm.mesh_vert_layer, "index")
- def upd(self, context):
- try:
- me = context.object.data
- bm = bmesh.from_edit_mesh(me)
- bm.verts[self.index][bm.verts.layers.float['test']] = self.value
- bmesh.update_edit_mesh(me, tessface=False, destructive=False)
- except:
- pass
- class MeshVertLayerVert(bpy.types.PropertyGroup):
- value = bpy.props.FloatProperty(update=upd)
- index = bpy.props.IntProperty()
- class MeshVertLayer(bpy.types.PropertyGroup):
- index = bpy.props.IntProperty()
- verts = bpy.props.CollectionProperty(type=MeshVertLayerVert)
- def register():
- bpy.utils.register_module(__name__)
- bpy.types.WindowManager.mesh_vert_layer = bpy.props.PointerProperty(type=MeshVertLayer)
- def unregister():
- bpy.utils.unregister_module(__name__)
- del bpy.types.WindowManager.mesh_vert_layer
- if __name__ == "__main__":
- register()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement