Export multiple models to a single model file using Autoesk Forge API - autodesk-forge

I have loaded multiple Revit files in Autodesk Forge viewer. Now I want to export a single SVF or Revit file (Merged all model contents into a single file) from the viewer.
Could you please help me to solve above problem?

Sorry, the viewer is used to viewing models only. It doesn't have the capabilities of editing or generating models, unfortuantely. So, I'd advise you to do the following:
Open either of the Revit models with Revit Desktop or Design Automation API for Revit as the host model, and link others as linked RVTs.
Save the changes into the host RVT.
Package host and linked RVT files into a ZIP file.
Upload the ZIP to your OSS bucket
Submit a composite Revit file translation job with the below job configuration for example, or see See https://youtu.be/nfHZLlWtQ-0?t=114
curl --location --request POST 'https://developer.api.autodesk.com/modelderivative/v2/designdata/job' \
--header 'Authorization: Bearer \
--header 'Content-Type: application/json' \
--data-raw '{
"input": {
"urn": "{URN_OF_THE_ZIP}",
"compressedUrn": true,
"rootFilename": "host_rvt_filename.rvt"
},
"output": {
"formats": [
{
"type": "svf",
"views": [
"2d",
"3d"
]
}
]
}
}'
Load the translated URN from step 5. This is the single URN containing the host and linked contents.

Related

Is there a way to export large google docs as pdfs?

When exporting a large google doc as a pdf I am experiencing a timeout issue. I am currently using this REST API. Is there a way to allow me to export larger documents? Maybe there is a way to change the timeout duration or upgrade to a paid version in the google cloud console.
Use exportLinks instead under Files: get instead as Files: export does have a limit of 10mb.
Sample:
curl \
'https://www.googleapis.com/drive/v3/files/[FILE_ID]?fields=exportLinks&key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
And it will provide you an output that contains all possible export links available (that doesn't have a file size limit)
Output:
{
"exportLinks": {
"application/rtf": "https://docs.google.com/feeds/download/documents/export/Export?id=[FILE_ID]&exportFormat=rtf&resourcekey=[RESOURCE_KEY]",
"application/vnd.oasis.opendocument.text": "https://docs.google.com/feeds/download/documents/export/Export?id=[FILE_ID]&exportFormat=odt&resourcekey=[RESOURCE_KEY]",
"text/html": "https://docs.google.com/feeds/download/documents/export/Export?id=[FILE_ID]&exportFormat=html&resourcekey=[RESOURCE_KEY]",
"application/pdf": "https://docs.google.com/feeds/download/documents/export/Export?id=[FILE_ID]&exportFormat=pdf&resourcekey=[RESOURCE_KEY]",
"application/epub+zip": "https://docs.google.com/feeds/download/documents/export/Export?id=[FILE_ID]&exportFormat=epub&resourcekey=[RESOURCE_KEY]",
"application/zip": "https://docs.google.com/feeds/download/documents/export/Export?id=[FILE_ID]&exportFormat=zip&resourcekey=[RESOURCE_KEY]",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "https://docs.google.com/feeds/download/documents/export/Export?id=[FILE_ID]&exportFormat=docx&resourcekey=[RESOURCE_KEY]",
"text/plain": "https://docs.google.com/feeds/download/documents/export/Export?id=[FILE_ID]&exportFormat=txt&resourcekey=[RESOURCE_KEY]"
}
Reference:
https://stackoverflow.com/a/59168288/14606045

Model Derivative Translation of Revit Models stored in BIM360 Docs

I'm working on an app to translate Revit models which have already been published to the cloud into IFC format using the data-management and model-derivative APIs, and have run into two key issues for the model-derivative API.
1. Model-Derivative Translation Issue:
I have run into a failed translation error which has also popped up in other threads
Model Uploader Error
The file is not a Revit file or is not a supported version
code:"Revit-UnsupportedFileType"
message:"<message>The file is not a Revit file or is not a supported version.</message>"
type:"error"
code:"TranslationWorker-RecoverableInternalFailure"
message:"Possibly recoverable warning exit code from extractor: -536870935"
type:"error
However my case is somewhat unique, and other answers are not applicable. Previous cases have failed due to incorrect Revit version (apparently the translation may work on a 2016 version but not a 2019 version), or corruption during the upload of the file. This cannot be applicable for me as the .rvt to .svf translation was successful for this model, only my .rvt to .ifc translation has failed, also I am not uploading through the app, rather accessing files that are already on BIM360 docs.
Another strange part of this behavior is that the .rvt->.ifc translation has been successful for earlier versions of the same model. This leads me to believe that perhaps there is a file size issue where the latest version of the model is too large for translation, although I haven't found any limits on the file size in the model-derivative documentation.
2. Model-Derivative Download Issue:
Routing the download of a translated file through my server before downloading again from server to client, in order to use the 3-legged OAuth token, means having to download the same file twice (once from data-management api endpoint to server, secondly from server to client). This is problematic for large models.
Currently my solution has been to just pass the 3-legged OAuth token and file URI to the client and have the request go straight from client to autodesk endpoint, although I thought this was bad practice.
I have not found any samples which incorporate this download endpoint, a NodeJS one would be optimal for me. Also I wish there was a content-length header attached to this endpoint to give a better idea of download progress.
The relevant endpoints for my issues are both here:
https://forge.autodesk.com/en/docs/model-derivative/v2/tutorials/translate-source-file-to-obj/
Translate:
curl -X 'POST' -H 'Authorization: Bearer WmzXZq9MATYyfrnOFpYOE75sL5dh' -H 'Content-Type: application/json' -v 'https://developer.api.autodesk.com/modelderivative/v2/designdata/job' -d
'{
"input": {
"urn": "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bW9kZWxkZXJpdmF0aXZlL0E1LmlhbQ"
},
"output": {
"formats": [
{
"type": "obj"
}
]
}
}'
Note: I have used "type": ifc rather than "type": obj, as my output format on this endpoint; that is not the issue.
Verify:
curl -X 'GET' -H 'Authorization: Bearer RWLzh098vuF3068r73FI7nF2RORf' -v 'https://developer.api.autodesk.com/modelderivative/v2/designdata/dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bW9kZWxkZXJpdmF0aXZlL0E1LmlhbQ/manifest'
Download:
curl -X 'GET' -H 'Authorization: Bearer RWLzh098vuF3068r73FI7nF2RORf' -v 'https://developer.api.autodesk.com/modelderivative/v2/designdata/dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bW9kZWxkZXJpdmF0aXZlL0E1LmlhbQ/manifest/urn%3Aadsk.viewing%3Afs.file%3AdXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bW9kZWxkZXJpdmF0aXZlL0E1LmlhbQ%2Foutput%2Fgeometry%2Fbc3339b2-73cd-4fba-9cb3-15363703a354.obj'
means having to download the same file twice (once from data-management api endpoint to server, secondly from server to client). This is problematic for large models.
Try set up a proxy service in your backend to relay user requests and direct them to fetch the derivatives and inject tokens into their headers so the tokens won’t get exposed to clients so the files won’t have to land physically on your backend as a go-between - see here for an sample.
Will update this answer once we get to the bottom of the first issue.

How I can save a page to Wayback Machine?

I checked their API documentation and didn't find anything useful that gives me the ability to create snapshots of the URLs I choose.
Submitting a POST request to the root path (https://pragma.archivelab.org) with JSON data containing url (String) and annotation (Object) fields will save a snapshot of url using the Wayback Machine and store the annotation object, making a bidirectional link between the stored snapshot and annotation entries.
Here's an example of such a request:
curl -X POST -H "Content-Type: application/json" -d '{"url": "google.com", "annotation": {"id": "lst-ib", "message": "Theres a microphone button in the searchbox"}}' https://pragma.archivelab.org

Create Couchbase documents via REST API

I am new to Couchbase and I want to know about how CRUD can be achieved in it.
I have sucessfully created a bucket and I've tried to insert documents in it using CURL.
Creating a bucket using CURL succeeded like the following:
curl -X POST -u admin:citrus -d name=test-bucket -d ramQuotaMB=100 -d authType=none -d replicaNumber=2 -d proxyPort=11216 http://example.com:8091/pools/default/buckets
Now how can I create sample documents in this bucket?
How can I achieve this by using a REST API, please help me..
Couchbase isn't designed to use a REST API for data creation or mutation, perhaps you are thinking of CouchDB which does offer this and shares some similarities with Couchbase although they are distinct technologies.
You need to use one of the sdks to interact with your bucket, there are a multitude of SDK's available in all the major languages, Java,Ruby,Python,C etc. Check out the list of them here, they also contain getting started guides which covers the basic operations such as get/set and more complex examples of views and topics such as locking.
http://docs.couchbase.com/
I think you should use the Sync Gateway of Couchbase. The Sync Gateway provides a REST API which allows you to Create, Read, Update and Delete (CRUD) documents.
For example, if you have a Couchbase Server running on port 8091 with a bucket called test-bucket, you can set up your Sync Gateway with the following content in your sync_gateway.json configuration file:
{
"log": ["HTTP+"],
"adminInterface": "127.0.0.1:4985",
"interface": "0.0.0.0:4984",
"databases": {
"test-db": {
"server": "http://localhost:8091",
"bucket": "test-bucket",
"username": "test-bucket",
"password": "test-bucket-password",
"users": {
"GUEST": {"disabled": false, "admin_channels": ["*"] }
}
}
}
}
Then, after starting the Sync Gateway, you can create a document like the following:
curl -X PUT -H 'Content-Type: application/json' http://localhost:4984/test-db/myNewDocId -d #document.file
With document.file being a file with the JSON content of the document you'd like to create and with myNewDocId being the ID of the new document.
You can find all supported REST API methods and details in the official documentation: http://developer.couchbase.com/documentation/mobile/1.1.0/develop/references/sync-gateway/rest-api/document/index.html
Couchbase now supports adding document via curl call.
you can do
curl localhost:8093/query/service -u uname:paaswd -d 'statement=INSERT INTO `bucketName` (KEY, VALUE) VALUES ( "my_doc_id", {"Price":"price"} );'
Note we are using 8093 which is query service port. for this to run you have to have query service(n1ql) running.

import json file to couch db-

If I have a json file that looks something like this:
{"name":"bob","hi":"hello"}
{"name":"hello","hi":"bye"}
Is there an option to import this into couchdb?
Starting from #Millhouse answer but with multiple docs in my file I used
cat myFile.json | lwp-request -m POST -sS "http://localhost/dbname/_bulk_docs" -c "application/json"
POST is an alias of lwp-request but POST doesn't seem to work on debian. If you use lwp-request you need to set the method with -m as above.
The trailing _bulk_docs allows multiple documents to be uploaded at once.
http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API
If you are on Linux, You could write a quick shell script to POST the contents of valid json files to Couch.
To test couch I did something like this:
cat myFile.json | POST -sS "http://myDB.couchone.com/testDB" -c "application/json"
myFile.json has the json contents I wanted to import into the database.
Another alternative, if you don't like command line or aren't using Linux, and prefer a gui, you can use a tool like RESTClient
Probably a bit late to answer. But If you can use Python than you can use the couchdb module to do so:
import couchdb
import json
couch = couchdb.Server(<your server url>)
db = couch[<your db name>]
with open(<your file name>) as jsonfile:
for row in jsonfile:
db_entry = json.load(row)
db.save(db_entry)
I created the python script to do that(As I could not find one on Internet).
The full script is here: :
http://bitbucket.org/tdatta/tools/src/
(name --> jsonDb_to_Couch.py)
If you download the full repo and:
Text replace all the "_id" in json files to "id"
Run make load_dbs
It would create 4 databases in your local couch installation
Hope that helps newbies (like me)
Yes, this is not valid JSON ...
To import JSON-Objects I use curl (http://curl.haxx.se):
curl -X PUT -d #my.json http://admin:secret#127.0.0.1:5984/db_name/doc_id
where my.json is a file the JSON-Object is in.
Of course you can put your JSON-Object directly into couchdb (without a file) as well:
curl -X PUT -d '{"name":"bob","hi":"hello"}' http://admin:secret#127.0.0.1:5984/db_name/doc_id
If you do not have a doc_id, you can ask couchdb for it:
curl -X GET http://127.0.0.1:5984/_uuids?count=1
That JSON object will not be accepted by CouchDB. To store all the data with a single server request use:
{
"people":
[
{
"name":"bob",
"hi":"hello"
},
{
"name":"hello",
"hi":"bye"
}
]
}
Alternatively, submit a different CouchDB request for each row.
Import the file into CouchDB from the command-line using cURL:
curl -vX POST https://user:pass#127.0.0.1:1234/database \
-d #- -# -o output -H "Content-Type: application/json" < file.json
It's not my solution but I found this to solve my issue:
A simple way of exporting a CouchDB database to a file, is by running the following Curl command in the terminal window:
curl -X GET http://127.0.0.1:5984/[mydatabase]/_all_docs\?include_docs\=true > /Users/[username]/Desktop/db.json
Next step is to modify the exported json file to look like something like the below (note the _id):
{
"docs": [
{"_id": "0", "integer": 0, "string": "0"},
{"_id": "1", "integer": 1, "string": "1"},
{"_id": "2", "integer": 2, "string": "2"}
]
}
Main bit you need to look at is adding the documents in the “docs” code block. Once this is done you can run the following Curl command to import the data to a CouchDB database:
curl -d #db.json -H "Content-type: application/json" -X POST http://127.0.0.1:5984/[mydatabase]/_bulk_docs
Duplicating a database
If you want to duplicate a database from one server to another. Run the following command:
curl -H 'Content-Type: application/json' -X POST http://localhost:5984/_replicate -d ' {"source": "http://example.com:5984/dbname/", "target": "http://localhost#:5984/dbname/"}'
Original Post:
http://www.greenacorn-websolutions.com/couchdb/export-import-a-database-with-couchdb.php
http://github.com/zaphar/db-couchdb-schema/tree/master
My DB::CouchDB::Schema module has a script to help with loading a series of documents into a CouchDB Database. The couch_schema_tool.pl script accepts a file as an argument and loads all the documents in that file into the database. Just put each document into an array like so:
[
{"name":"bob","hi":"hello"},
{"name":"hello","hi":"bye"}
]
It will load them into the database for you. Small caveat though I haven't tested my latest code against CouchDB's latest so if you use it and it breaks then let me know. I probably have to change something to fit the new API changes.
Jeremy