2 from mathutils
import *
5 def GetSelectedCurves():
8 for obj
in bpy
.context
.selected_objects
:
10 if obj
.type == "CURVE": rvList
.append(obj
)
17 def GetSelectedMeshes():
20 for obj
in bpy
.context
.selected_objects
:
22 if obj
.type == "MESH": rvList
.append(obj
)
31 if len(GetSelectedCurves()) == 1:
32 return (bpy
.context
.active_object
.type == "CURVE")
41 if len(GetSelectedMeshes()) == 1:
42 return (bpy
.context
.active_object
.type == "MESH")
49 def Selected1SingleSplineCurve():
52 return (len(bpy
.context
.active_object
.data
.splines
) == 1)
59 def Selected2Curves():
61 if len(GetSelectedCurves()) == 2:
62 return (bpy
.context
.active_object
.type == "CURVE")
69 def Selected3Curves():
71 if len(GetSelectedCurves()) == 3:
72 return (bpy
.context
.active_object
.type == "CURVE")
79 def Selected1OrMoreCurves():
81 if len(GetSelectedCurves()) > 0:
82 return (bpy
.context
.active_object
.type == "CURVE")
88 def Selected2OrMoreCurves():
90 if len(GetSelectedCurves()) > 1:
91 return (bpy
.context
.active_object
.type == "CURVE")
98 def Selected1OrMoreMesh():
100 if len(GetSelectedMeshes()) > 0:
101 return (bpy
.context
.active_object
.type == "MESH")
108 def GetToolsRegion():
109 for area
in bpy
.context
.screen
.areas
:
110 if area
.type == 'VIEW_3D':
111 for region
in area
.regions
:
112 if region
.type == 'TOOLS': return region
117 def GetFirstRegionView3D():
118 for area
in bpy
.context
.screen
.areas
:
119 if area
.type == 'VIEW_3D':
120 return area
.spaces
[0].region_3d
125 def LogFirstRegionView3D():
126 print("LogFirstRegionView3D()")
127 regionView3D
= GetFirstRegionView3D()
128 if regionView3D
is None:
129 print("--", "ERROR:", "regionView3D is None")
132 print("--", "view_matrix:")
133 print("--", "--", regionView3D
.view_matrix
)
134 print("--", "view_location:")
135 print("--", "--", regionView3D
.view_location
)
139 # listIP: list of BezierSplineIntersectionPoint
140 # return: list of splines
142 def GetBezierSplines(listIP
):
146 if not (ip
.spline
in rvList
): rvList
.append(ip
.spline
)
151 # listIP: list of BezierSplineIntersectionPoint
152 # return: list of segments
154 def GetBezierSegments(listIP
, spline
):
158 if not ip
.spline
is spline
: continue
160 segIP
= ip
.bezierSegmentIntersectionPoint
161 if not (segIP
.segment
in rvList
): rvList
.append(segIP
.segment
)
166 # listIP: list of BezierSplineIntersectionPoint
167 # return: list of floats (not necessarily ordered)
169 def GetBezierSegmentParameters(listIP
, segment
):
173 segIP
= ip
.bezierSegmentIntersectionPoint
174 if not segIP
.segment
is segment
: continue
176 rvList
.append(segIP
.parameter
)