Skip to content

Instantly share code, notes, and snippets.

@BigRoy
Created September 22, 2020 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BigRoy/eea07a0fb60437eb5cecd9fc6c4fd324 to your computer and use it in GitHub Desktop.
Save BigRoy/eea07a0fb60437eb5cecd9fc6c4fd324 to your computer and use it in GitHub Desktop.
Debug print out Alembic PolyMesh attributes
import alembic
def _print_properties(property, depth=1):
# Property name
print ("\t" * depth) + property.getName()
# Metadata
metadata = property.getMetaData()
if metadata.size():
# Can hold things like "sourceName" for UVs
print ("\t" * depth) + " - metadata -> %s" % metadata
# Header (check whether it's marked as UVs)
header = property.getHeader()
if hasattr(header, "isUV"):
is_uv = header.isUV()
if is_uv:
print ("\t" * depth) + " - " + "header -> isUV=%s" % header.isUV()
print("")
# CompoundProperty print children
if isinstance(property, alembic.Abc.ICompoundProperty):
num_sub_properties = property.getNumProperties()
for i in range(num_sub_properties):
sub_property = property.getProperty(i)
_print_properties(sub_property, depth+1)
def print_alembic_shape_attributes(filename):
filename = str(filename) # ensure str
archive = alembic.Abc.IArchive(filename)
root = archive.getTop()
iterator = list(root.children)
for obj in iterator:
md = obj.getMetaData()
if alembic.AbcGeom.IPolyMesh.matches(md):
polymesh = alembic.AbcGeom.IPolyMesh(obj, alembic.Abc.WrapExistingFlag.kWrapExisting)
schema = polymesh.getSchema()
print obj
uv = schema.getUVsParam()
if uv.valid():
print "\t", "polymesh (UV parm)"
_print_properties(uv)
# Arbitrary Geometry Parms
arbgeomparms = schema.getArbGeomParams()
if arbgeomparms.valid():
# Should always be valid
_print_properties(arbgeomparms)
# User Properties
user_properties = schema.getUserProperties()
if user_properties.valid():
_print_properties(user_properties)
print("")
# include children for coming iterations
iterator.extend(obj.children)
path = "path/to/alembic.abc"
print_alembic_shape_attributes(path)
@jpvfx2
Copy link

jpvfx2 commented Dec 9, 2020

Hi there,

Thanks for this! Extremely helpful for a beginner with alembic! One question (forgive me if its a noob question). I have the script working and printing the shape Attributes, but I cant figure out how to print the value of the attribute - I'm expecting the attribute "myMaterialTag" to return string of "test". what am i missing? Output below:

print_alembic_shape_attributes(path)
/pSphere1/pSphereShape1
.arbGeomParams
- metadata -> .arbGeomParams

	myMaterialTag
	      - metadata -> arrayExtent=1;isGeomParam=true;podExtent=1;podName=string

Thanks in advance for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment