Created
March 13, 2023 17:06
-
-
Save Gus-The-Forklift-Driver/23646c8cce64d4cdfe61467da64853c0 to your computer and use it in GitHub Desktop.
Export houdini packed geo to blender
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4@transforms = getpackedtransform(0,@primnum); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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