Is there an option for translate to SVF viewer using Design Automation API - autodesk-forge

Im just looking if is possible to create an SVF Viewer using Design Automation API and avoiding Model Derivative API.
Months ago I had a talk with the Forge support team and they told me that due to the amount of translates, for an economic issue it was convenient for me to use Design Automation.
Thanks in advance

Unfortunately, SVF translation on Design Automation API is not supported currently as I was told, except for AutoCAD. You may use this activity to generate SVF with the Design Automation API for AutoCAD:
{
"commandLine": [
"$(engine.path)\\accoreconsole.exe /i $(args[HostDwg].path) /al $(appbundles[Publish2View22].path) /s $(settings[script].path) /suppressGraphics"
],
"parameters": {
"HostDwg": {
"verb": "get",
"description": "Host drawing",
"required": true,
"localName": "$(HostDwg)"
},
"Result": {
"zip": true,
"verb": "post",
"description": "Results",
"required": true,
"localName": "result"
}
},
"id": "AutoCAD.AcSvfPublish+prod",
"engine": "Autodesk.AutoCAD+22",
"appbundles": [
"AutoCAD.Publish2View22+prod"
],
"settings": {
"script": {
"value": "(command \"_prepareforpropertyextraction\" \"index.json\")\n(command \"_indexextractor\" \"index.json\")\n(command \"_publishtosvf\" \"./output/result.svf\")\n(command \"_createbubblepackage\" \"./output\" \"./result\" \"\" \"\")\n"
}
},
"description": "AutoCAD translation sample generating SVF via core console.",
"version": 4
}

The 3ds Max engine also support generating svf file(s). You should be able to easily write a script to export to svf and execute it in Design Automation.
See this documentation on how to export in maxscript:
https://help.autodesk.com/view/3DSMAX/2020/ENU/?guid=GUID-624D3D05-B15D-4A97-9F15-DA35CDB0DDD2#GUID-624D3D05-B15D-4A97-9F15-DA35CDB0DDD2__SECTION_EB566E2CC6444FCEAD2EE67BB366F727
See this tutorial on how to execute a script in Design Automation for 3ds Max:
https://forge.autodesk.com/en/docs/design-automation/v3/tutorials/3dsmax/

Related

Create new dwg file and load existing dwg model in it using Autodesk Design Automation API for AutoCAD

How to programmatically create a new DWG file and load an existing DWG model into it using Autodesk Design Automation API for AutoCAD?
I am working on a project that requires me to automate the process of creating a new DWG file in AutoCAD and then load an existing DWG model into it using Autodesk Design Automation API. The goal is to automate the entire process without any manual intervention.
I am facing some difficulties in implementing the steps required to create a new DWG file and load an existing DWG model into it.
Can anyone provide a sample code or a detailed step-by-step explanation of how to programmatically create a new DWG file and load an existing DWG model into it using Autodesk Design Automation API for AutoCAD 2022? It would be great if the solution includes the necessary methods and properties to be used from the Autodesk Design Automation API.
I would highly appreciate any help or guidance in this matter.
input model dwg file
We have this ball valve model as input , we want to create a new dwg file add page border and load this existing dwg model inside page border using design automation api.
Expected Output :
expected output dwg file
I would encourage you to go through this tutorial https://tutorials.autodesk.io/tutorials/design-automation/, your objective should possible, you need to launch accoreconsole instance with your border drawing and insert the block from other drawing.
You can wrap the logic of importing blocks from external drawing in custom command .
Refer https://through-the-interface.typepad.com/through_the_interface/2006/08/import_blocks_f.html
Below is an example activty that importas "Microwave" block from "blocks.dwg" and inserts in "border.dwg"
Activity:
{
"id": "{{ _.activityId }}",
"commandLine": [
"$(engine.path)\\accoreconsole.exe \"$(args[main].path)\" /s $(settings[script].path)"
],
"parameters": {
"main": {
"verb": "get",
"description": "Main drawing to be loaded into AutoCAD.",
"required": true,
"localName": "border.dwg"
},
"blocks": {
"verb": "get",
"description": "The drawing which contains the blocks",
"required": true,
"localName": "blocks.dwg"
},
"BlockName": {
"verb": "read",
"description": "The block name to insert.",
"required": true
},
"BlockPosition": {
"verb": "read",
"description": "The position to insert block"
},
"ScaleX": {
"verb": "read",
"description": "The X scale factor",
"required": true
},
"ScaleY": {
"verb": "read",
"description": "The Y scale factor",
"required": true
},
"Rotation": {
"verb": "read",
"description": "The rotation angle of block",
"required": true
},
"result": {
"verb": "put",
"description": "",
"required": true,
"localName": "result.dwg"
}
},
"engine": "Autodesk.AutoCAD+23_1",
"description": "blah",
"settings": {
"script": "ImportBlocks\n"$(args[BlockName].value)\"\n\"$(args[BlockPosition].value)\"\n\"$(args[ScaleX].value)\"\n\"$(args[ScaleX].value)\"\n\"$(args[ScaleY].value)\"\n\"$(args[Rotation].value)\"\n_SAVEAS\n2018\nresult.dwg\n"
}
}
Workitem
{
"activityId": "{{ _.nickName }}.{{ _.activityId }}+{{ _.alias }}",
"arguments": {
"main": {
"verb": "get",
"url": "urn:adsk.objects:os.object:madlybuckets/main.dwg",
"headers": {
"Authorization": "Bearer {{ _.oAuthToken }}"
}
},
"blocks": {
"verb": "get",
"url": "urn:adsk.objects:os.object:madlybuckets/blocks.dwg",
"headers": {
"Authorization": "Bearer {{ _.oAuthToken }}"
}
},
"BlockName": "Microwave",
"BlockPosition": "198.241 162.455 0.0",
"ScaleX": "1.0",
"ScaleY": "1.0",
"Rotation": "0.0",
"result": {
"verb": "put",
"url": "urn:adsk.objects:os.object:madlybuckets/result.dwg",
"headers": {
"Authorization": "Bearer {{ _.oAuthToken }}"
}
}
}
}
}

Autodesk Forge import IFC failed

our customer try to show IFC model through method https://developer.api.autodesk.com/oss/v2/buckets/bucket_name/objects/model_name. IFC model is huge, about 100km, it is road design. He can't show it in Forge, he got error that model is empty, although it has 120MB. Model is in IFC4. Has You any documentation to supported IFC classes, or model size to show in FOrge ? He try to divide model to smaller parts, but nothing happen.
Milan Nemec, Graitec
A few things to check:
Did you call the conversion job to translate the IFCs to SVF first? Using this endpoint here?
Is the conversion completed? Try here to query the progress.
And if everything works out the manifest response should contain SVF derivatives similar to:
{
"type": "manifest",
"hasThumbnail": "true",
"status": "success",
"progress": "complete",
"region": "US",
EDIT
For IFC models exported from Revit try switch to the IFC loader by specifying in your job payload:
{
"input": {
"urn": "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2JzYjIzMzMvc2JiLmlmYw"
},
"output": {
"formats": [
{
"type": "svf",
"views": ["3d", "2d"], "advanced": {
"switchLoader": true
}
}]

How to change the name of the input and output file dynamically in workitem method in design automation api for Revit

I am working on a project where I need to generate output Revit file based on the input json file in the Design automation API for Revit.
Since my input json string was large, I create a json file example "InputFile.json" and upload it to the cloud and pass the signed url to it to the work item and activity as input parameter, the generated output is a zip file example "OutputFile.zip" which is again uploaded to the cloud using the signed url.
My project works properly using this process. But since the name used for the input and output files are fixed, I am facing issue when I send continuous request, I get mismatched output.
Activity request
..
"parameters": {
"Inputs": {
"zip": false,
"ondemand": false,
"verb": "get",
"description": "Element parameters",
"required": true,
"localName": "InputFile.json"
},
"Result": {
"zip": true,
"ondemand": false,
"verb": "put",
"description": "new created element",
"required": true,
"localName": "OutputFile"
}
},
...
and the WorkItem request
...
"arguments":{
"Inputs":{
"url":"https://storage.googleapis.com/XXXXXXX/InputFile.json?XXXXXXXXXXXXXXXsigned-url"
},
"Result":{
"verb":"put",
"url":"https://storage.googleapis.com/XXXXXXX/OutputFile.zip?XXXXXXXXXXXXXXXsigned-url",
...
How can I pass dynamically generated names like "InputFile_[DATE].json" and "OutputFile_[DATE].zip"?
Thanks in advance
Regards
You should be able to replace the localName value when submitting the workitem by adding the "localName" attribute to your argument.
Example:
"arguments":{
"Inputs":{
"url":"https://storage.googleapis.com/XXXXXXX/InputFile.json?XXXXXXXXXXXXXXXsigned-url"
},
"Result":{
"verb":"put",
"url":"https://storage.googleapis.com/XXXXXXX/OutputFile.zip?XXXXXXXXXXXXXXXsigned-url",
"localName": "myOutputFileName"
}
}

Access files located in the WIP folder of BIM360 Design (old C4R)

We have a requirement from one of our clients to access the project files that are stored in the BIM360 Design (old Collaboration for Revit - C4R). I can not find any information in the developer pages of the Forge APIs that points to this location. I assume such an API is not part of Forge, but we were wondering if there is any other API that can provide those files.
The exact requirements are:
Constantly monitor for changes on the files located there.
When changes occur, retrieve and backup all those files to a local machine.
The question is, how, if possible, can we access the project files located at the BIM360 Design cloud?
UPDATE (10/04/2018)
We have found these commands - specifically PublishModel and GetPublishModelJob. This does something, we can at the very least prompt the publication on demand, without the need for Revit. It is not clear to me when the items:autodesk.bim360:C4RModel pseudo-file is created. On top of that, the API does not appear to be able to receive a prefered output folder, which makes it really cumbersome to work for the intended purpose of backing up the information inside BIM360 Design.
UPDATE (25/04/2018)
We have tried using both commands (PublishJob and GetPublishModelJob). We have impersonated a Project Admin (via the x-user-id) but Forge is returning a 401 error (which is not even documented). The following (with a redacted documentID) is what we have tried:
{
"jsonapi": {
"version": "1.0"
},
"data": {
"type": "commands",
"attributes": {
"extension": {
"type": "commands:autodesk.bim360:C4RModelGetPublishJob",
"version": "1.0.0"
}
},
"relationships": {
"resources": {
"data": [ { "type": "items", "id": "<document_id>" } ]
}
}
}
}
And this is Forge's response:
{
"jsonapi": {
"version": "1.0"
},
"errors": [
{
"id": "a4547153-1fd4-4710-b0d1-a7184d9e7e22",
"status": "401",
"code": "C4R",
"detail": "Failed to get publish model job"
}
]
}
Any thoughts?
After discussing with #tfrascaroli in Forge Help channel, we found the root cause of this error is caused by the incorrect value of x-user-id, so he didn't have the right permission to push the latest version of the C4R model to BIM360 docs.
{
"jsonapi": {
"version": "1.0"
},
"errors": [
{
"id": "a4547153-1fd4-4710-b0d1-a7184d9e7e22",
"status": "401",
"code": "C4R",
"detail": "Failed to get publish model job"
}
]
}
The x-user-id is not a GUID and not the id we saw in the response of GET users or GET users/:user_id, it should be the value of the uid. After replacing the x-user-id value by the uid, the error doesn't show up again.
[
{
"id": "a75e8769-621e-40b6-a524-0cffdd2f784e", //!<<< We didn't use it for `x-user-id`
"account_id": "9dbb160e-b904-458b-bc5c-ed184687592d",
"status": "active",
"role": "account_admin",
"company_id": "28e4e819-8ab2-432c-b3fb-3a94b53a91cd",
"company_name": "Autodesk",
"last_sign_in": "2016-04-05T07:27:20.858Z",
"email": "john.smith#mail.com",
"name": "John Smith",
"nickname": "Johnny",
"first_name": "John",
"last_name": "Smith",
"uid": "L9EBJKCGCXBB", //!<<<<< Here is the value for the x-user-id
"image_url": "http://static-dc.autodesk.net/etc/designs/v201412151200/autodesk/adsk-design/images/autodesk_header_logo_140x23.png",
"address_line_1": "The Fifth Avenue",
"address_line_2": "#301",
"city": "New York",
"postal_code": "10011",
"state_or_province": "New York",
"country": "United States",
"phone": "(634)329-2353",
"company": "Autodesk",
"job_title": "Software Developer",
"industry": "IT",
"about_me": "Nothing here",
"created_at": "2015-06-26T14:47:39.458Z",
"updated_at": "2016-04-07T07:15:29.261Z"
}
]
Do you have an access right to the workshared Revit file? Publish command is to publish workshared central model in the cloud to Docs. To use it, you need an access to Revit model in the central in the cloud. Forge Publish command does the same thing as publish command in Revit desktop. You need the same access right. To use cloud workshared feature, first you need to have Design license assigned to you, then you also need to be a member a Revit project. Being invited to Docs is not enough.
(As C4R/Design was merged to Docs recently, this C4R specific license part was intentionally kept the same as previous licensing. We also have Team for earlier versions. It makes it a bit complicated. I hope it will be easier as we move forward in future.)

Defining query parameters for basic CRUD operations in Loopback

We are using Loopback successfully so far, but we want to add query params to our API documentation.
In our swagger.json file, we might have something that looks like =>
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "poc-discovery"
},
"basePath": "/api",
"paths": {
"/Users/{id}/accessTokens/{fk}": {
"get": {
"tags": [
"User"
],
"summary": "Find a related item by id for accessTokens.",
"operationId": "User.prototype.__findById__accessTokens",
"parameters": [
{
"name": "fk",
"in": "path",
"description": "Foreign key for accessTokens",
"required": true,
"type": "string",
"format": "JSON"
},
{
"name": "id",
"in": "path",
"description": "User id",
"required": true,
"type": "string",
"format": "JSON"
},
{
"name":"searchText",
"in":"query",
"description":"The Product that needs to be fetched",
"required":true,
"type":"string"
},
{
"name":"ctrCode",
"in":"query",
"description":"The Product locale needs to be fetched. Example=en-GB, fr-FR, etc.",
"required":true,
"type":"string"
},
],
I am 99% certain the swagger.json information gets generated dynamically via information from the .json files in the /server/models directory.
I am hoping that I can add the query params that we accept for each model in those .json files. What I want to avoid is having to modify swagger.json directly.
What is the best approach to add our query params so that they show up in our docs? Very confused as to how to best approach this.
After a few hours of tinkering, I'm afraid there is not a straight forward way to achieve this as the swagger spec generated here is representation of remoting metadata for model methods along with Model data from model.json files.
Thus, updating remoting metadata for built-in model methods would be challenging and it might not be fully supported by method implementations.
Right approach, IMO, here is to:
- create a remoteMethod wrapper around built-in method for which you want additional params to be injected with requried http mapping data.
- And, disable the REST end-point for the built-in method using
MyModel.disableRemoteMethod(<methodName>, <isStatic>).