1 # SPDX-FileCopyrightText: 2019-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
6 from mathutils
import *
9 def GetSelectedCurves():
12 for obj
in bpy
.context
.selected_objects
:
14 if obj
.type == "CURVE": rvList
.append(obj
)
21 def GetSelectedMeshes():
24 for obj
in bpy
.context
.selected_objects
:
26 if obj
.type == "MESH": rvList
.append(obj
)
35 if len(GetSelectedCurves()) == 1:
36 return (bpy
.context
.active_object
.type == "CURVE")
45 if len(GetSelectedMeshes()) == 1:
46 return (bpy
.context
.active_object
.type == "MESH")
53 def Selected1SingleSplineCurve():
56 return (len(bpy
.context
.active_object
.data
.splines
) == 1)
63 def Selected2Curves():
65 if len(GetSelectedCurves()) == 2:
66 return (bpy
.context
.active_object
.type == "CURVE")
73 def Selected3Curves():
75 if len(GetSelectedCurves()) == 3:
76 return (bpy
.context
.active_object
.type == "CURVE")
83 def Selected1OrMoreCurves():
85 if len(GetSelectedCurves()) > 0:
86 return (bpy
.context
.active_object
.type == "CURVE")
92 def Selected2OrMoreCurves():
94 if len(GetSelectedCurves()) > 1:
95 return (bpy
.context
.active_object
.type == "CURVE")
102 def Selected1OrMoreMesh():
104 if len(GetSelectedMeshes()) > 0:
105 return (bpy
.context
.active_object
.type == "MESH")
112 def GetToolsRegion():
113 for area
in bpy
.context
.screen
.areas
:
114 if area
.type == 'VIEW_3D':
115 for region
in area
.regions
:
116 if region
.type == 'TOOLS': return region
121 def GetFirstRegionView3D():
122 for area
in bpy
.context
.screen
.areas
:
123 if area
.type == 'VIEW_3D':
124 return area
.spaces
[0].region_3d
129 def LogFirstRegionView3D():
130 print("LogFirstRegionView3D()")
131 regionView3D
= GetFirstRegionView3D()
132 if regionView3D
is None:
133 print("--", "ERROR:", "regionView3D is None")
136 print("--", "view_matrix:")
137 print("--", "--", regionView3D
.view_matrix
)
138 print("--", "view_location:")
139 print("--", "--", regionView3D
.view_location
)
143 # listIP: list of BezierSplineIntersectionPoint
144 # return: list of splines
146 def GetBezierSplines(listIP
):
150 if not (ip
.spline
in rvList
): rvList
.append(ip
.spline
)
155 # listIP: list of BezierSplineIntersectionPoint
156 # return: list of segments
158 def GetBezierSegments(listIP
, spline
):
162 if not ip
.spline
is spline
: continue
164 segIP
= ip
.bezierSegmentIntersectionPoint
165 if not (segIP
.segment
in rvList
): rvList
.append(segIP
.segment
)
170 # listIP: list of BezierSplineIntersectionPoint
171 # return: list of floats (not necessarily ordered)
173 def GetBezierSegmentParameters(listIP
, segment
):
177 segIP
= ip
.bezierSegmentIntersectionPoint
178 if not segIP
.segment
is segment
: continue
180 rvList
.append(segIP
.parameter
)