- Campbell Barton updated his sel_same.py script;
- Added to Mesh scripts a call to Window.EditMode(0) to leave editmode before changing meshes.

BPython:
- small doc fixes / updates;
- added a call to undo_push_mesh inside Window.EditMode(0).

Mesh scripts could change the mesh but not the editmesh -- that would then overwrite the changed mesh.  Made all mesh scripts leave edit mode before changing a mesh.
This commit is contained in:
Willian Padovani Germano 2004-07-28 17:46:29 +00:00
parent d2da4f7160
commit 6b1eb45dda
9 changed files with 35 additions and 29 deletions

@ -378,7 +378,7 @@ def draw():
def event(evt, val): def event(evt, val):
if (evt== QKEY and not val): Exit() if ((evt== QKEY or evt== ESCKEY) and not val): Exit()
def bevent(evt): def bevent(evt):
global MODEMenu, NSIZE, ng, TMATList global MODEMenu, NSIZE, ng, TMATList
@ -430,4 +430,5 @@ def bevent(evt):
Blender.Redraw() Blender.Redraw()
Window.EditMode(0)
Register(draw, event, bevent) Register(draw, event, bevent)

@ -657,7 +657,7 @@ def draw():
msg = '' msg = ''
def event(evt, val): def event(evt, val):
if evt == Draw.QKEY and not val: if (evt == Draw.QKEY or evt == Draw.ESCKEY) and not val:
Draw.Exit() Draw.Exit()
if evt == Draw.CKEY and not val: if evt == Draw.CKEY and not val:
CutMesh() CutMesh()

@ -107,4 +107,5 @@ def rvk2rvk():
Draw.PupMenu('Error| You need to select two meshes.') Draw.PupMenu('Error| You need to select two meshes.')
Blender.Window.EditMode(0)
rvk2rvk() rvk2rvk()

@ -61,13 +61,12 @@ else:
mesh = object.getData() mesh = object.getData()
# We have a mesh so find AF. # We have a mesh so find AF.
for f in mesh.faces: af = mesh.getActiveFace()
if f.flag & NMesh.FaceFlags['ACTIVE']: if af: af = mesh.faces[af]
af = f
if af == None: if af == None:
error('no active face') error('no active face')
else: # Okay everything seems sane else: # Okay everything seems sane
#===================================== #=====================================
@ -152,7 +151,7 @@ else: # Okay everything seems sane
avcolIdx = 0 avcolIdx = 0
while avcolIdx < len(f1.col): while avcolIdx < len(f1.col):
match = 0 match = 0
vcolIdx = 0 vcolIdx = 0
while vcolIdx < len(f2.col): while vcolIdx < len(f2.col):
if colCompare(f1.col[avcolIdx], f2.col[vcolIdx], limit): if colCompare(f1.col[avcolIdx], f2.col[vcolIdx], limit):
@ -164,8 +163,6 @@ else: # Okay everything seems sane
avcolIdx += 1 avcolIdx += 1
return 1 return 1
# Makes sure face 2 has matching UVs within the limit. # Makes sure face 2 has matching UVs within the limit.
def faceUvCompare(f1, f2, limit): def faceUvCompare(f1, f2, limit):
for auv in f1.uv: for auv in f1.uv:
@ -193,7 +190,6 @@ else: # Okay everything seems sane
#====================# #====================#
#=============================# #=============================#
# Blender functions/shortcuts # # Blender functions/shortcuts #
#=============================# #=============================#
@ -212,7 +208,6 @@ else: # Okay everything seems sane
elif len(f.v) == 3: elif len(f.v) == 3:
return (measure(f.v[0].co, f.v[1].co), measure(f.v[1].co, f.v[2].co), measure(f.v[2].co, f.v[0].co) ) return (measure(f.v[0].co, f.v[1].co), measure(f.v[1].co, f.v[2].co), measure(f.v[2].co, f.v[0].co) )
def faceCent(f): def faceCent(f):
x = y = z = 0 x = y = z = 0
for v in f.v: for v in f.v:
@ -229,7 +224,9 @@ else: # Okay everything seems sane
#========================================# #========================================#
def fShouldCompare(f): def fShouldCompare(f):
# Only calculate for faces that will be affected. # Only calculate for faces that will be affected.
if faceOp == 1 and f.flag == 1: if len(f.v) < 3: # cant be an edge
return 0
elif faceOp == 1 and f.flag == 1:
return 0 return 0
elif faceOp == 0 and f.flag == 0: elif faceOp == 0 and f.flag == 0:
return 0 return 0
@ -247,10 +244,13 @@ else: # Okay everything seems sane
else: setFUnSel(f) else: setFUnSel(f)
def get_same_image(): def get_same_image():
for f in mesh.faces: if mesh.hasFaceUV() == 0:
if fShouldCompare(f): error('mesh has no uv image')
if af.image == f.image: setFSel(f) else:
else: setFUnSel(f) for f in mesh.faces:
if fShouldCompare(f):
if af.image == f.image: setFSel(f)
else: setFUnSel(f)
def get_same_mode(): def get_same_mode():
for f in mesh.faces: for f in mesh.faces:
@ -280,9 +280,7 @@ else: # Okay everything seems sane
if compare(afArea, faceArea(f), limit): setFSel(f) if compare(afArea, faceArea(f), limit): setFSel(f)
else: setFUnSel(f) else: setFUnSel(f)
def get_same_prop(limit): def get_same_prop(limit):
# Here we get the perimeter and use it for a proportional limit modifier. # Here we get the perimeter and use it for a proportional limit modifier.
afEdgeLens = getEdgeLengths(af) afEdgeLens = getEdgeLengths(af)
perim = 0 perim = 0
@ -326,10 +324,10 @@ else: # Okay everything seems sane
setFSel(f) setFSel(f)
else: else:
setFUnSel(f) setFUnSel(f)
#=====================# #=====================#
# End Sel same funcs # # End Sel same funcs #
#=====================# #=====================#
limit = 1 # some of these dont use the limit so it needs to be set, to somthing. limit = 1 # some of these dont use the limit so it needs to be set, to somthing.
# act on the menu item selected # act on the menu item selected
if method == 1: # Material if method == 1: # Material
@ -365,4 +363,4 @@ else: # Okay everything seems sane
# If limit is not set then dont bother # If limit is not set then dont bother
if limit != None: if limit != None:
mesh.update() mesh.update(0)

@ -1,7 +1,7 @@
#!BPY #!BPY
""" Registration info for Blender menus: <- these words are ignored """ Registration info for Blender menus: <- these words are ignored
Name: 'UnWeld' Name: 'UnWeld'
Blender: 232 Blender: 234
Group: 'Mesh' Group: 'Mesh'
Tip: 'Unweld all faces from a selected and common vertex. Made vertex bevelling.' Tip: 'Unweld all faces from a selected and common vertex. Made vertex bevelling.'
""" """
@ -57,6 +57,8 @@ from Blender import Noise
from Blender.Draw import * from Blender.Draw import *
from Blender.BGL import * from Blender.BGL import *
Blender.Window.EditMode(0)
Nr=Noise.random Nr=Noise.random
decal=0.03 decal=0.03
t=[0.0,0.0,0.0] t=[0.0,0.0,0.0]
@ -196,7 +198,7 @@ def D():
def E(evt,val): def E(evt,val):
global mouse_x,x,pl,orig,me,debut global mouse_x,x,pl,orig,me,debut
global mouse_y,y, MouseClickG,MouseClickD,MouseClickM global mouse_y,y, MouseClickG,MouseClickD,MouseClickM
if (evt== QKEY): Exit() if (evt== QKEY or evt== ESCKEY): Exit()
if (evt == MOUSEX): if (evt == MOUSEX):
mouse_x = val mouse_x = val

@ -42,6 +42,7 @@
#include <BIF_mywindow.h> #include <BIF_mywindow.h>
#include <BSE_headerbuttons.h> #include <BSE_headerbuttons.h>
#include <BSE_filesel.h> #include <BSE_filesel.h>
#include <BIF_editmesh.h> /* for undo_push_mesh() */
#include <BIF_screen.h> #include <BIF_screen.h>
#include <BIF_space.h> #include <BIF_space.h>
#include <BIF_drawtext.h> #include <BIF_drawtext.h>
@ -666,7 +667,6 @@ static PyObject *M_Window_SetViewQuat(PyObject *self, PyObject *args)
{ {
int ok = 0; int ok = 0;
float val[4]; float val[4];
float *vec;
if (!G.vd) { if (!G.vd) {
Py_INCREF (Py_None); Py_INCREF (Py_None);
@ -715,7 +715,6 @@ static PyObject *M_Window_SetViewOffset(PyObject *self, PyObject *args)
{ {
int ok = 0; int ok = 0;
float val[3]; float val[3];
float *vec;
if (!G.vd) { if (!G.vd) {
Py_INCREF (Py_None); Py_INCREF (Py_None);
@ -773,7 +772,10 @@ static PyObject *M_Window_EditMode(PyObject *self, PyObject *args)
if (status) { if (status) {
if (!G.obedit) enter_editmode(); if (!G.obedit) enter_editmode();
} }
else if (G.obedit) exit_editmode(1); else if (G.obedit) {
undo_push_mesh("From script"); /* use better solution after 2.34 */
exit_editmode(1);
}
} }
return Py_BuildValue("h", G.obedit?1:0); return Py_BuildValue("h", G.obedit?1:0);

@ -20,7 +20,7 @@ The Blender Python API Reference
- L{Draw} (*) - L{Draw} (*)
- L{Effect} - L{Effect}
- L{Image} (*) - L{Image} (*)
- L{Ipo} - L{Ipo} (*)
- L{Lamp} (*) - L{Lamp} (*)
- L{Lattice} - L{Lattice}
- L{Library} - L{Library}

@ -3,6 +3,8 @@
""" """
The Blender.Ipo submodule The Blender.Ipo submodule
B{New}: Ipo updates to both the program and bpython acess.
This module provides access to the Ipo Data in Blender. An Ipo is composed of This module provides access to the Ipo Data in Blender. An Ipo is composed of
several Ipocurves. several Ipocurves.
@ -91,8 +93,8 @@ class Ipo:
8. Key Ipo: Speed, 'Key 1' - 'Key 31'. 8. Key Ipo: Speed, 'Key 1' - 'Key 31'.
9. Action Ipo: LocX, LocY, LocZ, SizeX, SizeY, SizeZ, 9. Action Ipo: LocX, LocY, LocZ, SizeX, SizeY, SizeZ,
QuatX, QuatY, QuatZ, QuatW. QuatX, QuatY, QuatZ, QuatW.
10.Sequence Ipo: Fac. 10. Sequence Ipo: Fac.
11.Constraint Ipo: Inf. 11. Constraint Ipo: Inf.
@type curvename : string @type curvename : string
@rtype: IpoCurve object @rtype: IpoCurve object

@ -400,7 +400,7 @@ class NMesh:
@rtype: bool @rtype: bool
@return: True if successful or False if this NMesh wasn't linked to a real @return: True if successful or False if this NMesh wasn't linked to a real
Blender Mesh yet (or was, but the Mesh had no keys). Blender Mesh yet (or was, but the Mesh had no keys).
@warn: Currently the mesh keys from meshs that are grabbed with @warn: Currently the mesh keys from meshes that are grabbed with
NMesh.GetRaw() or .GetRawFromObject() are preserved, so if you want to NMesh.GetRaw() or .GetRawFromObject() are preserved, so if you want to
clear them or don't want them at all, remember to call this method. Of clear them or don't want them at all, remember to call this method. Of
course NMeshes created with NMesh.New() don't have mesh keys until you course NMeshes created with NMesh.New() don't have mesh keys until you