################################################################# # This script works on a single selected hair geometry object # modify the stagePath before using # ################################################################ import bpy from pxr import Usd, UsdGeom, Sdf, Gf stagePath = r'C:\work\dumpTest.usda' curvePrimPath = Sdf.Path('/blenderCurves') stage = Usd.Stage.CreateNew(stagePath) curvePrim = UsdGeom.BasisCurves.Define(stage, curvePrimPath) vertexCountAttr = curvePrim.GetCurveVertexCountsAttr() typeAttr = curvePrim.GetTypeAttr() widthAttr = curvePrim.GetWidthsAttr() pointsAttr = curvePrim.GetPointsAttr() widths = [] vertexCounts = [] points = [] curves = bpy.context.selected_objects[0] pointDump = [[x for x in y.points] for y in curves.data.curves] for i in pointDump: vertexCounts.append(len(i)) for pt in i: widths.append(pt.radius if pt.radius > .01 else .01) points.append(Gf.Vec3f(pt.position[0],pt.position[1],pt.position[2])) vertexCountAttr.Set(vertexCounts) widthAttr.Set(widths) pointsAttr.Set(points) typeAttr.Set(UsdGeom.Tokens.linear, Usd.TimeCode.Default()) stage.Save()