0

I am trying to add a design automation job to my application for Revit. After starting the design automation job I have received an Non-optional output [outputFile.rvt] is missing error. I can't find the errors in my code.

I have used this example, which works correctly.

This is my response-text

[05/24/2021 12:03:12] Job information:
"CommandLine":[
  "$(engine.path)\\revitcoreconsole.exe /i \"$(args[inputFile].path)\" /al \"$(appbundles[DeleteWallsAppAppBundle].path)\""
]
"Settings":{
  "script": {
    "value": ""
  },
  "dasreportfaileduploadoptional": {
    "value": "true",
    "isEnvironmentVariable": true
  }
}
"Id":"7d8851ec5bf540f090a54518bc85a1dd"
"ActivityId":"YS2SlY5WjJA11j3rEvG7m4s21ZkHjuYE.DeleteWallsAppActivity+dev"
"Engine.Id":"Autodesk.Revit!59"
"Apps": [
"App.Id":"YS2SlY5WjJA11j3rEvG7m4s21ZkHjuYE.DeleteWallsAppAppBundle!1"
]
"BoundArguments":{
  "inputFile": {
    "localName": "$(inputFile)",
    "url": "https://developer.api.autodesk.com/Masked:QikaKzmvbD28ySja/SiTmz28U0g=",
    "headers": {
      "Authorization": "Masked:Rw57GopadZ2RTlAiuPfjFJPr8h4="
    }
  },
  "outputFile": {
    "localName": "outputFile.rvt",
    "url": "https://developer.api.autodesk.com/Masked:gjEwaOnEvzpK7SIlNBB/AfDahu4=",
    "headers": {
      "Authorization": "Masked:Rw57GopadZ2RTlAiuPfjFJPr8h4=",
      "Content-type": "application/octet-stream"
    },
    "verb": "put"
  },
  "onComplete": {
    "ondemand": true,
    "optional": true,
    "url": "http://00413b440a0e.ngrok.io/Masked:36tqqkWUBakA7jyvfmxIyTRg+Do=",
    "verb": "post"
  },
  "onProgress": {
    "ondemand": true,
    "url": "https://wlnr5sjl3a.execute-api.us-east-1.amazonaws.com/Masked:UK/Z3b5X3xUWxXiH6C9r9i9UlRU=",
    "headers": {
      "Content-Type": "application/json",
      "x-das-authorize": "awssigv4(us-east-1)",
      "x-ads-token-data": "{\"access_token\":{\"client_id\":\"YS2SlY5WjJA11j3rEvG7m4s21ZkHjuYE\"},\"scope\":\"bucket:create bucket:read bucket:delete data:read data:create data:write code:all\",\"expires_in\":3576,\"client_id\":\"YS2SlY5WjJA11j3rEvG7m4s21ZkHjuYE\"}"
    },
    "verb": "put"
  }
}
"Quotas":{
  "limitProcessingTimeSec": 10800,
  "limitTotalUncompressedAppsSizeInMB": 5000
}
[05/24/2021 12:03:12] Starting work item 7d8851ec5bf540f090a54518bc85a1dd
[05/24/2021 12:03:12] Start download phase.
[05/24/2021 12:03:12] Start downloading input: verb - 'GET', url - 'https://developer.api.autodesk.com/oss/v2/buckets/ys2sly5wjja11j3revg7m4s21zkhjuye-designautomation/objects/20210524120300_input_7_floor_building.rvt'
[05/24/2021 12:03:14] End downloading file from 'https://developer.api.autodesk.com/oss/v2/buckets/ys2sly5wjja11j3revg7m4s21zkhjuye-designautomation/objects/20210524120300_input_7_floor_building.rvt'.
[05/24/2021 12:03:14] End download phase successfully.
[05/24/2021 12:03:14] Start preparing script and command line parameters.
[05/24/2021 12:03:14] Command line: [ /i "T:\Aces\Jobs\7d8851ec5bf540f090a54518bc85a1dd\20210524120300_input_7_floor_building.rvt" /al "T:\Aces\Applications\03bf1602bcbde6ea600ca74c35a7f5ae.YS2SlY5WjJA11j3rEvG7m4s21ZkHjuYE.DeleteWallsAppAppBundle[1].package"]
[05/24/2021 12:03:14] End preparing script and command line parameters.
[05/24/2021 12:03:14] Start script phase.
[05/24/2021 12:03:14] ### Command line arguments: /isolate HKEY_CURRENT_USER\SOFTWARE\AppDataLow\Software\Autodesk\CoreUser\WorkItem_7d8851ec5bf540f090a54518bc85a1dd "T:\Aces\Jobs\7d8851ec5bf540f090a54518bc85a1dd\userdata" /exe "T:\Aces\AcesRoot\21.0\coreEngine\Exe\revitcoreconsole.exe"  /i "T:\Aces\Jobs\7d8851ec5bf540f090a54518bc85a1dd\20210524120300_input_7_floor_building.rvt" /al "T:\Aces\Applications\03bf1602bcbde6ea600ca74c35a7f5ae.YS2SlY5WjJA11j3rEvG7m4s21ZkHjuYE.DeleteWallsAppAppBundle[1].package".
[05/24/2021 12:03:14] Start Revit Core Engine standard output dump.
[05/24/2021 12:03:14] Running in unattended mode.
[05/24/2021 12:03:14] ====== Revit is running: revitcoreconsole ======
[05/24/2021 12:03:14] Current Exe path: T:\Aces\AcesRoot\21.0\coreEngine\Exe\revitcoreconsole.exe
[05/24/2021 12:03:14] Echoing command line args:
[05/24/2021 12:03:14]   0:/i
[05/24/2021 12:03:14]   1:T:\Aces\Jobs\7d8851ec5bf540f090a54518bc85a1dd\20210524120300_input_7_floor_building.rvt
[05/24/2021 12:03:14]   2:/al
[05/24/2021 12:03:14]   3:T:\Aces\Applications\03bf1602bcbde6ea600ca74c35a7f5ae.YS2SlY5WjJA11j3rEvG7m4s21ZkHjuYE.DeleteWallsAppAppBundle[1].package
[05/24/2021 12:03:14]   4:/isolate
[05/24/2021 12:03:14]   5:HKEY_CURRENT_USER\SOFTWARE\AppDataLow\Software\Autodesk\CoreUser\WorkItem_7d8851ec5bf540f090a54518bc85a1dd
[05/24/2021 12:03:14]   6:T:\Aces\Jobs\7d8851ec5bf540f090a54518bc85a1dd\userdata
[05/24/2021 12:03:14] Running RevitAssemblyResolver....
[05/24/2021 12:03:14] Initializing RevitCoreEngine...
[05/24/2021 12:03:14] Selected Revit\RCE install Path: (from app.config) C:\Revit2021
[05/24/2021 12:03:14] Resolving location of Revit/RevitCoreEngine installation...
[05/24/2021 12:03:14] Running user application....
[05/24/2021 12:03:18] Found an addIn for registration: DeleteWalls.addin
[05/24/2021 12:03:18] Initializing RCE....
[05/24/2021 12:03:18] Initializing RevitCoreEngine (and possibly running stub installer)...
[05/24/2021 12:03:18] Language not specified, using English-United States(ENU) as default.
[05/24/2021 12:03:21] Initialize and  get RCE: (VersionBuild) 21.1.30.74 (VersionNumber) 2021 (SubVersionNumber) 2021.2
[05/24/2021 12:03:46] Finished running.  Process will return: Success
[05/24/2021 12:03:46] ====== Revit finished running: revitcoreconsole ======
[05/24/2021 12:03:47] End Revit Core Engine standard output dump.
[05/24/2021 12:03:47] End script phase.
[05/24/2021 12:03:47] Start upload phase.
[05/24/2021 12:03:47] Error: Non-optional output [outputFile.rvt] is missing.
[05/24/2021 12:03:48] Error: An unexpected error happened during phase Publishing of job.
[05/24/2021 12:03:48] Job finished with result FailedMissingOutput
[05/24/2021 12:03:48] Job Status:
{
  "status": "failedInstructions",
  "reportUrl": "https://dasprod-store.s3.amazonaws.com/workItem/YS2SlY5WjJA11j3rEvG7m4s21ZkHjuYE/7d8851ec5bf540f090a54518bc85a1dd/report.txt?AWSAccessKeyId=ASIATGVJZKM3IPRPZPPA&Expires=1621906385&x-amz-security-token=IQoJb3JpZ2luX2VjEFMaCXVzLWVhc3QtMSJGMEQCIFlLs8hzUD9ZqlPdgHg7L2HiZ%2FZOZAU0FJXfV%2Bq97Qk2AiAHOeQdhTmF2QygtyLlUd%2BE7mNB%2BYRmWQWOjQfHw5gFPireAQjr%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F8BEAIaDDIyMDQ3MzE1MjMxMCIMaF9CU%2Bj%2FlVOjJbcHKrIBWCiMUrqwOqwGNadD%2BBSILkwA2ZPnD8yrBg2sKpVaxcyOU8NVt0FWVlJmFsRZJ4%2BySrux1Sno%2F2MJdRBb96oMMvdKjyzlxhwHzMk7xqgSfKkHiJLPZh36hZt3Y69JxP8yCQ1LP8BDK14uLZK9%2FsMpHxN%2Fw03gl%2Bg14yrneys0ISJIMZGMMBAwF3mwrChQnRSzQCcWVQqVNFGFXj2PNdOf04hM0IsWtqdQzKNc1%2Fd4cVaOfjCq%2BK2FBjrhAZQnryz0FM0GDZrqYLbXMk4Q0sFYSzqc8tnkn9Zy6RSry4AJYl36OlxO7OobdrsJhR7lwCTm%2Fgb07RXo1Cw%2FDkqFOLxwy%2BvEILWdhyDA5%2Bxw7CuFbBZ1iGt7HyK7rdvCgEfSsgakE1e0wPfvtgV8ps2bKsyjti4uELuSDoR%2FI1xQpqS2Hxkx08CyNVsZqhGsINfVZmkt3fS9d7wkGj297ZE9EeQ5C9917EsjHNXw1ah7VBPDb7aJcYG7vq8S0WDFap6BaR7x%2F6%2FVsDMjcNcVbfrvSm7u8NbaTRVnnL8wt7O4kg%3D%3D&Signature=ZJujk5VQJinDZPawpmjESAFgygI%3D",
  "stats": {
    "timeQueued": "2021-05-24T12:03:04.523504Z",
    "timeDownloadStarted": "2021-05-24T12:03:12.8872971Z",
    "timeInstructionsStarted": "2021-05-24T12:03:14.6626201Z",
    "timeInstructionsEnded": "2021-05-24T12:03:47.9975457Z",
    "timeUploadEnded": "2021-05-24T12:03:47.9986029Z",
    "bytesDownloaded": 5931008
  },
  "id": "7d8851ec5bf540f090a54518bc85a1dd"
}

and my code which starts the work item

const start_workItem = async (req, res) => {
  const input = req.body;
  // basic input validation
  const workItemData = JSON.parse(input.data);
  // const widthParam = parseFloat(workItemData.width);
  // const heigthParam = parseFloat(workItemData.height);
  const activityName = `${Utils.NickName}.${workItemData.activityName}`;
  const browerConnectionId = workItemData.browerConnectionId;

  // save the file on the server
  const ContentRootPath = _path.resolve(_path.join(__dirname, "../../../.."));
  const fileSavePath = _path.join(
    ContentRootPath,
    _path.basename(req.files.file.name),
  );
  //const stream = _fs.createReasStream(fileSavePath, FileMode.Create)) await input.inputFile.CopyToAsync(stream);

  // upload file to OSS Bucket
  // 1. ensure bucket existis
  const bucketKey = Utils.NickName.toLowerCase() + "-designautomation";
  try {
    let payload = new ForgeAPI.PostBucketsPayload();
    payload.bucketKey = bucketKey;
    payload.policyKey = "transient"; // expires in 24h
    await new ForgeAPI.BucketsApi().createBucket(
      payload,
      {},
      req.oauth_client,
      req.oauth_token,
    );
  } catch (ex) {
    // in case bucket already exists
  }
  // 2. upload inputFile
  const inputFileNameOSS = `${new Date()
    .toISOString()
    .replace(/[-T:\.Z]/gm, "")
    .substring(0, 14)}_input_${_path.basename(req.files.file.name)}`; // avoid overriding

  try {
    let contentStream = _fs.createReadStream(req.files.file.tempFilePath);
    await new ForgeAPI.ObjectsApi().uploadObject(
      bucketKey,
      inputFileNameOSS,
      req.files.file.size,
      contentStream,
      {},
      req.oauth_client,
      req.oauth_token,
    );
  } catch (ex) {
    console.error(ex);
    return res.status(500).json({
      diagnostic: "Failed to upload file for workitem",
    });
  }

  // prepare workitem arguments
  // 1. input file
  const inputFileArgument = {
    url: `https://developer.api.autodesk.com/oss/v2/buckets/${bucketKey}/objects/${inputFileNameOSS}`,
    headers: {
      Authorization: `Bearer ${req.oauth_token.access_token}`,
    },
  };
  // 2. input json
  // const inputJson = {
  //   width: widthParam,
  //   height: heigthParam,
  // };
  // const inputJsonArgument = {
  //   url:
  //     "data:application/json, " + JSON.stringify(inputJson).replace(/"/g, "'"),
  // };

  // Better to use a presigned url to avoid the token to expire
  const outputFileNameOSS = `${new Date()
    .toISOString()
    .replace(/[-T:\.Z]/gm, "")
    .substring(0, 14)}_output_${_path.basename(req.files.file.name)}`; // avoid overriding
  let signedUrl = null;
  try {
    // write signed resource requires the object to already exist :(
    await new ForgeAPI.ObjectsApi().copyTo(
      bucketKey,
      inputFileNameOSS,
      outputFileNameOSS,
      req.oauth_client,
      req.oauth_token,
    );
    signedUrl = await new ForgeAPI.ObjectsApi().createSignedResource(
      bucketKey,
      outputFileNameOSS,
      {
        minutesExpiration: 60,
        singleUse: true,
      },
      {
        access: "write",
      },
      req.oauth_client,
      req.oauth_token,
    );
    signedUrl = signedUrl.body.signedUrl;
  } catch (ex) {
    console.error(ex);
    return res.status(500).json({
      diagnostic: "Failed to create a signed URL for output file",
    });
  }

  const outputFileArgument = {
    url: signedUrl,
    headers: {
      Authorization: `Bearer ${req.oauth_token.access_token}`,
      "Content-type": "application/octet-stream",
    },
    verb: dav3.Verb.put,
  };

  // prepare & submit workitem
  // the callback contains the connectionId (used to identify the client) and the outputFileName of this workitem
  const callbackUrl = `${config.credentials.webhook_url}/api/forge/callback/designautomation?id=${browerConnectionId}&outputFileName=${outputFileNameOSS}&inputFileName=${inputFileNameOSS}`;
  const workItemSpec = {
    activityId: activityName,
    arguments: {
      inputFile: inputFileArgument,
      // inputJson: inputJsonArgument,
      outputFile: outputFileArgument,
      onComplete: {
        verb: dav3.Verb.post,
        url: callbackUrl,
      },
    },
  };
  let workItemStatus = null;
  const api = await Utils.dav3API(req.oauth_token);
  try {
    workItem = await api.createWorkItem(workItemSpec);
    workItemStatus = await api.getWorkitemStatus(workItem.id);
  } catch (ex) {
    console.error(ex);
    return res.status(500).json({
      diagnostic: "Failed to create a workitem",
    });
  }

  res.status(200).json({
    workItemId: workItemStatus.id,
  });
};

Also, I have received the following error in the node.js console

enter image description here

Is someone familiar with this issue?

Hovo216
  • 39
  • 9
  • Does the addin code explicitly save the result to be outputFile.rvt? The name of output is defined by "localName": "outputFile.rvt" in the activity, it seems Design Automation job tried to find it, but cannot. – Emma Zhu May 25 '21 at 13:44
  • I have tried to run addin in working example and it works correctly. – Hovo216 May 25 '21 at 13:58
  • 1
    If you look at the report, the addin can run correctly on Design Automation. The workitem failed because a file named as `outputFile.rvt` cannot be found. That is why you may check if the addin indeed generates `outputFile.rvt` as the output – Emma Zhu May 25 '21 at 15:30
  • Yes, you are right. Thank You for your help. – Hovo216 May 26 '21 at 08:50

0 Answers0