Hi TD’ers!
I have an FBX with a lot of different sized box GEO’s inside.
I would love to manipulate these as instances, which would be easy if the children had the same size, but unfortunately nopes.
I might be able to do this if could get the local size of each mesh, but so far i can only get their parent Geo sizes which is default 1, 1.
Help would be greatly appreciated!
Thanks!
If your goal is to get the size of a SOP mesh, you can get that using the size member of the SOPClass:
Also the GeometryCOMPClass has the method computebounds() to calculate the bounding box of the child geometry of that component.
Thank you Nettoyeur!
The FileinSOP class is what i missed, but i’m still having a problem getting all the mesh sizes.
I would think it would be something like this, but obviously the syntax is wrong.
num = op(‘fbx’).numChildren
for i in range (num):
sx = op(‘fbx/a_’+str(i+1)/mesh).size.x
The mesh path is “/project1/fbx/a_636/mesh” where their parent geos are named “a_1” with incremental naming.
Thanks again!
Found the solution if anybody wants to instance an imported FBX with lots of different sized box meshes.
I wrote this script to get all the sop values into a table. Then i transformed the table to chop values and for manipulation I added a Chop to Top with noises which finally is used for the instancing data.
Running 60fps, HD, 32x aliasing, 810 meshes on a 3090.
Script:
#Clearing the target table
op('yourTablename').clear()
#Reference the top-level container containing Geometry COMPs
topLevelContainer = op('yourFBX')
#Get all Geometry COMPs inside the top-level container
geoCompList = topLevelContainer.findChildren(type=COMP)
#Iterate through Geometry COMPs
for geoComp in geoCompList:
print(f"Geometry Component: {geoComp.name}")
#Retrieve the tx and ty parameters of the Geometry COMP
tx = geoComp.par.tx.eval()
ty = geoComp.par.ty.eval()
print(f" tx: {tx}, ty: {ty}")
# Iterate through importselectSOPs inside the Geometry COMP
for importSOP in geoComp.findChildren(type=importselectSOP):
# Use the size attribute of importselectSOP
sopSizeX = importSOP.size.x
sopSizeY = importSOP.size.y
sopSizeZ = importSOP.size.z
print(f" Import Select SOP Size for {importSOP.name}: X={sopSizeX}, Y={sopSizeY}, Z={sopSizeZ}")
#print position and size values of all importsSelects to target table.
op('yourTablename').appendRow([tx,ty,sopSizeX,sopSizeY,sopSizeZ])
print("\n")
#Run this script and use a "Dat to" chop for the table. Now you can use this chop as channel data as instancing data in a GEO comp.