Newer
Older
# ##### 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; version 2
# of the License.
#
# 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 #####
"description": "Modeling and retopology tool.",
"wiki_url": "http://www.bsurfaces.info",
"tracker_url": "http://projects.blender.org/tracker/index.php?"\
"func=detail&aid=26642",
import mathutils
import operator
class VIEW3D_PT_tools_SURFSK_mesh(bpy.types.Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
bl_context = "mesh_edit"
def draw(self, context):
layout = self.layout
scn = context.scene
col = layout.column(align=True)
row = layout.row()
row.separator()
col.operator("gpencil.surfsk_add_surface", text="Add Surface")
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
col.operator("gpencil.surfsk_edit_strokes", text="Edit Strokes")
col.prop(scn, "SURFSK_cyclic_cross")
col.prop(scn, "SURFSK_cyclic_follow")
col.prop(scn, "SURFSK_loops_on_strokes")
col.prop(scn, "SURFSK_automatic_join")
col.prop(scn, "SURFSK_keep_strokes")
class VIEW3D_PT_tools_SURFSK_curve(bpy.types.Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
bl_context = "curve_edit"
bl_label = "Bsurfaces"
@classmethod
def poll(cls, context):
return context.active_object
def draw(self, context):
layout = self.layout
scn = context.scene
ob = context.object
col = layout.column(align=True)
row = layout.row()
row.separator()
col.operator("curve.surfsk_first_points", text="Set First Points")
col.operator("curve.switch_direction", text="Switch Direction")
col.operator("curve.surfsk_reorder_splines", text="Reorder Splines")
#### Returns the type of strokes used.
def get_strokes_type(main_object):
strokes_type = ""
strokes_num = 0
# Check if they are grease pencil
try:
#### Get the active grease pencil layer.
strokes_num = len(main_object.grease_pencil.layers.active.active_frame.strokes)
if strokes_num > 0:
strokes_type = "GP_STROKES"
except:
pass
# Check if they are curves, if there aren't grease pencil strokes.
if strokes_type == "":
if len(bpy.context.selected_objects) == 2:
for ob in bpy.context.selected_objects:
if ob != bpy.context.scene.objects.active and ob.type == "CURVE":
strokes_type = "EXTERNAL_CURVE"
strokes_num = len(ob.data.splines)
# Check if there is any non-bezier spline.
for i in range(len(ob.data.splines)):
if ob.data.splines[i].type != "BEZIER":
strokes_type = "CURVE_WITH_NON_BEZIER_SPLINES"
break
elif ob != bpy.context.scene.objects.active and ob.type != "CURVE":
strokes_type = "EXTERNAL_NO_CURVE"
elif len(bpy.context.selected_objects) > 2:
strokes_type = "MORE_THAN_ONE_EXTERNAL"
# Check if there is a single stroke without any selection in the object.
if strokes_num == 1 and main_object.data.total_vert_sel == 0:
if strokes_type == "EXTERNAL_CURVE":
strokes_type = "SINGLE_CURVE_STROKE_NO_SELECTION"
elif strokes_type == "GP_STROKES":
strokes_type = "SINGLE_GP_STROKE_NO_SELECTION"
if strokes_num == 0 and main_object.data.total_vert_sel > 0:
strokes_type = "SELECTION_ALONE"
if strokes_type == "":
strokes_type = "NO_STROKES"
return strokes_type
# Surface generator operator.
class GPENCIL_OT_SURFSK_add_surface(bpy.types.Operator):
bl_idname = "gpencil.surfsk_add_surface"
bl_description = "Generates surfaces from grease pencil strokes, bezier curves or loose edges."
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
edges_U = bpy.props.IntProperty(name = "Cross",
description = "Number of face-loops crossing the strokes.",
default = 1,
min = 1,
max = 200)
edges_V = bpy.props.IntProperty(name = "Follow",
description = "Number of face-loops following the strokes.",
default = 1,
min = 1,
max = 200)
cyclic_cross = bpy.props.BoolProperty(name = "Cyclic Cross",
description = "Make cyclic the face-loops crossing the strokes.",
default = False)
cyclic_follow = bpy.props.BoolProperty(name = "Cyclic Follow",
description = "Make cyclic the face-loops following the strokes.",
default = False)
loops_on_strokes = bpy.props.BoolProperty(name = "Loops on strokes",
description = "Make the loops match the paths of the strokes.",
default = False)
automatic_join = bpy.props.BoolProperty(name = "Automatic join",
description = "Join automatically vertices of either surfaces generated by crosshatching, or from the borders of closed shapes.",
default = False)
join_stretch_factor = bpy.props.FloatProperty(name = "Stretch",
description = "Amount of stretching or shrinking allowed for edges when joining vertices automatically.",
default = 1,
min = 0,
max = 3,
subtype = 'FACTOR')
Loading
Loading full blame...