Skip to content

Instantly share code, notes, and snippets.

@Gus-The-Forklift-Driver
Created March 13, 2023 17:06
Show Gist options
  • Save Gus-The-Forklift-Driver/23646c8cce64d4cdfe61467da64853c0 to your computer and use it in GitHub Desktop.
Save Gus-The-Forklift-Driver/23646c8cce64d4cdfe61467da64853c0 to your computer and use it in GitHub Desktop.
Export houdini packed geo to blender
import math
import bpy
from mathutils import *
D = bpy.data
C = bpy.context
print('=====START====')
with open('./locations.csv', 'r') as file:
lines = file.readlines()
for line in lines:
data = line.replace('\n', '').split(',')
trans = data[0:16]
name = data[16]
trans = [float(value) for value in trans]
trans = Matrix(((trans[0], trans[1], trans[2], trans[3]),
(trans[4], trans[5], trans[6], trans[7]),
(trans[8], trans[9], trans[10], trans[11]),
(trans[12], trans[13], trans[14], trans[15])))
non_transposed = trans
trans.transpose()
loc, rot, scale = trans.decompose()
duplicate = bpy.data.objects[name].copy()
duplicate.location = (loc.x, -loc.z, loc.y)
duplicate.rotation_euler = (Matrix.Rotation(math.radians(90), 4, 'X') @ non_transposed).to_euler()
duplicate.rotation_euler.x -= math.radians(90)
duplicate.scale = (scale.x, -scale.z, scale.y)
bpy.context.scene.collection.objects.link(duplicate)
4@transforms = getpackedtransform(0,@primnum);
node = hou.pwd()
geo = node.geometry()
# need packed geo to have a prim attribute 'name' contaning the name of the prim
# need packed geo to have a prim attribute 'transforms' containing the matrix transform of the packed prim
with open(node.evalParm('path'),'w') as file:
for prim in geo.prims():
transform = prim.attribValue('transforms')
for x in transform:
file.write(str(x) + ',')
file.write(prim.attribValue('name')+'\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment