Newer
Older
point.co = spline_points[key][j][0]
point = spline.points[-1]
point.co = spline_points[key][i][0]
num=i
return {'FINISHED'}
class SeparateOutline(bpy.types.Operator):
bl_idname = "curvetools.sep_outline"
bl_label = "Separate Outline"
bl_options = {'REGISTER', 'UNDO'}
bl_description = "Makes 'Outline' separate mesh"
@classmethod
def poll(cls, context):
return util.Selected1OrMoreCurves()
def execute(self, context):
bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.curve.separate()
return {'FINISHED'}
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
class CurveBoolean(bpy.types.Operator):
bl_idname = "curvetools.bezier_curve_boolean"
bl_description = "Curve Boolean"
bl_label = "Curve Boolean"
bl_options = {'REGISTER', 'UNDO'}
operation: bpy.props.EnumProperty(name='Type', items=[
('UNION', 'Union', 'Boolean OR', 0),
('INTERSECTION', 'Intersection', 'Boolean AND', 1),
('DIFFERENCE AB', 'Difference AB', 'Active minus Selected', 2),
('DIFFERENCE BA', 'Difference BA', 'Selected minus Active', 3),
])
@classmethod
def poll(cls, context):
return util.Selected1OrMoreCurves()
def execute(self, context):
current_mode = bpy.context.object.mode
if bpy.ops.object.mode_set.poll():
bpy.ops.object.mode_set(mode = 'OBJECT')
selected_Curves = util.GetSelectedCurves()
len_selected_curves = len(selected_Curves)
bpy.ops.object.select_all(action='DESELECT')
if len_selected_curves < 2:
return {'FINISHED'}
spline1 = selected_Curves[0].data.splines[0]
matrix_world1 = selected_Curves[0].matrix_world
len_spline1 = len(spline1.bezier_points)
dataCurve = bpy.data.curves.new(self.operation, type='CURVE')
dataCurve.dimensions = '2D'
newSpline1 = dataCurve.splines.new(type='BEZIER')
newSpline1.use_cyclic_u = True
newSpline1.bezier_points.add(len_spline1 - 1)
for n in range(0, len_spline1):
newSpline1.bezier_points[n].co = matrix_world1 @ spline1.bezier_points[n].co
newSpline1.bezier_points[n].handle_left_type = spline1.bezier_points[n].handle_left_type
newSpline1.bezier_points[n].handle_left = matrix_world1 @ spline1.bezier_points[n].handle_left
newSpline1.bezier_points[n].handle_right_type = spline1.bezier_points[n].handle_right_type
newSpline1.bezier_points[n].handle_right = matrix_world1 @ spline1.bezier_points[n].handle_right
Curve = object_utils.object_data_add(context, dataCurve)
bpy.context.view_layer.objects.active = Curve
Curve.select_set(True)
Curve.location = (0.0, 0.0, 0.0)
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
for iCurve in range(0, len_selected_curves):
matrix_world = selected_Curves[iCurve].matrix_world
len_splines = len(selected_Curves[iCurve].data.splines)
first = 0
if iCurve == 0:
first = 1
for ispline in range(first, len_splines):
spline = selected_Curves[iCurve].data.splines[ispline]
len_spline = len(spline.bezier_points)
newSpline = dataCurve.splines.new(type='BEZIER')
newSpline.use_cyclic_u = True
newSpline.bezier_points.add(len_spline - 1)
for n in range(0, len_spline):
newSpline.bezier_points[n].co = matrix_world @ spline.bezier_points[n].co
newSpline.bezier_points[n].handle_left_type = spline.bezier_points[n].handle_left_type
newSpline.bezier_points[n].handle_left = matrix_world @ spline.bezier_points[n].handle_left
newSpline.bezier_points[n].handle_right_type = spline.bezier_points[n].handle_right_type
newSpline.bezier_points[n].handle_right = matrix_world @ spline.bezier_points[n].handle_right
bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.curve.select_all(action='SELECT')
splines = internal.getSelectedSplines(True, True)
if len(splines) < 2:
continue
splineA = splines[0]
splineB = splines[1]
operation = self.operation
dataCurve.splines.active = newSpline1
if self.operation == 'DIFFERENCE AB':
operation = 'DIFFERENCE'
if self.operation == 'DIFFERENCE BA':
dataCurve.splines.active = newSpline
operation = 'DIFFERENCE'
splineA = splines[1]
splineB = splines[0]
if not internal.bezierBooleanGeometry(splineA, splineB, operation):
self.report({'WARNING'}, 'Invalid selection.')
return {'CANCELLED'}
bpy.ops.object.mode_set (mode = current_mode)
return {'FINISHED'}
def register():
for cls in classes:
bpy.utils.register_class(operators)
def unregister():
for cls in classes:
bpy.utils.unregister_class(operators)
if __name__ == "__main__":
register()
operators = [
OperatorCurveInfo,
OperatorCurveLength,
OperatorSplinesInfo,
OperatorSegmentsInfo,
OperatorOriginToSpline0Start,
OperatorIntersectCurves,
OperatorLoftCurves,
OperatorSweepCurves,
OperatorBirail,
OperatorSplinesSetResolution,
OperatorSplinesRemoveZeroSegment,
OperatorSplinesRemoveShort,
OperatorSplinesJoinNeighbouring,
ConvertSelectedFacesToBezier,
ConvertBezierToSurface,
BezierPointsFillet,
BezierDivide,
CurveScaleReset,
SeparateOutline,
CurveBoolean,