Giter Site home page Giter Site logo

Comments (7)

mottosso avatar mottosso commented on September 15, 2024

Any updates on this?

from core.

mottosso avatar mottosso commented on September 15, 2024

Anything to do with publishing will be in the /plugins directory, under the name of the given plug-in you would like to update.

Here we can see that Alembic export is done by a function called export_alembic() which can be found here. In this function, you'll need to add support for visibility, and then you'll be done.

Here is the documentation for Maya's Alembic Export MEL command that we use.

AbcExport -h;
// AbcExport [options]
Options:
-h / -help  Print this message.

-prs / -preRollStartFrame double
The frame to start scene evaluation at.  This is used to set the
starting frame for time dependent translations and can be used to evaluate
run-up that isn't actually translated.

-duf / -dontSkipUnwrittenFrames
When evaluating multiple translate jobs, the presence of this flag decides
whether to evaluate frames between jobs when there is a gap in their frame
ranges.

-v / -verbose
Prints the current frame that is being evaluated.

-j / -jobArg string REQUIRED
String which contains flags for writing data to a particular file.
Multiple jobArgs can be specified.

-jobArg flags:

-a / -attr string
A specific geometric attribute to write out.
This flag may occur more than once.

-df / -dataFormat string
The data format to use to write the file.  Can be either HDF or Ogawa.
The default is Ogawa.

-atp / -attrPrefix string (default ABC_)
Prefix filter for determining which geometric attributes to write out.
This flag may occur more than once.

-ef / -eulerFilter
If this flag is present, apply Euler filter while sampling rotations.

-f / -file string REQUIRED
File location to write the Alembic data.

-fr / -frameRange double double
The frame range to write.
Multiple occurrences of -frameRange are supported within a job. Each
-frameRange defines a new frame range. -step or -frs will affect the
current frame range only.

-frs / -frameRelativeSample double
frame relative sample that will be written out along the frame range.
This flag may occur more than once.

-nn / -noNormals
If this flag is present normal data for Alembic poly meshes will not be
written.

-pr / -preRoll
If this flag is present, this frame range will not be sampled.

-ro / -renderableOnly
If this flag is present non-renderable hierarchy (invisible, or templated)
will not be written out.

-rt / -root
Maya dag path which will be parented to the root of the Alembic file.
This flag may occur more than once.  If unspecified, it defaults to '|' which
means the entire scene will be written out.

-s / -step double (default 1.0)
The time interval (expressed in frames) at which the frame range is sampled.
Additional samples around each frame can be specified with -frs.

-sl / -selection
If this flag is present, write out all all selected nodes from the active
selection list that are descendents of the roots specified with -root.

-sn / -stripNamespaces (optional int)
If this flag is present all namespaces will be stripped off of the node before
being written to Alembic.  If an optional int is specified after the flag
then that many namespaces will be stripped off of the node name. Be careful
that the new stripped name does not collide with other sibling node names.

Examples: 
taco:foo:bar would be written as just bar with -sn
taco:foo:bar would be written as foo:bar with -sn 1

-u / -userAttr string
A specific user attribute to write out.  This flag may occur more than once.

-uatp / -userAttrPrefix string
Prefix filter for determining which user attributes to write out.
This flag may occur more than once.

-uv / -uvWrite
If this flag is present, uv data for PolyMesh and SubD shapes will be written to
the Alembic file.  Only the current uv map is used.

-wcs / -writeColorSets
Write all color sets on MFnMeshes as color 3 or color 4 indexed geometry 
parameters with face varying scope.

-wfs / -writeFaceSets
Write all Face sets on MFnMeshes.

-wfg / -wholeFrameGeo
If this flag is present data for geometry will only be written out on whole
frames.

-ws / -worldSpace
If this flag is present, any root nodes will be stored in world space.

-wv / -writeVisibility
If this flag is present, visibility state will be stored in the Alembic
file.  Otherwise everything written out is treated as visible.

-wc / -writeCreases
If this flag is present and the mesh has crease edges or crease vertices, 
the mesh (OPolyMesh) would now be written out as an OSubD and crease info will be stored in the Alembic 
file. Otherwise, creases info won't be preserved in Alembic file 
unless a custom Boolean attribute SubDivisionMesh has been added to mesh node and its value is true. 

-mfc / -melPerFrameCallback string
When each frame (and the static frame) is evaluated the string specified is
evaluated as a Mel command. See below for special processing rules.

-mpc / -melPostJobCallback string
When the translation has finished the string specified is evaluated as a Mel
command. See below for special processing rules.

-pfc / -pythonPerFrameCallback string
When each frame (and the static frame) is evaluated the string specified is
evaluated as a python command. See below for special processing rules.

-ppc / -pythonPostJobCallback string
When the translation has finished the string specified is evaluated as a
python command. See below for special processing rules.

Special callback information:
On the callbacks, special tokens are replaced with other data, these tokens
and what they are replaced with are as follows:

#FRAME# replaced with the frame number being evaluated.
#FRAME# is ignored in the post callbacks.

#BOUNDS# replaced with a string holding bounding box values in minX minY minZ
maxX maxY maxZ space seperated order.

#BOUNDSARRAY# replaced with the bounding box values as above, but in
array form.
In Mel: {minX, minY, minZ, maxX, maxY, maxZ}
In Python: [minX, minY, minZ, maxX, maxY, maxZ]

Examples:

AbcExport -j "-root |group|foo -root |test|path|bar -file /tmp/test.abc"
Writes out everything at foo and below and bar and below to /tmp/test.abc.
foo and bar are siblings parented to the root of the Alembic scene.

AbcExport -j "-frameRange 1 5 -step 0.5 -root |group|foo -file /tmp/test.abc"
Writes out everything at foo and below to /tmp/test.abc sampling at frames:
1 1.5 2 2.5 3 3.5 4 4.5 5

AbcExport -j "-fr 0 10 -frs -0.1 -frs 0.2 -step 5 -file /tmp/test.abc"
Writes out everything in the scene to /tmp/test.abc sampling at frames:
-0.1 0.2 4.9 5.2 9.9 10.2

Note: The difference between your highest and lowest frameRelativeSample can
not be greater than your step size.

AbcExport -j "-step 0.25 -frs 0.3 -frs 0.60 -fr 1 5 -root foo -file test.abc"

Is illegal because the highest and lowest frameRelativeSamples are 0.3 frames
apart.

AbcExport -j "-sl -root |group|foo -file /tmp/test.abc"
Writes out all selected nodes and it's ancestor nodes including up to foo.
foo will be parented to the root of the Alembic scene.

 // 

In it, we can spot writeVisibility. This is the one we'd like to add.

Ideally, we add it as an argument to our alembic_export() function, like uv_write=True, so that we have some flexibility.

Let me know if you need any more help with this.

from core.

LegacyID1991 avatar LegacyID1991 commented on September 15, 2024

I am on it

from core.

LegacyID1991 avatar LegacyID1991 commented on September 15, 2024

I have followed your instructions and I have made modifications to

extract_animation.py
lib.py

I have not been able to test out its functionality related to this issue (ie multiple models hidden and revealed as controlled by a rig)

but I did this test and was sucessfull:

cmds.file(new=True, force=True)

from maya import cmds
from mindbender import maya, api


cube = cmds.polyCube(name="myCube_GEO")
cmds.select(cube)
transform = cmds.ls(selection=True, type="transform")

startTime = cmds.playbackOptions( query=True, minTime=True)
endTime = cmds.playbackOptions( query=True, maxTime=True)

halfTime = (((endTime-startTime)/2)+startTime)


cmds.cutKey( transform, time=(startTime, endTime), attribute="visibility" )

cmds.setKeyframe(transform, time=startTime, attribute="visibility", value=1)
cmds.setKeyframe(transform, time=halfTime, attribute="visibility", value=0)
cmds.setKeyframe(transform, time=endTime, attribute="visibility", value=1)

assembly = cmds.group(name="ROOT")


container = maya.create(
    "animationDefault",
    family="mindbender.animation",
    options={"useSelection": True}
)

cmds.file(rename="temp.ma")
cmds.file(save=True)

import pyblish_lite
pyblish_lite.show()
# STOP HERE
# Complete the steps in pyblish

# continue
cmds.file(new=True, force=True)

import os
from maya import cmds
from mindbender import maya, api

importpath = os.getenv("MINDBENDER_ASSETPATH")
#double backwardslashes because of windows and single backwardslash result in error. 
importpath = importpath+"\publish\\animationDefault\\v001\\animationDefault.abc"

print importpath

cmds.AbcImport(importpath)

from core.

mottosso avatar mottosso commented on September 15, 2024

That is excellent, Arvid!

If you make a pull request, I'll show you how we can make a test for this specific feature so that we know it works now and that it never breaks in the future once we have made more changes.

from core.

mottosso avatar mottosso commented on September 15, 2024

Also here is a shorthand way of publishing directly via Python.

from pyblish import util
util.publish()

That way, there is absolutely no way we could be getting different results of anyone clicking something in a different order or what not.

from core.

LegacyID1991 avatar LegacyID1991 commented on September 15, 2024

That is awesome, Thanks!

from core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.