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
9216515d
Commit
9216515d
authored
14 years ago
by
Florian Meyer
Browse files
Options
Downloads
Patches
Plain Diff
- same view_align fix as in gears
parent
34be323f
No related branches found
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
add_mesh_gears.py
+16
-18
16 additions, 18 deletions
add_mesh_gears.py
add_mesh_pipe_joint.py
+43
-19
43 additions, 19 deletions
add_mesh_pipe_joint.py
with
59 additions
and
37 deletions
add_mesh_gears.py
+
16
−
18
View file @
9216515d
...
@@ -67,6 +67,18 @@ import mathutils
...
@@ -67,6 +67,18 @@ import mathutils
from
math
import
*
from
math
import
*
from
bpy.props
import
*
from
bpy.props
import
*
# calculates the matrix for the new object
# depending on user pref
def
align_matrix
(
context
):
loc
=
mathutils
.
TranslationMatrix
(
context
.
scene
.
cursor_location
)
obj_align
=
context
.
user_preferences
.
edit
.
object_align
if
(
context
.
space_data
.
type
==
'
VIEW_3D
'
and
obj_align
==
'
VIEW
'
):
rot
=
context
.
space_data
.
region_3d
.
view_matrix
.
rotation_part
().
invert
().
resize4x4
()
else
:
rot
=
mathutils
.
Matrix
()
newMatrix
=
loc
*
rot
return
newMatrix
# Stores the values of a list of properties and the
# Stores the values of a list of properties and the
# operator id in a property group ('recall_op') inside the object.
# operator id in a property group ('recall_op') inside the object.
...
@@ -752,7 +764,7 @@ class AddGear(bpy.types.Operator):
...
@@ -752,7 +764,7 @@ class AddGear(bpy.types.Operator):
min
=
0.0
,
min
=
0.0
,
max
=
100.0
,
max
=
100.0
,
default
=
0.0
)
default
=
0.0
)
newMatrix
=
'
fromInvoke
'
newMatrix
=
mathutils
.
Matrix
()
def
draw
(
self
,
context
):
def
draw
(
self
,
context
):
props
=
self
.
properties
props
=
self
.
properties
...
@@ -818,14 +830,7 @@ class AddGear(bpy.types.Operator):
...
@@ -818,14 +830,7 @@ class AddGear(bpy.types.Operator):
return
{
'
FINISHED
'
}
return
{
'
FINISHED
'
}
def
invoke
(
self
,
context
,
event
):
def
invoke
(
self
,
context
,
event
):
loc
=
mathutils
.
TranslationMatrix
(
context
.
scene
.
cursor_location
)
self
.
newMatrix
=
align_matrix
(
context
)
obj_align
=
context
.
user_preferences
.
edit
.
object_align
if
(
context
.
space_data
.
type
==
'
VIEW_3D
'
and
obj_align
==
'
VIEW
'
):
rot
=
context
.
space_data
.
region_3d
.
view_matrix
.
rotation_part
().
invert
().
resize4x4
()
else
:
rot
=
mathutils
.
RotationMatrix
()
self
.
newMatrix
=
loc
*
rot
self
.
execute
(
context
)
self
.
execute
(
context
)
return
{
'
FINISHED
'
}
return
{
'
FINISHED
'
}
...
@@ -885,7 +890,7 @@ class AddWormGear(bpy.types.Operator):
...
@@ -885,7 +890,7 @@ class AddWormGear(bpy.types.Operator):
min
=
0.0
,
min
=
0.0
,
max
=
100.0
,
max
=
100.0
,
default
=
0.0
)
default
=
0.0
)
newMatrix
=
'
fromInvoke
'
newMatrix
=
mathutils
.
Matrix
()
def
draw
(
self
,
context
):
def
draw
(
self
,
context
):
props
=
self
.
properties
props
=
self
.
properties
...
@@ -947,14 +952,7 @@ class AddWormGear(bpy.types.Operator):
...
@@ -947,14 +952,7 @@ class AddWormGear(bpy.types.Operator):
return
{
'
FINISHED
'
}
return
{
'
FINISHED
'
}
def
invoke
(
self
,
context
,
event
):
def
invoke
(
self
,
context
,
event
):
loc
=
mathutils
.
TranslationMatrix
(
context
.
scene
.
cursor_location
)
self
.
newMatrix
=
align_matrix
(
context
)
obj_align
=
context
.
user_preferences
.
edit
.
object_align
if
(
context
.
space_data
.
type
==
'
VIEW_3D
'
and
obj_align
==
'
VIEW
'
):
rot
=
context
.
space_data
.
region_3d
.
view_matrix
.
rotation_part
().
invert
().
resize4x4
()
else
:
rot
=
mathutils
.
RotationMatrix
()
self
.
newMatrix
=
loc
*
rot
self
.
execute
(
context
)
self
.
execute
(
context
)
return
{
'
FINISHED
'
}
return
{
'
FINISHED
'
}
...
...
This diff is collapsed.
Click to expand it.
add_mesh_pipe_joint.py
+
43
−
19
View file @
9216515d
...
@@ -145,25 +145,26 @@ def store_recall_properties(ob, op, op_args):
...
@@ -145,25 +145,26 @@ def store_recall_properties(ob, op, op_args):
# Apply view rotation to objects if "Align To" for
# Apply view rotation to objects if "Align To" for
# new objects was set to "VIEW" in the User Preference.
# new objects was set to "VIEW" in the User Preference.
def
apply_object_align
(
context
,
ob
):
# Is now handled in the invoke functions
obj_align
=
bpy
.
context
.
user_preferences
.
edit
.
object_align
# calculates the matrix for the new object
# depending on user pref
def
align_matrix
(
context
):
loc
=
mathutils
.
TranslationMatrix
(
context
.
scene
.
cursor_location
)
obj_align
=
context
.
user_preferences
.
edit
.
object_align
if
(
context
.
space_data
.
type
==
'
VIEW_3D
'
if
(
context
.
space_data
.
type
==
'
VIEW_3D
'
and
obj_align
==
'
VIEW
'
):
and
obj_align
==
'
VIEW
'
):
view3d
=
context
.
space_data
rot
=
context
.
space_data
.
region_3d
.
view_matrix
.
rotation_part
().
invert
().
resize4x4
()
region
=
view3d
.
region_3d
else
:
viewMatrix
=
region
.
view_matrix
rot
=
mathutils
.
Matrix
()
rot
=
viewMatrix
.
rotation_part
()
newMatrix
=
loc
*
rot
ob
.
rotation_euler
=
rot
.
invert
().
to_euler
()
return
newMatrix
# Create a new mesh (object) from verts/edges/faces.
# Create a new mesh (object) from verts/edges/faces.
# verts/edges/faces ... List of vertices/edges/faces for the
# verts/edges/faces ... List of vertices/edges/faces for the
# new mesh (as used in from_pydata).
# new mesh (as used in from_pydata).
# name ... Name of the new mesh (& object).
# name ... Name of the new mesh (& object).
# edit ... Replace existing mesh data.
# edit ... Replace existing mesh data.
# Note: Using "edit" will destroy/delete existing mesh data.
# Note: Using "edit" will destroy/delete existing mesh data.
def
create_mesh_object
(
context
,
verts
,
edges
,
faces
,
name
,
edit
):
def
create_mesh_object
(
context
,
verts
,
edges
,
faces
,
name
,
edit
,
newMatrix
):
scene
=
context
.
scene
scene
=
context
.
scene
obj_act
=
scene
.
objects
.
active
obj_act
=
scene
.
objects
.
active
...
@@ -216,9 +217,7 @@ def create_mesh_object(context, verts, edges, faces, name, edit):
...
@@ -216,9 +217,7 @@ def create_mesh_object(context, verts, edges, faces, name, edit):
ob_new
.
selected
=
True
ob_new
.
selected
=
True
# Place the object at the 3D cursor location.
# Place the object at the 3D cursor location.
ob_new
.
location
=
scene
.
cursor_location
ob_new
.
matrix
=
newMatrix
apply_object_align
(
context
,
ob_new
)
if
obj_act
and
obj_act
.
mode
==
'
EDIT
'
:
if
obj_act
and
obj_act
.
mode
==
'
EDIT
'
:
if
not
edit
:
if
not
edit
:
...
@@ -359,6 +358,7 @@ class AddElbowJoint(bpy.types.Operator):
...
@@ -359,6 +358,7 @@ class AddElbowJoint(bpy.types.Operator):
min
=
0.01
,
min
=
0.01
,
max
=
100.0
,
max
=
100.0
,
unit
=
"
LENGTH
"
)
unit
=
"
LENGTH
"
)
newMatrix
=
mathutils
.
Matrix
()
def
execute
(
self
,
context
):
def
execute
(
self
,
context
):
edit
=
self
.
properties
.
edit
edit
=
self
.
properties
.
edit
...
@@ -419,7 +419,7 @@ class AddElbowJoint(bpy.types.Operator):
...
@@ -419,7 +419,7 @@ class AddElbowJoint(bpy.types.Operator):
faces
.
extend
(
createFaces
(
loop2
,
loop3
,
closed
=
True
))
faces
.
extend
(
createFaces
(
loop2
,
loop3
,
closed
=
True
))
obj
=
create_mesh_object
(
context
,
verts
,
[],
faces
,
obj
=
create_mesh_object
(
context
,
verts
,
[],
faces
,
"
Elbow Joint
"
,
edit
)
"
Elbow Joint
"
,
edit
,
self
.
newMatrix
)
# Store 'recall' properties in the object.
# Store 'recall' properties in the object.
recall_args_list
=
{
recall_args_list
=
{
...
@@ -433,6 +433,10 @@ class AddElbowJoint(bpy.types.Operator):
...
@@ -433,6 +433,10 @@ class AddElbowJoint(bpy.types.Operator):
return
{
'
FINISHED
'
}
return
{
'
FINISHED
'
}
def
invoke
(
self
,
context
,
event
):
self
.
newMatrix
=
align_matrix
(
context
)
self
.
execute
(
context
)
return
{
'
FINISHED
'
}
class
AddTeeJoint
(
bpy
.
types
.
Operator
):
class
AddTeeJoint
(
bpy
.
types
.
Operator
):
# Create the vertices and polygons for a simple tee (T) joint.
# Create the vertices and polygons for a simple tee (T) joint.
...
@@ -488,6 +492,7 @@ class AddTeeJoint(bpy.types.Operator):
...
@@ -488,6 +492,7 @@ class AddTeeJoint(bpy.types.Operator):
min
=
0.01
,
min
=
0.01
,
max
=
100.0
,
max
=
100.0
,
unit
=
"
LENGTH
"
)
unit
=
"
LENGTH
"
)
newMatrix
=
mathutils
.
Matrix
()
def
execute
(
self
,
context
):
def
execute
(
self
,
context
):
edit
=
self
.
properties
.
edit
edit
=
self
.
properties
.
edit
...
@@ -615,7 +620,7 @@ class AddTeeJoint(bpy.types.Operator):
...
@@ -615,7 +620,7 @@ class AddTeeJoint(bpy.types.Operator):
faces
.
extend
(
createFaces
(
loopJoint2
,
loopArm
,
closed
=
True
))
faces
.
extend
(
createFaces
(
loopJoint2
,
loopArm
,
closed
=
True
))
faces
.
extend
(
createFaces
(
loopJoint3
,
loopMainEnd
,
closed
=
True
))
faces
.
extend
(
createFaces
(
loopJoint3
,
loopMainEnd
,
closed
=
True
))
obj
=
create_mesh_object
(
context
,
verts
,
[],
faces
,
"
Tee Joint
"
,
edit
)
obj
=
create_mesh_object
(
context
,
verts
,
[],
faces
,
"
Tee Joint
"
,
edit
,
self
.
newMatrix
)
# Store 'recall' properties in the object.
# Store 'recall' properties in the object.
recall_args_list
=
{
recall_args_list
=
{
...
@@ -630,6 +635,10 @@ class AddTeeJoint(bpy.types.Operator):
...
@@ -630,6 +635,10 @@ class AddTeeJoint(bpy.types.Operator):
return
{
'
FINISHED
'
}
return
{
'
FINISHED
'
}
def
invoke
(
self
,
context
,
event
):
self
.
newMatrix
=
align_matrix
(
context
)
self
.
execute
(
context
)
return
{
'
FINISHED
'
}
class
AddWyeJoint
(
bpy
.
types
.
Operator
):
class
AddWyeJoint
(
bpy
.
types
.
Operator
):
'''
Add a Wye-Joint mesh
'''
'''
Add a Wye-Joint mesh
'''
...
@@ -689,6 +698,7 @@ class AddWyeJoint(bpy.types.Operator):
...
@@ -689,6 +698,7 @@ class AddWyeJoint(bpy.types.Operator):
min
=
0.01
,
min
=
0.01
,
max
=
100.0
,
max
=
100.0
,
unit
=
"
LENGTH
"
)
unit
=
"
LENGTH
"
)
newMatrix
=
mathutils
.
Matrix
()
def
execute
(
self
,
context
):
def
execute
(
self
,
context
):
edit
=
self
.
properties
.
edit
edit
=
self
.
properties
.
edit
...
@@ -827,7 +837,7 @@ class AddWyeJoint(bpy.types.Operator):
...
@@ -827,7 +837,7 @@ class AddWyeJoint(bpy.types.Operator):
faces
.
extend
(
createFaces
(
loopJoint2
,
loopArm1
,
closed
=
True
))
faces
.
extend
(
createFaces
(
loopJoint2
,
loopArm1
,
closed
=
True
))
faces
.
extend
(
createFaces
(
loopJoint3
,
loopArm2
,
closed
=
True
))
faces
.
extend
(
createFaces
(
loopJoint3
,
loopArm2
,
closed
=
True
))
obj
=
create_mesh_object
(
context
,
verts
,
[],
faces
,
"
Wye Joint
"
,
edit
)
obj
=
create_mesh_object
(
context
,
verts
,
[],
faces
,
"
Wye Joint
"
,
edit
,
self
.
newMatrix
)
# Store 'recall' properties in the object.
# Store 'recall' properties in the object.
recall_args_list
=
{
recall_args_list
=
{
...
@@ -843,6 +853,10 @@ class AddWyeJoint(bpy.types.Operator):
...
@@ -843,6 +853,10 @@ class AddWyeJoint(bpy.types.Operator):
return
{
'
FINISHED
'
}
return
{
'
FINISHED
'
}
def
invoke
(
self
,
context
,
event
):
self
.
newMatrix
=
align_matrix
(
context
)
self
.
execute
(
context
)
return
{
'
FINISHED
'
}
class
AddCrossJoint
(
bpy
.
types
.
Operator
):
class
AddCrossJoint
(
bpy
.
types
.
Operator
):
'''
Add a Cross-Joint mesh
'''
'''
Add a Cross-Joint mesh
'''
...
@@ -913,6 +927,7 @@ class AddCrossJoint(bpy.types.Operator):
...
@@ -913,6 +927,7 @@ class AddCrossJoint(bpy.types.Operator):
min
=
0.01
,
min
=
0.01
,
max
=
100.0
,
max
=
100.0
,
unit
=
"
LENGTH
"
)
unit
=
"
LENGTH
"
)
newMatrix
=
mathutils
.
Matrix
()
def
execute
(
self
,
context
):
def
execute
(
self
,
context
):
edit
=
self
.
properties
.
edit
edit
=
self
.
properties
.
edit
...
@@ -1102,7 +1117,7 @@ class AddCrossJoint(bpy.types.Operator):
...
@@ -1102,7 +1117,7 @@ class AddCrossJoint(bpy.types.Operator):
faces
.
extend
(
createFaces
(
loopJoint4
,
loopArm3
,
closed
=
True
))
faces
.
extend
(
createFaces
(
loopJoint4
,
loopArm3
,
closed
=
True
))
obj
=
create_mesh_object
(
context
,
verts
,
[],
faces
,
obj
=
create_mesh_object
(
context
,
verts
,
[],
faces
,
"
Cross Joint
"
,
edit
)
"
Cross Joint
"
,
edit
,
self
.
newMatrix
)
# Store 'recall' properties in the object.
# Store 'recall' properties in the object.
recall_args_list
=
{
recall_args_list
=
{
...
@@ -1120,6 +1135,10 @@ class AddCrossJoint(bpy.types.Operator):
...
@@ -1120,6 +1135,10 @@ class AddCrossJoint(bpy.types.Operator):
return
{
'
FINISHED
'
}
return
{
'
FINISHED
'
}
def
invoke
(
self
,
context
,
event
):
self
.
newMatrix
=
align_matrix
(
context
)
self
.
execute
(
context
)
return
{
'
FINISHED
'
}
class
AddNJoint
(
bpy
.
types
.
Operator
):
class
AddNJoint
(
bpy
.
types
.
Operator
):
'''
Add a N-Joint mesh
'''
'''
Add a N-Joint mesh
'''
...
@@ -1156,6 +1175,7 @@ class AddNJoint(bpy.types.Operator):
...
@@ -1156,6 +1175,7 @@ class AddNJoint(bpy.types.Operator):
min
=
0.01
,
min
=
0.01
,
max
=
100.0
,
max
=
100.0
,
unit
=
"
LENGTH
"
)
unit
=
"
LENGTH
"
)
newMatrix
=
mathutils
.
Matrix
()
def
execute
(
self
,
context
):
def
execute
(
self
,
context
):
edit
=
self
.
properties
.
edit
edit
=
self
.
properties
.
edit
...
@@ -1280,7 +1300,7 @@ class AddNJoint(bpy.types.Operator):
...
@@ -1280,7 +1300,7 @@ class AddNJoint(bpy.types.Operator):
createFaces
(
loopsJoints
[
loopIdx
],
createFaces
(
loopsJoints
[
loopIdx
],
loopsEndCircles
[
loopIdx
],
closed
=
True
))
loopsEndCircles
[
loopIdx
],
closed
=
True
))
obj
=
create_mesh_object
(
context
,
verts
,
[],
faces
,
"
N Joint
"
,
edit
)
obj
=
create_mesh_object
(
context
,
verts
,
[],
faces
,
"
N Joint
"
,
edit
,
self
.
newMatrix
)
# Store 'recall' properties in the object.
# Store 'recall' properties in the object.
recall_args_list
=
{
recall_args_list
=
{
...
@@ -1293,6 +1313,10 @@ class AddNJoint(bpy.types.Operator):
...
@@ -1293,6 +1313,10 @@ class AddNJoint(bpy.types.Operator):
return
{
'
FINISHED
'
}
return
{
'
FINISHED
'
}
def
invoke
(
self
,
context
,
event
):
self
.
newMatrix
=
align_matrix
(
context
)
self
.
execute
(
context
)
return
{
'
FINISHED
'
}
class
INFO_MT_mesh_pipe_joints_add
(
bpy
.
types
.
Menu
):
class
INFO_MT_mesh_pipe_joints_add
(
bpy
.
types
.
Menu
):
# Define the "Pipe Joints" menu
# Define the "Pipe Joints" menu
...
...
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