api change?

anybody know what the new commands is for this?

File “C:\Users\RJ\0blend25\0alpha738\Release\parabohyper1.blend/Text.001”, lin
e 171, in register
AttributeError: ‘RNA_Types’ object has no attribute ‘VIEW3D_PT_3dview_display’
location:<unknown location>:-1
location:<unknown location>:-1

Thanks

Did a search and see some diffs coming from the mailing list.

SVN commit: /data/svn/bf-blender [28482] trunk/blender -class VIEW3D_PT_3dview_display(bpy.types.Panel):
+class VIEW3D_PT_view3d_display(bpy.types.Panel):
There are others. It would seems that “3dview” has been changed to “view3d” in all of it’s occurrences.

CHANGEd IT FOR

bpy.types.VIEW3D_PT_view3d_display.prepend(menu_func)

bpy.types.VIEW3D_PT_3dview_display.prepend(menu_func)

def unregister():
bpy.types.unregister(IndexVisualiser)
bpy.types.VIEW3D_PT_view3d_display.remove(menu_func)

and don’t get the error any more for that one!

this is part of the indices visualiser old script from last year

still canot get the indices in viewport

now i also ahd to change the name Mathtuil
but i guess there is another error now for a mathutil call
online 67
here

       if v.selected or not bpy.context.scene.display_sel_only:

67 locs.append([1.0, 1.0, 1.0, v.index, mathutils.Vector(v.co[:][0], v.co[:][1], v.co[:][2], 1.0)])

may be there is another change to the mathutil module that affect this !
but which one ?

Thanks

I dunno which build of Blender you’re using, but the most recent ones require that you call mathutils.Vector using a tuple that contains all of the vector’s components. Something like this:

components=(1,2,3,4)
vector=mathutils.Vector(components)

Yes, the docs appear to bear this out. mathutils…

http://www.blender.org/documentation/250PythonDoc/mathutils.html?highlight=mathutil#module-mathutilsclass mathutils.Vector

got this page but even this page seems not to be updated to last API version!

i modified most of the mathutil lines
bit now get an error on this draw line for blf

# draw
<b>blf.size(13, 72)</b>

seems it needs 3 arguments isntead of 2

any idea what it could be ?

by the way is there a wiki page giving all the API changes as a summary?

cause it’s difficult to follow all changes over time for this API!

hope it can work this time

Thanks

blf.size(fontid, size, dpi)Set the size and dpi for drawing text.
Parameters:

  • fontid (int) – The id of the typeface as returned by blf.load(), for default font use 0.
  • size (int) – Point size of the font.
  • dpi (int) – dots per inch value to use for drawing.

i found an example in pie menu for this blf

i change it and added 0 at the first var like this

# draw

blf.size(0,13, 72)

for i in range(0,len(texts),7):
    bgl.glColor3f(texts[i], texts[i+1], texts[i+2])
    blf.position(texts[i+4], texts[i+5], texts[i+6])
    blf.draw(str(int(texts[i+3])))

but when i execute the script i now get an error on the blf.position needs 4 arg instead of 3

strange i cannot find this in the pie menu example ?

so what could cause this error and how to correct this ?

Thanks

almost working now

shows only one face ?
may be can have a look and see why only one face ?
i forgot tochange mathutil in 2 lines around 70 to 75 sorry for that !

you should also uncomment these 2 lines as shown in script

uncomment 2 lines below, to enable live updating of the selection

bpy.ops.object.editmode_toggle()
bpy.ops.object.editmode_toggle

with theses 2 lines seems to work better with all faces edges andn vertices !

here is the code


 
# ##### BEGIN GPL LICENSE BLOCK #####
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; either version 2
#  of the License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software Foundation,
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
 
__script__ = "Index Visualiser"
__author__ = ["Bartius Crouch"]
__version__ = "2.1 2010/03/11"
__blender__ = "2.52"
__category__ = ["Misc"]
__url__ = ["Homepage, http://sites.google.com/site/bartiuscrouch/",
"Support thread, http://blenderartists.org/forum/showthread.php?t=180683"]
__email__ = ["Crouch, bartius*crouch:gmail*com"]
__bpydoc__ = """\
Display the indices of vertices, edges and faces in the 3d-view.
 
How to use:
- Select a mesh and go into editmode
- Display the properties panel (N-key)
- Go to the Display tab (4th tab), it helps to fold the tabs above it
- Press the 'Visualise indices button'
 
"""
 
import bgl, blf, bpy, mathutils
 
# calculate locations and store them as ID property in the mesh
def calc_callback(self, context):
    # polling
    if context.mode != 'EDIT_MESH':
        return
 
    # get screen information
    mid_x = context.region.width/2.0
    mid_y = context.region.height/2.0
    width = context.region.width
    height = context.region.height
 
    # get matrices
    view_mat = context.space_data.region_3d.perspective_matrix
    ob_mat = context.active_object.matrix
    total_mat = view_mat*ob_mat
 
    # calculate location info
    texts = []
    locs = []
    me = context.active_object.data
    # uncomment 2 lines below, to enable live updating of the selection
    #bpy.ops.object.editmode_toggle()
    #bpy.ops.object.editmode_toggle()
    if bpy.context.scene.display_vert_index:
        for v in me.verts:
            if v.selected or not bpy.context.scene.display_sel_only:
#                locs.append([1.0, 1.0, 1.0, v.index, mathutils.Vector(v.co[:][0], v.co[:][1], v.co[:][2], 1.0)])
                vr1=(v.co[:][0], v.co[:][1], v.co[:][2], 1.0)
#                locs.append([1.0, 1.0, 1.0, v.index, mathutils.Vector((v.co[:][0], v.co[:][1], v.co[:][2]), 1.0)])
                locs.append([1.0, 1.0, 1.0, v.index, mathutils.Vector(vr1)])
    if bpy.context.scene.display_edge_index:
        for ed in me.edges:
            if ed.selected or not bpy.context.scene.display_sel_only:
                v1, v2 = ed.verts
#                v1 = mathutils.Vector(me.verts[v1].co[:])
                v1 = mathutils.Vector((me.verts[v1].co[:]))
#                v2 = mathutils.Vector(me.verts[v2].co[:])
                v2 = mathutils.Vector((me.verts[v2].co[:]))
                loc = v1 + ((v2-v1)/2.0)
#                locs.append([1.0, 1.0, 0.0, ed.index, mathutils.Vector(loc[0],loc[1],loc[2],1.0)])
#                locs.append(([1.0, 1.0, 0.0, ed.index, mathutils.Vector(loc[0],loc[1],loc[2],1.0)]))
                vl1=(loc[0],loc[1],loc[2],1.0)
                locs.append([1.0, 1.0, 0.0, ed.index, mathutils.Vector(vl1)])
 
 
    if bpy.context.scene.display_face_index:
        for f in me.faces:
            if f.selected or not bpy.context.scene.display_sel_only:
#                locs.append([1.0, 0.0, 0.5, f.index, mathutils.Vector(f.center[0], f.center[1], f.center[2], 1.0)])
#                locs.append([1.0, 0.0, 0.5, f.index, mathutils.Vector(f.center[0], f.center[1], f.center[2], 1.0)])
                vj1=(f.center[0], f.center[1], f.center[2], 1.0)
                locs.append([1.0, 0.0, 0.5, f.index, mathutils.Vector(vj1)])
    for loc in locs:
        vec = total_mat*loc[4] # order is important
#        vec = mathutils.Vector(vec[0]/vec[3],vec[1]/vec[3],vec[2]/vec[3]) # dehomogenise
#        vec = mathutils.Vector((vec[0]/vec[3],vec[1]/vec[3],vec[2]/vec[3])) # dehomogenise
        vh1=(vec[0]/vec[3],vec[1]/vec[3],vec[2]/vec[3])
        vec = mathutils.Vector(vh1) # dehomogenise
        x = int(mid_x + vec[0]*width/2.0)
        y = int(mid_y + vec[1]*height/2.0)
        texts+=[loc[0], loc[1], loc[2], loc[3], x, y, 0]
 
    # store as ID property in mesh
    context.active_object.data['IndexVisualiser'] = texts
 
# draw in 3d-view
def draw_callback(self, context):
    # polling
    if context.mode != 'EDIT_MESH':
        return
    # retrieving ID property data
    try:
        texts = context.active_object.data['IndexVisualiser']
    except:
        return
    if not texts:
        return
 
    # draw
    blf.size(0,13, 72)
    for i in range(0,len(texts),7):
        bgl.glColor3f(texts[i], texts[i+1], texts[i+2])
        blf.position(0,texts[i+4], texts[i+5], texts[i+6])
        blf.draw(0,str(int(texts[i+3])))
 
# operator
class IndexVisualiser(bpy.types.Operator):
    bl_idname = "view3d.index_visualiser"
    bl_label = "Index Visualiser"
    bl_description = "Toggle the visualisation of indices"
 
    def poll(self, context):
        return context.mode=='EDIT_MESH'
 
    def modal(self, context, event):
        context.area.tag_redraw()
 
        # removal of callbacks when operator is called again
        if context.scene.display_indices == -1:
            context.region.callback_remove(self.handle1)
            context.region.callback_remove(self.handle2)
            context.scene.display_indices = 0
            return {'CANCELLED'}
 
        return {'PASS_THROUGH'}
 
    def invoke(self, context, event):
        if context.area.type == 'VIEW_3D':
            if context.scene.display_indices == 0:
                # operator is called for the first time, start everything
                context.scene.display_indices = 1
                context.manager.add_modal_handler(self)
                self.handle1 = context.region.callback_add(calc_callback, (self, context), 'POST_VIEW')
                self.handle2 = context.region.callback_add(draw_callback, (self, context), 'POST_PIXEL')
                return {'RUNNING_MODAL'}
            else:
                # operator is called again, stop displaying
                context.scene.display_indices = -1
                return {'RUNNING_MODAL'}
        else:
            self.report({'WARNING'}, "View3D not found, can't run operator")
            return {'CANCELLED'}
 
# defining the panel
def menu_func(self, context):
    col = self.layout.column(align=True)
    col.operator(IndexVisualiser.bl_idname, text="Visualise indices")
    row = col.row(align=True)
    row.active = (context.mode=='EDIT_MESH' and context.scene.display_indices==1)
    row.prop(context.scene, 'display_vert_index', toggle=True)
    row.prop(context.scene, 'display_edge_index', toggle=True)
    row.prop(context.scene, 'display_face_index', toggle=True)
    row = col.row(align=True)
    row.active = (context.mode=='EDIT_MESH' and context.scene.display_indices==1)
    row.prop(context.scene, 'display_sel_only')
    self.layout.separator()
 
def register():
 
    bpy.types.Scene.IntProperty(attr="display_indices", default=0)
    bpy.context.scene.display_indices = 0
    bpy.types.Scene.BoolProperty(attr="display_sel_only", name="Selected only", description="Only display indices of selected vertices/edges/faces", default=True)
    bpy.types.Scene.BoolProperty(attr="display_vert_index", name="Vertices", description="Display vertex indices", default=True)
    bpy.types.Scene.BoolProperty(attr="display_edge_index", name="Edges", description="Display edge indices")
    bpy.types.Scene.BoolProperty(attr="display_face_index", name="Faces", description="Display face indices")
 
    bpy.types.register(IndexVisualiser)
    bpy.types.VIEW3D_PT_view3d_display.prepend(menu_func)
#    bpy.types.VIEW3D_PT_3dview_display.prepend(menu_func)    
 
def unregister():
    bpy.types.unregister(IndexVisualiser)
    bpy.types.VIEW3D_PT_view3d_display.remove(menu_func)
#     bpy.types.VIEW3D_PT_3dview_display.remove(menu_func)  
 
#VIEW3D_PT_view3d_display(bpy.types.Panel)
 
 
if __name__ == "__main__":
    register()
 
 
 

have fun with index
sorry this was done in version 738 hope it’s also good in later version!

if you have later vesion can you test and tell me if it’s ok
i’ll load it back in other thread too!

salutations

latest version working

but if you look into the console report you can see it’s looping constinoulsy ?

is this normal ?



# ##### BEGIN GPL LICENSE BLOCK #####
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; either version 2
#  of the License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software Foundation,
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####

__script__ = "Index Visualiser"
__author__ = ["Bartius Crouch"]
__version__ = "2.1 2010/03/11"
__blender__ = "2.52"
__category__ = ["Misc"]
__url__ = ["Homepage, http://sites.google.com/site/bartiuscrouch/",
"Support thread, http://blenderartists.org/forum/showthread.php?t=180683"]
__email__ = ["Crouch, bartius*crouch:gmail*com"]
__bpydoc__ = """\
Display the indices of vertices, edges and faces in the 3d-view.

How to use:
- Select a mesh and go into editmode
- Display the properties panel (N-key)
- Go to the Display tab (4th tab), it helps to fold the tabs above it
- Press the 'Visualise indices button'

"""

import bgl, blf, bpy, mathutils

# calculate locations and store them as ID property in the mesh
def calc_callback(self, context):
    # polling
    if context.mode != 'EDIT_MESH':
        return
    
    # get screen information
    mid_x = context.region.width/2.0
    mid_y = context.region.height/2.0
    width = context.region.width
    height = context.region.height
    
    # get matrices
    view_mat = context.space_data.region_3d.perspective_matrix
    ob_mat = context.active_object.matrix
    total_mat = view_mat*ob_mat
    
    # calculate location info
    texts = []
    locs = []
    me = context.active_object.data
    # uncomment 2 lines below, to enable live updating of the selection
    bpy.ops.object.editmode_toggle()
    bpy.ops.object.editmode_toggle()
    if bpy.context.scene.display_vert_index:
        for v in me.verts:
            if v.selected or not bpy.context.scene.display_sel_only:
                vr1=(v.co[:][0], v.co[:][1], v.co[:][2], 1.0)
                locs.append([1.0, 1.0, 1.0, v.index, mathutils.Vector(vr1)])
    if bpy.context.scene.display_edge_index:
        for ed in me.edges:
            if ed.selected or not bpy.context.scene.display_sel_only:
                v1, v2 = ed.verts
                ff1=(me.verts[v1].co[:])
#                v1 = mathutils.Vector((me.verts[v1].co[:]))
                v1 = mathutils.Vector(ff1)
                ff2=(me.verts[v2].co[:])
#                v2 = mathutils.Vector((me.verts[v2].co[:]))
                v2 = mathutils.Vector(ff2)
                                
                loc = v1 + ((v2-v1)/2.0)
                vl1=(loc[0],loc[1],loc[2],1.0)
                locs.append([1.0, 1.0, 0.0, ed.index, mathutils.Vector(vl1)])
                
                
    if bpy.context.scene.display_face_index:
        for f in me.faces:
            if f.selected or not bpy.context.scene.display_sel_only:
                vj1=(f.center[0], f.center[1], f.center[2], 1.0)
                locs.append([1.0, 0.0, 0.5, f.index, mathutils.Vector(vj1)])
    for loc in locs:
        vec = total_mat*loc[4] # order is important
        vh1=(vec[0]/vec[3],vec[1]/vec[3],vec[2]/vec[3])
        vec = mathutils.Vector(vh1) # dehomogenise
        x = int(mid_x + vec[0]*width/2.0)
        y = int(mid_y + vec[1]*height/2.0)
        texts+=[loc[0], loc[1], loc[2], loc[3], x, y, 0]

    # store as ID property in mesh
    context.active_object.data['IndexVisualiser'] = texts

# draw in 3d-view
def draw_callback(self, context):
    # polling
    if context.mode != 'EDIT_MESH':
        return
    # retrieving ID property data
    try:
        texts = context.active_object.data['IndexVisualiser']
    except:
        return
    if not texts:
        return
    
    # draw
    blf.size(0,13, 72)
    for i in range(0,len(texts),7):
        bgl.glColor3f(texts[i], texts[i+1], texts[i+2])
        blf.position(0,texts[i+4], texts[i+5], texts[i+6])
        blf.draw(0,str(int(texts[i+3])))

# operator
class IndexVisualiser(bpy.types.Operator):
    bl_idname = "view3d.index_visualiser"
    bl_label = "Index Visualiser"
    bl_description = "Toggle the visualisation of indices"
    
    def poll(self, context):
        return context.mode=='EDIT_MESH'
    
    def modal(self, context, event):
        context.area.tag_redraw()

        # removal of callbacks when operator is called again
        if context.scene.display_indices == -1:
            context.region.callback_remove(self.handle1)
            context.region.callback_remove(self.handle2)
            context.scene.display_indices = 0
            return {'CANCELLED'}
        
        return {'PASS_THROUGH'}
    
    def invoke(self, context, event):
        if context.area.type == 'VIEW_3D':
            if context.scene.display_indices == 0:
                # operator is called for the first time, start everything
                context.scene.display_indices = 1
                context.manager.add_modal_handler(self)
                self.handle1 = context.region.callback_add(calc_callback, (self, context), 'POST_VIEW')
                self.handle2 = context.region.callback_add(draw_callback, (self, context), 'POST_PIXEL')
                return {'RUNNING_MODAL'}
            else:
                # operator is called again, stop displaying
                context.scene.display_indices = -1
                return {'RUNNING_MODAL'}
        else:
            self.report({'WARNING'}, "View3D not found, can't run operator")
            return {'CANCELLED'}

# defining the panel
def menu_func(self, context):
    col = self.layout.column(align=True)
    col.operator(IndexVisualiser.bl_idname, text="Visualise indices")
    row = col.row(align=True)
    row.active = (context.mode=='EDIT_MESH' and context.scene.display_indices==1)
    row.prop(context.scene, 'display_vert_index', toggle=True)
    row.prop(context.scene, 'display_edge_index', toggle=True)
    row.prop(context.scene, 'display_face_index', toggle=True)
    row = col.row(align=True)
    row.active = (context.mode=='EDIT_MESH' and context.scene.display_indices==1)
    row.prop(context.scene, 'display_sel_only')
    self.layout.separator()

def register():

    bpy.types.Scene.IntProperty(attr="display_indices", default=0)
    bpy.context.scene.display_indices = 0
    bpy.types.Scene.BoolProperty(attr="display_sel_only", name="Selected only", description="Only display indices of selected vertices/edges/faces", default=True)
    bpy.types.Scene.BoolProperty(attr="display_vert_index", name="Vertices", description="Display vertex indices", default=True)
    bpy.types.Scene.BoolProperty(attr="display_edge_index", name="Edges", description="Display edge indices")
    bpy.types.Scene.BoolProperty(attr="display_face_index", name="Faces", description="Display face indices")
    
    bpy.types.register(IndexVisualiser)
    bpy.types.VIEW3D_PT_view3d_display.prepend(menu_func)
#    bpy.types.VIEW3D_PT_3dview_display.prepend(menu_func)    

def unregister():
    bpy.types.unregister(IndexVisualiser)
    bpy.types.VIEW3D_PT_view3d_display.remove(menu_func)
#     bpy.types.VIEW3D_PT_3dview_display.remove(menu_func)  
 
#VIEW3D_PT_view3d_display(bpy.types.Panel)
    

if __name__ == "__main__":
    register()




still don’t know before this sunday when i download the lates blender version if it will work there

Thanks

hint, you can replace
mathutils.Vector((me.verts[v2].co[:]))

with…
me.verts[v2].co.copy()

RickyBlender: please check the latest version of the script here. It’s version 2.5 (clear your browser cache, if you get an older one) and works correctly with current SVN.

sorry but can you upload the file cause i cannot access the given site !

now i just got 30173 vesion this morning

and seems that there are more problems in this latest vesion
like when rotating the cube the indices are not following it !

Thanks

RickyBlender,
there is indeed a new bug.

bug in the script or in the 30173 blender version?

Thanks

bug in the script.
you need to toggle object mode back to edit mode to update the index numbers.

i still don’t have the latest script from Crouch i cannot access the page
can you upload that version

on the version i modified when i rotate a cube the indices are not following it in 30173

so that might be another bug in the old script
and may be with the latest version this wont happen !

Thanks

RickyBlender.
I am using the latest version of the script. with a 5 min old version of Blender.
I’m also sure that Crouch will fix it as soon as he can.

ok i’ll wait till latest from Crouch!

meanwhile i keep working at my script for triangles
and having problems with the pie menu to execute class outside sub menu

if you have time to help on this one i might be able to relesase that script sooner!

see the pie menu thread

Thanks for any help