maxon.AssetCreationInterface

Description

Helper interface for asset creation and drag&drop

Inheritance diagram

Inheritance

Parent Class:

Methods Signature

AddPreviewRenderAsset(assetsToPreviewRender)

Adds the given assets to the background render queue.

BrowseDescriptionForDefaults(desc, add, …)

Helper function to browse through Descriptions to collect all attributes to be stored in a preset.

CheckObjectsOnDrop(doc, url, asset, …)

Helper function to add objects into the scene from the asset browser.

CreateMaterialAsset(activeDoc, mat, …)

Creates a material asset from the given BaseMaterial.

CreateMaterialsOnDrag(doc, objectOrTag, url, …)

param doc

BaseDocument to insert the asset.

CreateObjectAsset(op, activeDoc, …)

Creates an object asset from the given BaseObject.

CreateObjectsOnDrag(doc, url, asset, …[, …])

Helper function to create assets when d&d into a scene/viewport.

CreateSceneAsset(activeDoc, …)

Creates a scene asset from the given BaseDocument.

GenerateImagePreview(imageUrl, previews, …)

Generates a preview image for a given texture.

GenerateScenePreviewImage(doc, preview, …)

Generates the preview image of the given BaseDocument.

GetAddDependencyDelegate(documentPath, …)

Helper function to generate the ResolveAssetDependenciesStruct.ResolveDelegate.

GetDefaultObject(asset[, doc])

Returns a new default object for the given preset.

GetDefaultSettings(asset, resId, resData)

Loads the settings for a preset

GetNewAssetIdFromIdAndVersion(prefix, …)

GetNewAssetIdFromIdAndVersion generates a standarized id from the given prefix and IdAndVersion for a new asset.

OpenSaveAssetDialog(flags, presetTypeName, …)

Opens the save asset dialog.

RenderDocumentAsset(renderDoc, progressRef, …)

Helper function to render a BaseDocument for preview rendering.

SaveActiveDocumentAsNewVersion(activeDoc, …)

Writes the current BaseDocument as new version with asset dialog.

SaveBaseDocumentAsAsset(doc, c4dRootPath, …)

Stores the given BaseDocument as a new scene to be saved as an asset.

SaveBrowserPreset(assetType, sourceData, …)

Stores the given data as preset asset.

SaveDefaultPresetFromObject(l, makeDefault)

Stores the default from the given object into the asset browser.

SaveDocumentAsset(assetDoc, subType, …)

Stores the given BaseDocument into the given repository.

SaveMemFileAsAsset(saveFileName, …)

Stores the given url as a asset into a temporary repository.

SaveMemFileAsAssetAlone(saveFileName, …)

Stores the plain file into a temporary repository.

SaveMemFileAsAssetWithCopyAsset(…)

Stores the given url as a asset.

SaveMetaDataForAsset(asset, parentCategory, …)

Stores he given values into the asset description.

SaveTextureAsset(imageUrl, assetName, …)

Stores the given image as media asset.

SetDefaultObject(defaultsType, partial, bc, …)

param defaultsType

Ids of the BaseObject. e.g. Ocube

SupportDefaultPresets(l)

Helper function to find if the given type supports the preset system.

UpdateMetaData(doc[, metaProperties, …])

UpdateMetaData recalculates the asset metadata.

Methods Definition

static AssetCreationInterface.AddPreviewRenderAsset(assetsToPreviewRender)

Adds the given assets to the background render queue.

Parameters

assetsToPreviewRender (maxon.Block [maxon.AssetDescription]) – Assets to add to the render queue.

static AssetCreationInterface.BrowseDescriptionForDefaults(desc, add, isPartial)

Helper function to browse through Descriptions to collect all attributes to be stored in a preset.

Parameters
  • desc (c4d.Description) – Description to browse.

  • add (Callable[[c4d.DescId, maxon.Tuple [bool, c4d.BaseContainer, c4d.DescID, str], None]) – delegate which is triggered for each attribute.

  • isPartial (bool) – True if this should be a partial preset. In that case DESC_UNIMPORTANTFORDEFAULTS will be ignored.

static AssetCreationInterface.CheckObjectsOnDrop(doc, url, asset, placementScale)

Helper function to add objects into the scene from the asset browser.

This functions keeps a list of assets and remembers if they were added already.

Parameters
  • doc (c4d.documents.BaseDocument) – BaseDocument to insert the asset.

  • url (maxon.Url) – Url of the d&d operation. This is typically an asset url “asset:///…”

  • asset (maxon.AssetDescription) – AssetDescription of the asset.

  • placementScale (float) – Additional scale factor.

static AssetCreationInterface.CreateMaterialAsset(activeDoc, mat, storeAssetStruct, assetId, assetName, assetVersion, copyMetaData, addAssetsIfNotInThisRepository)

Creates a material asset from the given BaseMaterial.

Parameters
  • activeDoc (c4d.documents.BaseDocument) – BaseDocument of the material to store. This document will be used to find dependencies.

  • mat (c4d.BaseMaterial) – BaseMaterial to store.

  • storeAssetStruct (maxon.StoreAssetStruct) – Settings where to store the asset.

  • assetId (maxon.Id) – Optional asset Id. If empty the system calculates a new asset id.

  • assetName (str) – Human readable name of the asset.

  • assetVersion (str) – Human readable version string.

  • copyMetaData (maxon.AssetMetaData) – Optional meta data to copy from another version.

  • addAssetsIfNotInThisRepository (bool) – True to store the asset in the given saveRepository even if it’s already in any other repository. False would skip the writing.

Returns

The created AssetDescription.

Return type

maxon.AssetDescription

static AssetCreationInterface.CreateMaterialsOnDrag(doc, objectOrTag, url, allowMultiple, subType, noManagerUpdate, startUndo)
Parameters
  • doc (c4d.documents.BaseDocument) – BaseDocument to insert the asset.

  • objectOrTag (c4d.BaseList2D) – Drop destination.

  • url (maxon.Url) – Url of the d&d operation. This is typically an asset url “asset:///…”

  • allowMultiple (bool) – True to insert multiple materials at the same time.

  • subType (maxon.Id) – Subtype of the asset.

  • noManagerUpdate (bool) – True to prevent attribute manager updates when activating the new objects.

  • startUndo (bool) – True to call doc->StartUndo() and EndUndo().

Returns

Array with the newly created BaseMaterials on success.

Return type

tuple( c4d.BaseMaterial)

static AssetCreationInterface.CreateObjectAsset(op, activeDoc, storeAssetStruct, assetId, assetName, assetVersion, copyMetaData, addAssetsIfNotInThisRepository)

Creates an object asset from the given BaseObject.

Parameters
  • op (c4d.BaseObject) – BaseObject to store.

  • activeDoc (c4d.documents.BaseDocument) – BaseDocument of the material to store. This document will be used to find dependencies.

  • storeAssetStruct (maxon.StoreAssetStruct) – Settings where to store the asset.

  • assetId (maxon.Id) – Optional asset Id. If empty the system calculates a new asset id.

  • assetName (str) – Human readable name of the asset.

  • assetVersion (str) – Human readable version string.

  • copyMetaData (maxon.AssetMetaData) – Optional meta data to copy from another version.

  • addAssetsIfNotInThisRepository (bool) – True to store the asset in the given saveRepository even if it’s already in any other repository. False would skip the writing.

Returns

The created AssetDescription.

Return type

maxon.AssetDescription

static AssetCreationInterface.CreateObjectsOnDrag(doc, url, asset, filterString, allowPreviewCube, overwriteMatrix, overwriteMatrixMg, placementScale, parent=None, prev=None)

Helper function to create assets when d&d into a scene/viewport.

Parameters
  • doc (c4d.documents.BaseDocument) – BaseDocument to insert the asset.

  • url (maxon.Url) – Url of the d&d operation. This is typically an asset url “asset:///…”

  • asset (maxon.AssetDescription) – AssetDescription of the asset.

  • filterString (str) – Filter string of the d&d operation. This allows to switch the search term e.g. sphere / cube on a modeling node.

  • allowPreviewCube (bool) – True to indicate that a preview cube should be inserted instead of the real geometry.

  • overwriteMatrix (bool) – True to overwrite the overwriteMatrixMg.

  • overwriteMatrixMg (maxon.Matrix) – Overwrite the matrix with this value.

  • placementScale (float) – Additional scale factor.

  • parent (Optional[c4d.BaseObject]) – Parent object to insert.

  • prev (Optional[c4d.BaseObject]) – Previous object to insert.

static AssetCreationInterface.CreateSceneAsset(activeDoc, storeAssetStruct, assetId, assetName, assetVersion, copyMetaData, addAssetsIfNotInThisRepository)

Creates a scene asset from the given BaseDocument.

Parameters
  • activeDoc (c4d.documents.BaseDocument) – BaseDocument to store. This document will be used to find dependencies.

  • storeAssetStruct (maxon.StoreAssetStruct) – Settings where to store the asset.

  • assetId (maxon.Id) – Optional asset Id. If empty the system calculates a new asset id.

  • assetName (str) – Human readable name of the asset.

  • assetVersion (str) – Human readable version string.

  • copyMetaData (maxon.AssetMetaData) – Optional meta data to copy from another version.

  • addAssetsIfNotInThisRepository (bool) – True to store the asset in the given saveRepository even if it’s already in any other repository. False would skip the writing.

Returns

The created AssetDescription.

Return type

maxon.AssetDescription

static AssetCreationInterface.GenerateImagePreview(imageUrl, previews, previewW, previewH)

Generates a preview image for a given texture.

Parameters
  • imageUrl (maxon.Url) – Url of the texture.

  • previews (Callable[[maxon.Url], None]) – ValueReceiver which receives the preview.

  • previewW (int) – Preview width.

  • previewH (int) – Preview height.

static AssetCreationInterface.GenerateScenePreviewImage(doc, preview, flags, previewW, previewH)

Generates the preview image of the given BaseDocument.

Parameters
static AssetCreationInterface.GetAddDependencyDelegate(documentPath, addAssetsIfNotInThisRepository)

Helper function to generate the ResolveAssetDependenciesStruct.ResolveDelegate.

Parameters
  • documentPath (str) – Root Path of the document.

  • addAssetsIfNotInThisRepository (bool) – True to store the asset in the given saveRepository even if it’s already in any other repository. False would skip the writing.

Returns

Delegate to be used in functions where it is required.

Return type

Callable[[maxon.Url, maxon.StoreAssetStruct, maxon.ResolveAssetDependenciesStruct], maxon.Id]

static AssetCreationInterface.GetDefaultObject(asset, doc=None)

Returns a new default object for the given preset.

Only next calls are allowed:
Parameters
Returns

New BaseList2D to insert.

Return type

c4d.BaseList2D

static AssetCreationInterface.GetDefaultSettings(asset, resId, resData)

Loads the settings for a preset

Parameters
Returns

True means a partial preset was loaded.

Return type

bool

static AssetCreationInterface.GetNewAssetIdFromIdAndVersion(prefix, idAndVersion)

GetNewAssetIdFromIdAndVersion generates a standarized id from the given prefix and IdAndVersion for a new asset.

Parameters
  • prefix (str) – Prefix can be used for the type of the asset. e.g. “file” for file assets. preset for “presets”.

  • idAndVersion (maxon.Tuple [maxon.Id, maxon.Id]) – IdAndVersion of the asset to be created.

Returns

Id on success.

Return type

maxon.Id

static AssetCreationInterface.OpenSaveAssetDialog(flags, presetTypeName, id, name, version, lookupRepository, category, selectedRepository, setAsDefault)

Opens the save asset dialog.

Parameters
  • flags (maxon.OPENSAVEASSETDIALOGFLAGS) – see OPENSAVEASSETDIALOGFLAGS.

  • presetTypeName (str) – Asset Type name to create the dialog title.

  • id (maxon.Id) – Id of the asset.

  • name (str) – Asset name.

  • version (str) – Version string.

  • lookupRepository (maxon.AssetRepositoryRef) – Repository to search for assets.

  • category (maxon.Id) – Category in which the asset should be stored.

  • selectedRepository (maxon.AssetRepositoryRef) – Selected repository where the asset should be stored.

  • setAsDefault (bool) – True to set the preset as default.

Returns

True on success and dialog okay. False if user canceled.

Return type

bool

static AssetCreationInterface.RenderDocumentAsset(renderDoc, progressRef, progressIndex, polygonCount, previewW, previewH, flags)

Helper function to render a BaseDocument for preview rendering.

Parameters
  • renderDoc (c4d.documents.BaseDocument) – BaseDocument to render.

  • progressRef (maxon.MediaSessionProgressRef) – progress class.

  • progressIndex (int) – progress index to use.

  • polygonCount (int) – Number of polygons in the scene. If -1 the count will be calculated. If the count == 0 and the scene has one first object the icon of the object is used as preview.

  • previewW (int) – Preview width.

  • previewH (int) – Preview height.

  • flags (maxon.GENERATESCENEPREVIEWIMAGEFLAGS) – see GENERATESCENEPREVIEWIMAGEFLAGS.

Returns

Url of the rendered memory file.

Return type

maxon.Url

static AssetCreationInterface.SaveActiveDocumentAsNewVersion(activeDoc, addAssetsIfNotInThisRepository)

Writes the current BaseDocument as new version with asset dialog.

Parameters
  • activeDoc (c4d.documents.BaseDocument) – BaseDocument to store.

  • addAssetsIfNotInThisRepository (bool) – True to store the asset in the given saveRepository even if it’s already in any other repository. False would skip the writing.

Returns

The created AssetDescription.

Return type

maxon.AssetDescription

static AssetCreationInterface.SaveBaseDocumentAsAsset(doc, c4dRootPath, saveFileName, addDependencyStruct, resolveAssets, metaProperties, calcBoundingBox, objectMatrix, subType)

Stores the given BaseDocument as a new scene to be saved as an asset. Dependencies will be calculated as well.

Parameters
Returns

True on success.

Return type

bool

static AssetCreationInterface.SaveBrowserPreset(assetType, sourceData, presetTypeName, presetNameA, showMakeDefault, setAsDefault, allowSceneRepository)

Stores the given data as preset asset.

Parameters
  • assetType (maxon.BasePresetAssetType) – PresetType.

  • sourceData (maxon.PresetSaveArgs) – Data to store.

  • presetTypeName (str) – Present Type name to generate the dialog title for.

  • presetNameA (str) – Name of the Preset.

  • showMakeDefault (bool) – True to enable the “Make as default” checkbox in the dialog.

  • setAsDefault (bool) – True to make it the default.

  • allowSceneRepository (bool) – True to allow to store the preset into the scene repository.

Returns

AssetDescription of the newly created asset on success.

Return type

maxon.AssetDescription

static AssetCreationInterface.SaveDefaultPresetFromObject(l, makeDefault, allowMakeDefault=True)

Stores the default from the given object into the asset browser.

Parameters
  • l (c4d.GeListNode) – Object to store.

  • makeDefault (bool) – True to make it the default.

  • allowMakeDefault (bool) – True to enable the “Make as default” checkbox in the dialog.

static AssetCreationInterface.SaveDocumentAsset(assetDoc, subType, newAssetId, storeAssetStruct, assetName, versionString, createPreviewBitmapDelegate, copyMetaData, addAssetsIfNotInThisRepository)

Stores the given BaseDocument into the given repository.

Parameters
  • assetDoc (c4d.documents.BaseDocument) – BaseDocument to store.

  • subType (maxon.InternedId) – Optional value to set the subType of the asset.

  • newAssetId (maxon.Id) – Optional asset Id. If empty the system calculates a new asset id.

  • storeAssetStruct (maxon.StoreAssetStruct) – Settings where to store the asset.

  • assetName (str) – User readable name of the asset.

  • versionString (str) – User readable version string.

  • createPreviewBitmapDelegate (Callable[[], c4d.BaseBitmap]) – Optional delegate to generate a preview preview bitmap when saving the asset.

  • copyMetaData (maxon.AssetMetaData) – Optional meta data to copy from another version.

  • addAssetsIfNotInThisRepository (bool) – True to store the asset in the given saveRepository even if it’s already in any other repository. False would skip the writing.

Returns

AssetDescription of the new asset on success.

Return type

maxon.AssetDescription

static AssetCreationInterface.SaveMemFileAsAsset(saveFileName, parentCategory, subType, calculateMetaData, metaProperties, dependencies, previews, animFps, assetName, localizedNames, localizedAnnotations, copyMetaData)

Stores the given url as a asset into a temporary repository.

Parameters
  • saveFileName (maxon.Url) – Url of the asset to be stored.

  • parentCategory (maxon.Id) – Parent category in which the asset should be saved.

  • subType (maxon.InternedId) – SubType of the asset, e.g. maxon.ASSETMETADATA.SubType_ENUM_Object.

  • calculateMetaData (bool) – True to automatically calculate meta data when saving.

  • metaProperties (maxon.DataDictionary) – Additional metadata to store.

  • dependencies (tuple[AssetDependencyStruct]) – Dependencies to store with the asset.

  • previews (maxon.BaseArray [maxon.Url]) – Array images of Previews. If you pass more then one image it will be stored as animated mp4 with the given animFps frame rate.

  • animFps (float) – If more than one image was given the preview will be stored as mp4 wih this frame rate.

  • assetName (str) – User readable name of the asset.

  • localizedNames (tuple[ Id, String]) – Optional translated names of the asset in other languages. Id is the languageid from LanguageInterface.

  • localizedAnnotations (tuple[ Id, String]) – Optional translated descriptions of the asset in other languages. Id is the languageid from LanguageInterface.

  • copyMetaData (maxon.AssetMetaData) – Metadata to copy.

Returns

AssetDescription of the new asset. UpdatableAssetRepositoryRef is a new temporary repository from which the asset can be moved into the target repository.

Return type

maxon.Tuple [maxon.AssetDescription, bool]

static AssetCreationInterface.SaveMemFileAsAssetAlone(saveFileName, copyMetaData)

Stores the plain file into a temporary repository.

Parameters
Returns

AssetDescription of the new asset. UpdatableAssetRepositoryRef is a new temporary repository from which the asset can be moved into the target repository.

Return type

maxon.Tuple [maxon.AssetDescription, maxon.UpdatableAssetRepositoryRef]

static AssetCreationInterface.SaveMemFileAsAssetWithCopyAsset(depResultUrl, storeAssetStruct, subType, dependencies, assetName, addAssetsIfNotInThisRepository)

Stores the given url as a asset.

Parameters
Returns

Tuple[ maxon.AssetDescription, bool]

Return type

AssetDescription contains the new asset description, Bool is true if the asset is a new asset. False if the asset already existed.

static AssetCreationInterface.SaveMetaDataForAsset(asset, parentCategory, subType, calculateMetaData, metaProperties, dependencies, previews, animFps, assetName, localizedNames, localizedAnnotations)

Stores he given values into the asset description.

Parameters
  • asset (maxon.AssetDescription) – Asset to be modified.

  • parentCategory (maxon.Id) – Parent category in which the asset should be saved.

  • subType (maxon.InternedId) – SubType of the asset, e.g. maxon.ASSETMETADATA.SubType_ENUM_Object.

  • calculateMetaData (bool) – True to automatically calculate meta data when saving.

  • metaProperties (maxon.DataDictionary) – Additional metadata to store.

  • dependencies (tuple[AssetDependencyStruct]) – Dependencies to store with the asset.

  • previews (maxon.BaseArray [maxon.Url]) – Array images of Previews. If you pass more then one image it will be stored as animated mp4 with the given animFps frame rate.

  • animFps (float) – If more than one image was given the preview will be stored as mp4 wih this frame rate.

  • assetName (str) – User readable name of the asset.

  • localizedNames (tuple[ Id, String]) – Optional translated names of the asset in other languages. Id is the languageid from LanguageInterface.

  • localizedAnnotations (tuple[ Id, String]) – Optional translated descriptions of the asset in other languages. Id is the languageid from LanguageInterface.

Returns

AssetDescription of the new asset. UpdatableAssetRepositoryRef is a new temporary repository from which the asset can be moved into the target repository.

Return type

maxon.Tuple [maxon.AssetDescription, bool]

static AssetCreationInterface.SaveTextureAsset(imageUrl, assetName, storeAssetStruct, dependencies, addAssetsIfNotInThisRepository)

Stores the given image as media asset.

Parameters
  • imageUrl (maxon.Url) – Url of the texture to store.

  • assetName (str) – Human readable asset name.

  • storeAssetStruct (maxon.StoreAssetStruct) – Settings where to store the asset.

  • dependencies (Tuple[ maxon.AssetDependencyStruct]) – Optional dependencies to store along with the asset.

  • addAssetsIfNotInThisRepository (bool) – True to store the asset in the given saveRepository even if it’s already in any other repository. False would skip the writing.

Returns

AssetDescription of the new asset. Bool is True if the asset was saved. False if it was already in the repository.
In that case the maxon.AssetDescription is the one of the existing asset.

Return type

Tuple[maxon.AssetDescription, bool]

static AssetCreationInterface.SetDefaultObject(defaultsType, partial, bc, setAsDefault, allowMakeDefault)
Parameters
  • defaultsType (maxon.Block [int]) – Ids of the BaseObject. e.g. Ocube

  • partial (bool) – True to signal that this preset contains only partial settings.

  • bc (c4d.BaseContainer) – BaseContainer with the settings.

  • setAsDefault (bool) – True to make this preset the default when creating new objects.

  • allowMakeDefault (bool) – True to enable the “Make as default” checkbox in the dialog.

Returns

True on success.

Return type

bool

static AssetCreationInterface.SupportDefaultPresets(l)

Helper function to find if the given type supports the preset system.

Parameters

l (c4d.C4DAtom) – Object to check

Returns

Tuple<Bool, Bool>: first - support presets, second - support set as default

Return type

maxon.Tuple [bool, bool]

static AssetCreationInterface.UpdateMetaData(doc, metaProperties=None, calcBoundingBox=None, objectMatrix=None, subType=None)

UpdateMetaData recalculates the asset metadata.

For scene files this might be the number of points, polygons. etc. for images the size, bitdepth etc.
Only next calls are allowed:
Parameters