Skip to content

Commit

Permalink
Update 03.Explore Versions Item and Derivative Urn.ipynb
Browse files Browse the repository at this point in the history
  • Loading branch information
chuongmep committed Feb 27, 2024
1 parent 8198d6d commit 28dd06f
Showing 1 changed file with 270 additions and 2 deletions.
272 changes: 270 additions & 2 deletions docs/Tutorials/03.Explore Versions Item and Derivative Urn.ipynb
Original file line number Diff line number Diff line change
@@ -1,11 +1,279 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Version"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Autodesk Forge is a collection of Autodesk's cloud-based APIs and services. It allows developers to create applications that can interact with Autodesk's software and services in a cloud-based environment. \n",
"\n",
"One of the key components of Autodesk Forge is the \"Version\" item. In the context of Autodesk Forge, a \"Version\" represents a specific iteration of a design file. Each time a design file is updated and saved, a new version is created. This allows for tracking of changes and the ability to revert to previous versions if necessary.\n",
"\n",
"The Version item in Autodesk Forge includes several properties:\n",
"\n",
"- `id`: A unique identifier for the version.\n",
"- `type`: The type of the item, which is \"versions\" for version items.\n",
"- `attributes`: This includes several sub-properties like `name` (the name of the version), `createTime` (when the version was created), `createUserId` (the user who created the version), `lastModifiedTime` (when the version was last modified), and `versionNumber` (the version number).\n",
"\n",
"To interact with the Version item, Autodesk Forge provides several APIs, including:\n",
"\n",
"- Versions API: Allows you to get metadata about a specific version, get a list of versions for a specific item, and upload a new version of a design file.\n",
"- Data Management API: Allows you to manage and access data across BIM 360 Team, Fusion Team, BIM 360 Docs, A360 Personal, and the Object Storage Service.\n",
"\n",
"Remember, to use these APIs, you need to authenticate your application with Autodesk Forge's OAuth service."
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"polyglot_notebook": {
"kernelName": "csharp"
},
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [
{
"data": {
"text/html": [
"<div><div></div><div></div><div><strong>Installed Packages</strong><ul><li><span>APSToolkit, 1.0.4</span></li></ul></div></div>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"#r \"nuget:APSToolkit\""
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"polyglot_notebook": {
"kernelName": "csharp"
},
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [],
"source": [
"using APSToolkit;"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Auth"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"polyglot_notebook": {
"kernelName": "csharp"
},
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [],
"source": []
"source": [
"using APSToolkit.Auth;\n",
"// Get 2-legged token\n",
"var token = Authentication.Get2LeggedToken().Result;"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Get Version Items"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"polyglot_notebook": {
"kernelName": "csharp"
},
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Item Version: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=28\n",
"Item Version: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=27\n",
"Item Version: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=26\n",
"Item Version: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=25\n",
"Item Version: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=24\n",
"Item Version: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=23\n",
"Item Version: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=22\n",
"Item Version: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=21\n",
"Item Version: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=20\n",
"Item Version: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=19\n",
"Item Version: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=18\n",
"Item Version: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=17\n",
"Item Version: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=16\n",
"Item Version: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=15\n",
"Item Version: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=14\n",
"Item Version: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=13\n",
"Item Version: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=12\n",
"Item Version: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=11\n",
"Item Version: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=10\n",
"Item Version: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=9\n",
"Item Version: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=8\n",
"Item Version: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=7\n",
"Item Version: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=6\n",
"Item Version: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=5\n",
"Item Version: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=4\n",
"Item Version: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=3\n",
"Item Version: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=2\n",
"Item Version: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=1\n"
]
}
],
"source": [
"using APSToolkit.BIM360;\n",
"string itemId = \"urn:adsk.wipprod:dm.lineage:Od8txDbKSSelToVg1oc1VA\";\n",
"string projectId = \"b.ca790fb5-141d-4ad5-b411-0461af2e9748\";\n",
"var bim360 = new BIM360();\n",
"var itemVersions = bim360.GetItemVersions(token, projectId, itemId);\n",
"foreach (var itemVersion in itemVersions)\n",
"{\n",
" dynamic itemVersionw = itemVersion.Value;\n",
" Console.WriteLine(\"Item Version: \" + itemVersionw.id);\n",
"}"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Get Latest Version of an Item"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"polyglot_notebook": {
"kernelName": "csharp"
},
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Latest Item Version Id: urn:adsk.wipprod:fs.file:vf.Od8txDbKSSelToVg1oc1VA?version=28\r\n"
]
}
],
"source": [
"var latestItem = bim360.GetLatestVersionItem(token, projectId, itemId);\n",
"Console.WriteLine(\"Latest Item Version Id: \" + latestItem.id);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## URN"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In Autodesk Forge, a URN (Uniform Resource Name) is a unique identifier for a specific resource, such as a design file or version of a file. \n",
"\n",
"A derivative, on the other hand, is a representation of a design file in a different format. For example, a 3D model might have derivatives that are 2D drawings, thumbnail images, or files in different 3D formats. \n",
"\n",
"When you upload a design file to Autodesk Forge, it creates a URN for that file and generates derivatives. These derivatives are also associated with their own unique URNs. \n",
"\n",
"You can use these URNs to retrieve specific resources through the Forge APIs. For example, you might retrieve a derivative to display a 3D model in a web browser, or to download a 2D drawing. \n",
"\n",
"In summary, a URN derivative in Autodesk Forge is a unique identifier for a specific representation of a design file."
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"polyglot_notebook": {
"kernelName": "csharp"
},
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Derivative Urn: dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLk9kOHR4RGJLU1NlbFRvVmcxb2MxVkE_dmVyc2lvbj0yOA\r\n"
]
}
],
"source": [
"string itemId = \"urn:adsk.wipprod:dm.lineage:Od8txDbKSSelToVg1oc1VA\";\n",
"var derivativeUrn = bim360.GetDerivativesUrn(token, projectId, itemId, 28);\n",
"Console.WriteLine(\"Derivative Urn: \" + derivativeUrn);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"What you can do with a URN:\n",
"- Get the metadata of a specific item\n",
"- Get the metadata of a specific version\n",
"- Export data to different formats\n",
"- Query the properties of a specific item\n",
"...\n",
"\n",
"Congratulations! You have learned the basics of the Autodesk Platform Services API about `Version Item` and `URN`. Now you can continute for the next part to learn how to use the APIs to use `item` and `urn` with another task."
]
}
],
"metadata": {
Expand Down

0 comments on commit 28dd06f

Please sign in to comment.