RetainMaterialAuthoringFiles job
Parameters
| job - material-authoring handle whose job has succeeded |
Description
|
Keeps a finished job's generated files when the job is released. Call it after a successful publication, then call FreeMaterialAuthoring. Do not retain cancelled or discarded drafts. A staging journal protects committed files during later recovery. For the request and result fields, see the material authoring API guide. Requires Extended mode. See also: FreeMaterialAuthoring, MaterialAuthoringResult, BeginMaterialAuthoring. |
Example
; BeginMaterialAuthoring Example ; ------------------------------ ; Requires Extended mode. ; Material authoring runs as a background job, so a tool stays responsive. ; This one inspects the materials authored inside the Fox glTF model. model$=CurrentDir()+"../../../samples/glTF/assets/Fox/Fox.gltf" job=StartAnalysis(model$) ; Poll the job; the state never blocks on decoding or copying While MaterialAuthoringState(job)<3 Delay 10 Wend If MaterialAuthoringState(job)=3 result=MaterialAuthoringResult(job) materials=JsonObjectGet(result,"materials") Print "MaterialAuthoringState: 3 (succeeded)" Print "Fox.gltf authors "+JsonCount(materials)+" material(s):" For i=0 To JsonCount(materials)-1 material=JsonArrayGet(materials,i) name=JsonObjectGet(material,"name") Print " "+i+": "+JsonText(name) FreeJson name FreeJson material Next FreeJson materials FreeJson result ; This analysis generated no files, so retaining is a no-op here; after a ; portable publication it keeps the published textures when the job is freed RetainMaterialAuthoringFiles job Else Print "Analysis failed: "+MaterialAuthoringError(job) EndIf FreeMaterialAuthoring job ; A missing model fails, and the job explains why job=StartAnalysis(CurrentDir()+"no_such_model.gltf") While MaterialAuthoringState(job)<3 Delay 10 Wend Print "" Print "Analysing a missing file ends in state "+MaterialAuthoringState(job) Print " MaterialAuthoringError: "+MaterialAuthoringError(job) FreeMaterialAuthoring job Print "" Print "Press any key to close the example" WaitKey End ; Start an analyzeModel job for one model file Function StartAnalysis(path$) request=CreateJsonObject() operation=CreateJsonString("analyzeModel") JsonObjectSet request,"operation",operation FreeJson operation file=CreateJsonString(path) JsonObjectSet request,"path",file FreeJson file job=BeginMaterialAuthoring(request) ; The service copies the request, so it can be freed straight away FreeJson request Return job End Function
Index