Skip to content

Commit

Permalink
Update 04.Explore Revit Data With APSToolkit.ipynb
Browse files Browse the repository at this point in the history
  • Loading branch information
chuongmep committed Feb 27, 2024
1 parent 16337ce commit bdf1279
Showing 1 changed file with 104 additions and 65 deletions.
169 changes: 104 additions & 65 deletions docs/Tutorials/04.Explore Revit Data With APSToolkit.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,6 @@
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"Loading extensions from `C:\\Users\\chuongho\\.nuget\\packages\\microsoft.data.analysis\\0.20.1\\interactive-extensions\\dotnet\\Microsoft.Data.Analysis.Interactive.dll`"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"ename": "Error",
"evalue": "Failed to load kernel extension \"DataFrameKernelExtension\" from assembly C:\\Users\\chuongho\\.nuget\\packages\\microsoft.data.analysis\\0.20.1\\interactive-extensions\\dotnet\\Microsoft.Data.Analysis.Interactive.dll",
"output_type": "error",
"traceback": [
"Failed to load kernel extension \"DataFrameKernelExtension\" from assembly C:\\Users\\chuongho\\.nuget\\packages\\microsoft.data.analysis\\0.20.1\\interactive-extensions\\dotnet\\Microsoft.Data.Analysis.Interactive.dll"
]
},
{
"ename": "Error",
"evalue": "Microsoft.DotNet.Interactive.KernelExtensionLoadException: Failure loading Kernel Extension\r\n ---> System.MissingMethodException: Method not found: 'Void Microsoft.DotNet.Interactive.Commands.SubmitCode..ctor(System.String, System.String, Microsoft.DotNet.Interactive.Commands.SubmissionType)'.\r\n at Microsoft.Data.Analysis.Interactive.DataFrameKernelExtension.LoadExtensionApiAsync(Kernel cSharpKernel)\r\n at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)\r\n at Microsoft.Data.Analysis.Interactive.DataFrameKernelExtension.LoadExtensionApiAsync(Kernel cSharpKernel)\r\n at Microsoft.Data.Analysis.Interactive.DataFrameKernelExtension.OnLoadAsync(Kernel kernel)\r\n at Microsoft.DotNet.Interactive.App.PackageDirectoryExtensionLoader.LoadFromAssemblyFile(FileInfo assemblyFile, Kernel kernel, KernelInvocationContext context) in D:\\a\\_work\\1\\s\\src\\dotnet-interactive\\PackageDirectoryExtensionLoader.cs:line 124\r\n --- End of inner exception stack trace ---",
"output_type": "error",
"traceback": [
"Microsoft.DotNet.Interactive.KernelExtensionLoadException: Failure loading Kernel Extension\r\n",
" ---> System.MissingMethodException: Method not found: 'Void Microsoft.DotNet.Interactive.Commands.SubmitCode..ctor(System.String, System.String, Microsoft.DotNet.Interactive.Commands.SubmissionType)'.\r\n",
" at Microsoft.Data.Analysis.Interactive.DataFrameKernelExtension.LoadExtensionApiAsync(Kernel cSharpKernel)\r\n",
" at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)\r\n",
" at Microsoft.Data.Analysis.Interactive.DataFrameKernelExtension.LoadExtensionApiAsync(Kernel cSharpKernel)\r\n",
" at Microsoft.Data.Analysis.Interactive.DataFrameKernelExtension.OnLoadAsync(Kernel kernel)\r\n",
" at Microsoft.DotNet.Interactive.App.PackageDirectoryExtensionLoader.LoadFromAssemblyFile(FileInfo assemblyFile, Kernel kernel, KernelInvocationContext context) in D:\\a\\_work\\1\\s\\src\\dotnet-interactive\\PackageDirectoryExtensionLoader.cs:line 124\r\n",
" --- End of inner exception stack trace ---"
]
}
],
"source": [
Expand Down Expand Up @@ -80,12 +48,12 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## How to access token Autodesk Platform Services"
"## Auth"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
Expand All @@ -96,31 +64,27 @@
},
"outputs": [],
"source": [
"string urn = \"dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLk9kOHR4RGJLU1NlbFRvVmcxb2MxVkE_dmVyc2lvbj0z\";\n",
"Autodesk.Forge.TwoLeggedApi twoLeggedApi = new Autodesk.Forge.TwoLeggedApi();\n",
"var ClientID = Environment.GetEnvironmentVariable(\"APS_CLIENT_ID\");\n",
"var ClientSecret = Environment.GetEnvironmentVariable(\"APS_CLIENT_SECRET\");\n",
"Console.WriteLine(\"Done with Authentication\");\n",
"dynamic token = twoLeggedApi.Authenticate(ClientID, ClientSecret, \"client_credentials\",\n",
" new Scope[]\n",
" {\n",
" Scope.DataRead, Scope.DataWrite, Scope.DataCreate, Scope.DataSearch, Scope.BucketCreate, Scope.BucketRead,\n",
" Scope.BucketUpdate, Scope.BucketDelete\n",
" });\n",
"var access_token = token.access_token;\n",
"Console.WriteLine(\"Access Token: \" + access_token);"
"using APSToolkit.Auth;\n",
"var access_token = Authentication.Get2LeggedToken().Result;"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## How to get all categories of Revit Model "
"## Revit Data "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### How to get all categories of Revit Model In ACC ?"
]
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 8,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
Expand Down Expand Up @@ -173,21 +137,23 @@
],
"source": [
"using APSToolkit.Utils;\n",
"string urn = \"dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLk9kOHR4RGJLU1NlbFRvVmcxb2MxVkE_dmVyc2lvbj0z\";\n",
"var RevitPropDbReader = new PropDbReaderRevit(urn, access_token);\n",
"var categories = RevitPropDbReader.GetAllCategories();\n",
"// return key is dbid, value is category name\n",
"display(categories);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## How to export all catefories to csv file"
"#### How to export all catefories to csv file ? "
]
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 21,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
Expand All @@ -196,21 +162,66 @@
"kernelName": "csharp"
}
},
"outputs": [],
"outputs": [
{
"data": {
"text/html": [
"<div class=\"dni-plaintext\"><pre>[ Key\tValue\r, 39\tPhases\r, 65\tMaterials\r, 405\tPrimary Contours\r, 407\tArea Schemes\r ... (5 more) ]</pre></div><style>\r\n",
".dni-code-hint {\r\n",
" font-style: italic;\r\n",
" overflow: hidden;\r\n",
" white-space: nowrap;\r\n",
"}\r\n",
".dni-treeview {\r\n",
" white-space: nowrap;\r\n",
"}\r\n",
".dni-treeview td {\r\n",
" vertical-align: top;\r\n",
" text-align: start;\r\n",
"}\r\n",
"details.dni-treeview {\r\n",
" padding-left: 1em;\r\n",
"}\r\n",
"table td {\r\n",
" text-align: start;\r\n",
"}\r\n",
"table tr { \r\n",
" vertical-align: top; \r\n",
" margin: 0em 0px;\r\n",
"}\r\n",
"table tr td pre \r\n",
"{ \r\n",
" vertical-align: top !important; \r\n",
" margin: 0em 0px !important;\r\n",
"} \r\n",
"table th {\r\n",
" text-align: start;\r\n",
"}\r\n",
"</style>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"categories.ExportToCsv(\"result.csv\");"
"categories.ExportToCsv(\"result.csv\");\n",
"// read the csv file\n",
"var csv = System.IO.File.ReadAllText(\"result.csv\");\n",
"// just show 10 lines\n",
"csv.Split(\"\\n\").Take(10)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## How to export all data to excel ? "
"#### How to export all data to excel ? "
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 26,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
Expand All @@ -224,16 +235,44 @@
"RevitPropDbReader.ExportAllDataToExcel(\"result.xlsx\");"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"polyglot_notebook": {
"kernelName": "csharp"
}
},
"outputs": [
{
"data": {
"text/plain": [
"759"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"// read excel file \n",
"var excel = ExcelUtils.ReadDataFromExcel(\"result.xlsx\",\"Views\");\n",
"excel[0][0]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## How to export data by category to excel ?"
"#### How to export data by category to excel ?"
]
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 30,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
Expand All @@ -251,12 +290,12 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## How to export data to big data format like parquet ? "
"#### How to export data to big data format like parquet ? "
]
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 31,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
Expand All @@ -279,12 +318,12 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## How to get all data from Revit Model filter by parameters ? "
"#### How to get all data from Revit Model filter by parameters ? "
]
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 32,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
Expand All @@ -311,7 +350,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## How to get all families from Revit Model ?"
"#### How to get all families from Revit Model ?"
]
},
{
Expand Down Expand Up @@ -376,7 +415,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## How to get all family type from Revit Model ?"
"#### How to get all family type from Revit Model ?"
]
},
{
Expand Down Expand Up @@ -441,12 +480,12 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## How to get all data by catgories and parameters ?"
"#### How to get all data by catgories and parameters ?"
]
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 33,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
Expand Down

0 comments on commit bdf1279

Please sign in to comment.