Forum breadcrumbs - You are here:ForumPrism: GeneralExport Attributes in Alembic
You need to log in to create posts and topics.

Export Attributes in Alembic

12

Hi !
I'm not Magnus but as I'm working with him and my password link doesn't work I'm using his account !

We are trying to make a custom importer for Houdini and we need to write the 'Extra Attributes' that Maya provides into an exported .abc file. I would like to keep the export process through Prism because it's easier for me but 'Attributes' are not supported yet...

There is a setting that need to be manually added via the Alembic cache window exporter (see image below) or from code when running the "cmds.AbcExport":

flag to add: -attr <attributeName>

cmds.AbcExport ( j = "-frameRange  1001 1100  -attr material -dataFormat ogawa -root pCube -file object.abc )

My problem is that I don't know how to integrate that in the Prism exporter, or by the Hook system that you provide, have you got any tips ?

I have also another question: Magnus told me that you are planning to add a unique file always overwritten at each new version saved, do you have any plans to work soon on this feature ?

Uploaded files:
  • export_abc_attribute.jpg

Do you need help with resetting your password?

At the moment there is no option to add custom attributes. I would need to add a new field in the state settings for that I guess or at least a callback that you could use a Prism plugin to modify the export command. The callback I could add right now, but adding that option to the user interface would take a bit more time. You can find the export command of Prism for alembic in Maya here: https://github.com/RichardFrangenberg/Prism/blob/e11f464d09718954fe36488698ab90eac0d614ca/Prism/Plugins/Apps/Maya/Scripts/Prism_Maya_Functions.py#L602

You could customize it and use the "Reload all plugins" button in the Plugins tab of the Prism Settings to let your changes take affect without restarting Maya.

 

Quote from Magnus on 4. July 2019, 11:18

I have also another question: Magnus told me that you are planning to add a unique file always overwritten at each new version saved, do you have any plans to work soon on this feature ?

I'm not exactly sure what you mean by that. Do you mean that a Maya scenefile gets saved over the previous version or do you talk about exports or renderings?

My username is 'Augu' if you can help me 🙂

Yeah a callback to change .abc export settings will be great as a first step if I manage to make it works !

Talking about callback is there one to modify and launch an export (State Manager) from the plugin API ? I would like to export automatically some object as a Publish file when a scene step is created but I can't find it... Same thing with the importer, it would be nice if we can do it by python !

I was talking about Maya's scene files which are saved over the previous version, yes !

 

Quote from Magnus on 5. July 2019, 9:46

My username is 'Augu' if you can help me 🙂

I could set a password for your account and send it to your email address.

 

Quote from Magnus on 5. July 2019, 9:46

Yeah a callback to change .abc export settings will be great as a first step if I manage to make it works !

I just added the callback "maya_export_abc" to the "custom" plugin type in Prism v1.2.0.17. You can use that to modify the mel command, which Prism will execute to export the abc file. The callback has an example in the comment in the plugin script, but feel free to ask if something is unclear. See here how to create a new plugin.

 

Quote from Magnus on 5. July 2019, 9:46

Talking about callback is there one to modify and launch an export (State Manager) from the plugin API ? I would like to export automatically some object as a Publish file when a scene step is created but I can't find it... Same thing with the importer, it would be nice if we can do it by python !

There is a "onStepCreated" callback, where you can add your code to, which will be executed, when a step gets created. It would be possible to open the StateManager, create a state and publish the scene. I can give you a quick example. But do you want to publish the currently open scene or do you want to create an empty Maya file in the newly created step, open that file and publish that file?

 

Quote from Magnus on 5. July 2019, 9:46

I was talking about Maya's scene files which are saved over the previous version, yes !

To overwrite the current scenefile you can simply hit ctrl+s or use File->Save Scene in Maya. I don't think it's necessary to make a new shelf tool for that. But of course you could customize your Prism shelf and add this if you like.

Hey Richie! The real Magnus is back 🙂

1) If you could send the password to contact.augustelefort@gmail.com it would be mucho appreciated!

2) Maya_export_abc: Working great - thanks a million!

3) Import/Export: An example would great, thanks. Let me try to ellaborate a bit more what we are working on.

For each defined asset (that we define in a json file) we want to do the following:

  1. create 'mod' step
  2. add custom groups with custom naming in the empty mod file (no need for example of course)
  3. publish that group - with specific task name (asset name + _MOD)
  4. create 'rig' step
  5. import mod export
  6. add custom groups and naming
  7. export custom named group with rig and mod ref inside

Hope that make sense. We are just looking for the prism commands of course.

4) Publish to overwritten file

I don't know if you remember about a year  ago I suggested prism adapting the publish structure that 'open pipeline' use, where there is a single publish file for each asset so that you don't have to manually update asset when they are exorted. The versions is also kept so you can easily roll back of course. I never had any påroblems with this, however the manual updates (even though there is a pop-up and flashing orange button) have givin me hours and hours on end of troubleshooting because somewhere in the pipe stuff havn't been updates. So for me and our studio setup the'open pipeline'-way makes more sense. I totally understand why prism is set up the way it is of course, I guess it is a matter of preference 🙂 anyways, we want to implement this new functionality as a plugin - but since you back then mentioned that it could be something you wanted to add to prism I ask Auguste to ask you if it is something that going to be implemented in the near future - just to check, we know it is a long shot 😀 Or maybe you know about anyone else that have already done this as a plugin?

5) Create new HDA from existing HDA

I'm a bit lost regarding this, lol.... So basically I want to create a completely new hda from an existing hda. I have a hda called 'ASSET_base'. Let's say I have a character asset named 'Kronk', I want to basically duplicate the 'ASSET_base' and make it into a new hda called 'ASSET_kronk'. Is this possible with the prism exporter (tried every setting, but couldn't get it to work) , and if not, do you know how to do this in houdni - optimally with code?

Best,

Magnus

 

 

 

 

Hey nice to see you back 🙂 I needed to make some changes to the Prism code, which is why my reply took a bit.

3. It would be possible with your current Prism version, but I cleaned up the Prism code, which makes it a lot easier to script this behavior now. To use this example you need at least Prism v1.2.1.0 (which I just uploaded).

####(execute in Maya Script Editor)

assetName = "Cube"

# get Project Browser class
pb = pcore.pb
# create step
stepPath = pb.createStep(stepName="mod", entity="asset", entityName=assetName, createCat=True)
# create empty scene and open it
filePath = pb.createEmptyScene(entity="asset", fileName="EmptyScene_Maya2018.ma", entityName=assetName, step="mod", category=os.path.basename(stepPath), openFile=True)

#### create states and publish
stateManager = pcore.stateManager()
exportItem = stateManager.createState("Export")
# create objects in scene
cmds.polyCube( sx=10, sy=15, sz=5, h=20 )
cmds.group( 'pCube1', n='group1' )
# add objects to the export state
pcore.appPlugin.sm_export_addObjects(exportItem.ui, objects=["group1", "pCube1"])
# set task name
exportItem.ui.setTaskname("cubeGEO")
# set outputtype
idx = exportItem.ui.cb_outType.findText(".ma")
exportItem.ui.cb_outType.setCurrentIndex(idx)
# publish
stateManager.publish()
# get outputpath
modelPath = exportItem.ui.l_pathLast.text()

# create rigging file
stepPath = pb.createStep(stepName="rig", entity="asset", entityName=assetName, createCat=True)
filePath = pb.createEmptyScene(entity="asset", fileName="EmptyScene_Maya2018.ma", entityName=assetName, step="rig", category=os.path.basename(stepPath), openFile=True)
# import model
stateManager = pcore.stateManager()
importItem = stateManager.createState("ImportFile", importPath=["cubeGEO", modelPath])

exportItem = stateManager.createState("Export", setActive=True)
# select imported objects
cmds.select( importItem.ui.nodes )
# add selected objects to the export state
pcore.appPlugin.sm_export_addObjects(exportItem.ui)
exportItem.ui.setTaskname("cubeRIG")
idx = exportItem.ui.cb_outType.findText(".ma")
exportItem.ui.cb_outType.setCurrentIndex(idx)
# uncheck import references
exportItem.ui.chb_importReferences.setChecked(False)
stateManager.publish()

4. Oh yeah, sure I remember that. It sounded like you meant the actual working scenefile and not the one which gets exported. I don't have planned this for the near future. So if you could manage to write that a plugin that would be great. If you get stuck I'll support you of course. Unfortunately I'm not aware of anyone who already has a plugin for that.

5. Prism has no option at the moment to change the node type of a node. But it would be possible new feature in the future. You can do that in the Houdini UI in the asset manager window. Rightclick on your 'ASSET_base' definition and select "Duplicate". Then you can enter a filepath to save the new HDA and a operator type and label. The equivalent in python would be:

hou.selectedNodes()[0].type().definition().copyToHDAFile("D:/Kronk.hda", new_name="asset_kronk", new_menu_name="Kronk")

Hey ! I finally manage to make this account working ! Thanks Richard ! Next step: find how to change my profil picture 😉

3. Thanks for the snippet ! Actually I have some trouble with it:

  • The command  createEmptyScene() seems to not work as expected and the script fails because of it... Even through the ProjectBrowser UI I'm not able able to create a new scene from your predefined ones. Maybe there is some problem with our Maya version (Autodesk Maya 2017 Update 5). Of course I tried with this:

    fileName="EmptyScene_Maya2017.ma"

    but it didn't work :'( For now I'm using a custom starting file.

  • I need to be able to run your snippet in a Prism plugin but when I tried there was an error throwned: Can't find the pcore declaration (because I suppose that it is set with the opening of Maya). So how can I access this module outside Maya ?

Thanks again for your quick answers and for the other points I'll let Magnus answer ! 🙂

For the profile picture you have to change it here: https://en.gravatar.com/

It feels a bit unintuitive to change it on a different site, but it works 🙂

What's the error you get with createEmptyScene()? Check if that scenefile actually exists in /00_Pipeline/EmptyScenes in your project folder.

pcore is just a variable to reference the PrismCore instance in the Maya script editor. To access the current PrismCore instance in a plugin function you can simply use "self.core" instead of "pcore". The example should work fine inside of Maya, but if you want to execute it in a standalone Prism instance, it needs to be changed a bit. Because the State Manager is not available in the standalone Prism tools, the line "stateManager = self.core.stateManager()" would not work outside of a 3d app.

I'll dig into that thanks !

########################################################################

What's the error you get with createEmptyScene()? Check if that scenefile actually exists in /00_Pipeline/EmptyScenes in your project folder.

Yes it exists and here's the errors:

Traceback (most recent call last):
File "C:/Prism\Scripts\PrismCore.py", line 218, in func_wrapper
return func(*args, **kwargs)
File "C:/Prism\Scripts\PrismCore.py", line 1949, in generateScenePath
assetPath = assetPath.replace(self.aBasePath.replace(self.core.projectPath, self.core.localProjectPath), "")
AttributeError: PrismCore instance has no attribute 'aBasePath'

Traceback (most recent call last):
File "C:\Prism\Scripts\ProjectScripts\ProjectBrowser.py", line 219, in func_wrapper
return func(*args, **kwargs)
File "C:\Prism\Scripts\ProjectScripts\ProjectBrowser.py", line 1637, in createEmptyScene
filePath = filePath.replace(self.core.projectPath, self.core.localProjectPath)
AttributeError: 'NoneType' object has no attribute 'replace'

########################################################################

the line "stateManager = self.core.stateManager()" would not work outside of a 3d app

Oh that's why... I'm using the plugin through Maya (custom UI pop up when you open Prism Settings just for testing) but I guess it runs outside of Maya after all... Will it be hard to access it anyway ?

Oh, I introduced that error yesterday evening, sorry about that. I just fixed it (v1.2.1.2).

As long as your code doesn't try to interact with the Maya scene or the State Manager it should work in the Prism standalone tools as well. When you want to run your plugin code in Prism standalone and it should modify Maya scenefiles, you have to start a Maya process of course. So you would have a python process, which runs some code to start a Maya process and then this process runs some code to open a scene and modifies it.

If you want to process multiple scenes without user interaction you should take a look at the mayapy.exe (to run Maya without UI, which is a lot faster). But I haven't tested Prism with mayapy too much, so in case some Prism UIs will pop up I have to fix that.

12