Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
blender-addons
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blender
blender-addons
Commits
22358f56
Commit
22358f56
authored
15 years ago
by
Martin Buerbaum
Browse files
Options
Downloads
Patches
Plain Diff
* Nevermind.
parent
644e86a3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mesh_utils.py
+0
-126
0 additions, 126 deletions
mesh_utils.py
with
0 additions
and
126 deletions
mesh_utils.py
deleted
100644 → 0
+
0
−
126
View file @
644e86a3
# ##### 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 #####
import
bpy
# Stores the values of a list of properties in a
# property group (named like the operator) in the object.
# Could (in theory) be used for non-objects.
# Note: Replaces any existing property group with the same name!
def
store_recall_properties
(
ob
,
op
,
prop_list
):
if
ob
and
op
and
prop_list
:
# Store new recall properties.
prop_list
[
'
recall_op
'
]
=
op
.
bl_idname
ob
[
'
recall
'
]
=
prop_list
# Apply view rotation to objects if "Align To" for
# new objects was set to "VIEW" in the User Preference.
def
apply_object_align
(
context
,
ob
):
obj_align
=
bpy
.
context
.
user_preferences
.
edit
.
object_align
if
(
context
.
space_data
.
type
==
'
VIEW_3D
'
and
obj_align
==
'
VIEW
'
):
view3d
=
context
.
space_data
region
=
view3d
.
region_3d
viewMatrix
=
region
.
view_matrix
rot
=
viewMatrix
.
rotation_part
()
ob
.
rotation_euler
=
rot
.
invert
().
to_euler
()
# Create a new mesh (object) from verts/edges/faces.
# verts/edges/faces ... List of vertices and faces for the new mesh.
# name ... Name of the new mesh (& object).
# edit ... Replace existing mesh data.
# Note: Using "edit" will destroy/delete existing mesh data.
def
create_mesh_object
(
context
,
verts
,
edges
,
faces
,
name
,
edit
):
'''
Creates Meshes (& Objects) for the given lists of vertices and faces.
'''
scene
=
context
.
scene
obj_act
=
scene
.
objects
.
active
if
edit
and
not
obj_act
:
return
None
# Create new mesh
mesh
=
bpy
.
data
.
meshes
.
new
(
name
)
# Make a mesh from a list of verts/edges/faces.
mesh
.
from_pydata
(
verts
,
edges
,
faces
)
# Update mesh geometry after adding stuff.
mesh
.
update
()
# Deselect all objects.
bpy
.
ops
.
object
.
select_all
(
action
=
'
DESELECT
'
)
if
edit
:
# Replace geometry of existing object
ob_new
=
obj_act
if
obj_act
.
mode
==
'
OBJECT
'
:
# Remove existing vertices.
# @todo There is probably a better/faster way (delete(mesh)?).
bpy
.
ops
.
object
.
mode_set
(
mode
=
'
EDIT
'
)
bpy
.
ops
.
mesh
.
select_all
(
action
=
'
SELECT
'
)
bpy
.
ops
.
mesh
.
delete
(
type
=
'
VERT
'
)
bpy
.
ops
.
object
.
mode_set
(
mode
=
'
OBJECT
'
)
ob_new
.
data
=
mesh
ob_new
.
selected
=
True
else
:
# Create new object
ob_new
=
bpy
.
data
.
objects
.
new
(
name
,
mesh
)
# Link new object to the given scene and select it.
scene
.
objects
.
link
(
ob_new
)
ob_new
.
selected
=
True
# Place the object at the 3D cursor location.
ob_new
.
location
=
scene
.
cursor_location
apply_object_align
(
context
,
ob_new
)
if
obj_act
and
obj_act
.
mode
==
'
EDIT
'
:
if
not
edit
:
# We are in EditMode, switch to ObjectMode.
bpy
.
ops
.
object
.
mode_set
(
mode
=
'
OBJECT
'
)
# Select the active object as well.
obj_act
.
selected
=
True
# Apply location of new object.
scene
.
update
()
# Join new object into the active.
bpy
.
ops
.
object
.
join
()
# Switching back to EditMode.
bpy
.
ops
.
object
.
mode_set
(
mode
=
'
EDIT
'
)
ob_new
=
obj_act
else
:
# We are in ObjectMode.
# Make the new object the active one.
scene
.
objects
.
active
=
ob_new
return
ob_new
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment