Guest

understanding problem vertex_groups method

drlolig

Posted: Tue Nov 27, 2012 1:28 pm
Joined: 27 Nov 2012
Posts: 1
hello,

i want to check the wall thickness of an object, i ve a good working script for blender 2.49,
i converted all the code to python blender 2.6, because blender 2.6 can run in the background.

 Code: def PaintVertices(me, vertIndList, paintAmt, group):       if paintAmt >= 0.1:  # Prevents float rounding errors and so forth from potentially troubling us; we refuse to paint anything under 10%.          for vertInd in vertIndList:             try:                currentState = me.getVertsFromGroup(group, 1, [vertInd])                if currentState and currentState[0][1]:                   curPaint = currentState[0][1]                else: curPaint = 0.0             except AttributeError: curPaint = 0.0             except RuntimeError: curPaint = 0.0                       if not curPaint:                me.assignVertsToGroup(group, [vertInd], paintAmt, AssignModes.ADD)                #print "Newly painting vert {0:d} to {1:.1%}.".format(vertInd, paintAmt)             elif paintAmt > curPaint:                me.assignVertsToGroup(group, [vertInd], paintAmt, AssignModes.REPLACE)                #print "Repainting vert {0:d} from {2:.1%} to {1:.1%}.".format(vertInd, paintAmt, curPaint)             else:                #print "Declining to paint vert {0:d} to {1:.1%}, since it's already at {2:.1%}.".format(vertInd, paintAmt, curPaint)                pass

i don t know to do some thing with me.getVertsFromGroup(group, 1, [vertInd])

my code, but don t work:

 Code: def PaintVertices(ob, vertIndList, paintAmt, group):                 if paintAmt >= 0.1:                        for vertInd in vertIndList:                                          try:                                         currentState = ob.vertex_groups[group]                                         if currentState.index == vertInd:                                                 if currentState and currentState[0][1]:                                                         curPaint = currentState[0][1]                                                 else: curPaint = 0.0                                 except AttributeError: curPaint = 0.0                                 except RuntimeError: curPaint = 0.0                                                                 if not curPaint:                                         ob.vertex_groups[group].add([vertInd], paintAmt, type='ADD')                                 elif paintAmt > curPaint:                                         ob.vertex_groups[group].add([vertInd], paintAmt, type='REPLACE' )                                 else:                                         pass

mfg drlolig

 Jump to: Select a forum Blender development forums----------------User Questions that really belong on blenderartists.orgNews & ChatCoding BlenderDocumentation & EducationFoundation and WebsitesTesting BuildsBlender Open ProjectsBlender Conference 2013Academic & Research Blender functionality forums----------------Interface & ToolsAnimationRenderingPythonInteractive 3d