Skip to content

Commit

Permalink
add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
chuongmep committed Mar 6, 2024
1 parent 1f05ad4 commit 1b413cd
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 0 deletions.
130 changes: 130 additions & 0 deletions APSToolkitPython/Tutorials/08. Explore URL ACC Extract.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Extract Infomration From ACC URL Opening "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Example URL , make sure you opened the 3d model in the browser before copying the URL"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"\n",
"url = \"https://acc.autodesk.com/docs/files/projects/ec0f8261-aeca-4ab9-a1a5-5845f952b17d?folderUrn=urn%3Aadsk.wipprod%3Afs.folder%3Aco.SQBGbt7LTWywCVcHfqSb1Q&entityId=urn%3Aadsk.wipprod%3Adm.lineage%3AoxAqhUL0SISdkPcNLzehag&viewModel=detail&moduleId=folders&viewableGuid=5d41dda7-eea1-eff5-77dd-ee1aa81fc3a8\""
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ProjectId: b.ec0f8261-aeca-4ab9-a1a5-5845f952b17d\n",
"folderUrn: urn%3Aadsk.wipprod%3Afs.folder%3Aco.SQBGbt7LTWywCVcHfqSb1Q\n",
"entityId: urn%3Aadsk.wipprod%3Adm.lineage%3AoxAqhUL0SISdkPcNLzehag\n",
"viewableGuid: 5d41dda7-eea1-eff5-77dd-ee1aa81fc3a8\n"
]
}
],
"source": [
"import requests\n",
"from urllib.parse import urlparse\n",
"\n",
"def get_info_from_url(url):\n",
" try:\n",
" response = requests.get(url)\n",
" response.raise_for_status()\n",
" parsed_url = urlparse(url)\n",
" \n",
" # Extract project ID from URL path\n",
" path_segments = parsed_url.path.split('/')\n",
" project_id = path_segments[4] if len(path_segments) >= 4 else ''\n",
" # Extract query parameters\n",
" query_params = dict(q.split(\"=\") for q in parsed_url.query.split(\"&\"))\n",
" folder_urn = query_params.get('folderUrn', '')\n",
" entity_id = query_params.get('entityId', '')\n",
" viewable_guid = query_params.get('viewableGuid', '')\n",
" \n",
" return {\n",
" 'ProjectId': \"b.\"+project_id,\n",
" 'folderUrn': folder_urn,\n",
" 'entityId': entity_id,\n",
" 'viewableGuid': viewable_guid\n",
" }\n",
" except Exception as e:\n",
" print(\"Error occurred:\", e)\n",
" return None\n",
"info = get_info_from_url(url)\n",
"if info:\n",
" for key, value in info.items():\n",
" print(f\"{key}: {value}\")\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Get Derivative URN"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Derivative URN Of Version 2: dXJuJTNBYWRzay53aXBwcm9kJTNBZG0ubGluZWFnZSUzQW94QXFoVUwwU0lTZGtQY05MemVoYWc_dmVyc2lvbj0y\n"
]
}
],
"source": [
"# convert entityId to derivative urn by base64encode\n",
"import base64\n",
"version = 2\n",
"item_version = info['entityId']+ f\"?version={version}\"\n",
"urn = base64.b64encode(item_version.encode()).decode()\n",
"# change character \"/\" to \"_\n",
"urn = urn.replace(\"/\", \"_\")\n",
"print(f\"Derivative URN Of Version {version}: {urn}\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ All Tutorials are available under Jupyter Notebook at [Python Tutorials](./APSTo
- [05. Explore Access Database And Query Items](./APSToolkitPython/Tutorials/05.%20Explore%20Access%20Database%20And%20Query%20Items.ipynb)
- [06. Data Visualization - Analyst BIM Model](./APSToolkitPython/Tutorials/06.%20Data%20Visualization%20-%20Analyst%20BIM%20Model.ipynb)
- [07. Explore Big Data Format Storage](./APSToolkitPython/Tutorials/07.%20Explore%20Big%20Data%20Format%20Storage.ipynb)
- [08. Explore URL ACC Extract](./APSToolkitPython/Tutorials/08.%20Explore%20URL%20ACC%20Extract.ipynb)

## License
Thís project is licensed under the terms of the [MIT](LICENSE).
Expand Down

0 comments on commit 1b413cd

Please sign in to comment.