├── .gitattributes
├── .gitignore
├── BIMrx.Marconi SinglePage 1.1.pdf
├── LICENSE
├── README.md
├── graphiql.png
└── src
├── GraphQL4Revit.sln
├── RevitGraphQLCommand
├── App.cs
├── EntryCommandSeparateThread.cs
├── Properties
│ └── AssemblyInfo.cs
├── Resources
│ └── graphql.png
├── Revit2GraphQL.addin
├── RevitGraphQLCommand.csproj
├── Ui.xaml
├── Ui.xaml.cs
├── Util.cs
├── app.config
└── packages.config
├── RevitGraphQLResolver
├── GraphQL
│ ├── GraphQLHelpers.cs
│ ├── GraphQLQuery.cs
│ ├── IQuery.cs
│ ├── Mutation.cs
│ ├── MySchema.cs
│ └── Query.cs
├── GraphQLModel
│ ├── IQLFamily.cs
│ ├── IQLFamilyCategory.cs
│ ├── IQLFamilySymbol.cs
│ ├── QLAssemblyResolve.cs
│ ├── QLElementCollectionResolve.cs
│ ├── QLFabricationPartResolve.cs
│ ├── QLFabricationServiceResolve.cs
│ ├── QLFamilyCategoryResolve.cs
│ ├── QLFamilyInstanceResolve.cs
│ ├── QLFamilyResolve.cs
│ ├── QLFamilySymbolResolve.cs
│ ├── QLMepSystemResolve.cs
│ ├── QLTammTreeNodeResolve.cs
│ └── QLViewScheduleResolve.cs
├── ResolverEntry.cs
├── RevitGraphQLResolver.csproj
└── TraversalTree
│ ├── Options.cs
│ ├── TraversalTree.cs
│ └── Util.cs
├── RevitGraphQLSchema
├── GraphQLModel
│ ├── QLAssembly.cs
│ ├── QLElementCollection.cs
│ ├── QLFabricationPart.cs
│ ├── QLFabricationService.cs
│ ├── QLFamily.cs
│ ├── QLFamilyCategory.cs
│ ├── QLFamilyInstance.cs
│ ├── QLFamilySymbol.cs
│ ├── QLMepSystem.cs
│ ├── QLParameter.cs
│ ├── QLTammTreeNode.cs
│ ├── QLViewSchedule.cs
│ ├── QLViewScheduleData.cs
│ ├── QLViewScheduleRow.cs
│ └── UpdateQLParameter.cs
├── GraphQLSchema.cs
├── IGraphQL
│ ├── IMutation.cs
│ └── IQuery.cs
├── MarconiUser.cs
└── RevitGraphQLSchema.csproj
├── RevitMarconiCommand
├── App.cs
├── Class1.cs
├── EntryCommandSeparateThread.cs
├── Helpers
│ ├── MsalAuthHelper.cs
│ └── TokenCacheHelper.cs
├── Properties
│ └── AssemblyInfo.cs
├── Resources
│ └── phone.png
├── RevitMarconi.addin
├── RevitMarconiCommand.csproj
├── Ui.xaml
├── Ui.xaml.cs
├── Util.cs
├── app.config
└── packages.config
└── RevitWebServer
├── Controllers
├── AboutController.cs
└── GraphqlController.cs
├── Properties
└── AssemblyInfo.cs
├── RevitWebServer.csproj
├── Startup.cs
├── WebServer.cs
├── app.config
└── packages.config
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Aa][Rr][Mm]/
27 | [Aa][Rr][Mm]64/
28 | bld/
29 | [Bb]in/
30 | [Oo]bj/
31 | [Ll]og/
32 | [Ll]ogs/
33 |
34 | # Visual Studio 2015/2017 cache/options directory
35 | .vs/
36 | # Uncomment if you have tasks that create the project's static files in wwwroot
37 | #wwwroot/
38 |
39 | # Visual Studio 2017 auto generated files
40 | Generated\ Files/
41 |
42 | # MSTest test Results
43 | [Tt]est[Rr]esult*/
44 | [Bb]uild[Ll]og.*
45 |
46 | # NUnit
47 | *.VisualState.xml
48 | TestResult.xml
49 | nunit-*.xml
50 |
51 | # Build Results of an ATL Project
52 | [Dd]ebugPS/
53 | [Rr]eleasePS/
54 | dlldata.c
55 |
56 | # Benchmark Results
57 | BenchmarkDotNet.Artifacts/
58 |
59 | # .NET Core
60 | project.lock.json
61 | project.fragment.lock.json
62 | artifacts/
63 |
64 | # StyleCop
65 | StyleCopReport.xml
66 |
67 | # Files built by Visual Studio
68 | *_i.c
69 | *_p.c
70 | *_h.h
71 | *.ilk
72 | *.meta
73 | *.obj
74 | *.iobj
75 | *.pch
76 | *.pdb
77 | *.ipdb
78 | *.pgc
79 | *.pgd
80 | *.rsp
81 | *.sbr
82 | *.tlb
83 | *.tli
84 | *.tlh
85 | *.tmp
86 | *.tmp_proj
87 | *_wpftmp.csproj
88 | *.log
89 | *.vspscc
90 | *.vssscc
91 | .builds
92 | *.pidb
93 | *.svclog
94 | *.scc
95 |
96 | # Chutzpah Test files
97 | _Chutzpah*
98 |
99 | # Visual C++ cache files
100 | ipch/
101 | *.aps
102 | *.ncb
103 | *.opendb
104 | *.opensdf
105 | *.sdf
106 | *.cachefile
107 | *.VC.db
108 | *.VC.VC.opendb
109 |
110 | # Visual Studio profiler
111 | *.psess
112 | *.vsp
113 | *.vspx
114 | *.sap
115 |
116 | # Visual Studio Trace Files
117 | *.e2e
118 |
119 | # TFS 2012 Local Workspace
120 | $tf/
121 |
122 | # Guidance Automation Toolkit
123 | *.gpState
124 |
125 | # ReSharper is a .NET coding add-in
126 | _ReSharper*/
127 | *.[Rr]e[Ss]harper
128 | *.DotSettings.user
129 |
130 | # TeamCity is a build add-in
131 | _TeamCity*
132 |
133 | # DotCover is a Code Coverage Tool
134 | *.dotCover
135 |
136 | # AxoCover is a Code Coverage Tool
137 | .axoCover/*
138 | !.axoCover/settings.json
139 |
140 | # Visual Studio code coverage results
141 | *.coverage
142 | *.coveragexml
143 |
144 | # NCrunch
145 | _NCrunch_*
146 | .*crunch*.local.xml
147 | nCrunchTemp_*
148 |
149 | # MightyMoose
150 | *.mm.*
151 | AutoTest.Net/
152 |
153 | # Web workbench (sass)
154 | .sass-cache/
155 |
156 | # Installshield output folder
157 | [Ee]xpress/
158 |
159 | # DocProject is a documentation generator add-in
160 | DocProject/buildhelp/
161 | DocProject/Help/*.HxT
162 | DocProject/Help/*.HxC
163 | DocProject/Help/*.hhc
164 | DocProject/Help/*.hhk
165 | DocProject/Help/*.hhp
166 | DocProject/Help/Html2
167 | DocProject/Help/html
168 |
169 | # Click-Once directory
170 | publish/
171 |
172 | # Publish Web Output
173 | *.[Pp]ublish.xml
174 | *.azurePubxml
175 | # Note: Comment the next line if you want to checkin your web deploy settings,
176 | # but database connection strings (with potential passwords) will be unencrypted
177 | *.pubxml
178 | *.publishproj
179 |
180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
181 | # checkin your Azure Web App publish settings, but sensitive information contained
182 | # in these scripts will be unencrypted
183 | PublishScripts/
184 |
185 | # NuGet Packages
186 | *.nupkg
187 | # NuGet Symbol Packages
188 | *.snupkg
189 | # The packages folder can be ignored because of Package Restore
190 | **/[Pp]ackages/*
191 | # except build/, which is used as an MSBuild target.
192 | !**/[Pp]ackages/build/
193 | # Uncomment if necessary however generally it will be regenerated when needed
194 | #!**/[Pp]ackages/repositories.config
195 | # NuGet v3's project.json files produces more ignorable files
196 | *.nuget.props
197 | *.nuget.targets
198 |
199 | # Microsoft Azure Build Output
200 | csx/
201 | *.build.csdef
202 |
203 | # Microsoft Azure Emulator
204 | ecf/
205 | rcf/
206 |
207 | # Windows Store app package directories and files
208 | AppPackages/
209 | BundleArtifacts/
210 | Package.StoreAssociation.xml
211 | _pkginfo.txt
212 | *.appx
213 | *.appxbundle
214 | *.appxupload
215 |
216 | # Visual Studio cache files
217 | # files ending in .cache can be ignored
218 | *.[Cc]ache
219 | # but keep track of directories ending in .cache
220 | !?*.[Cc]ache/
221 |
222 | # Others
223 | ClientBin/
224 | ~$*
225 | *~
226 | *.dbmdl
227 | *.dbproj.schemaview
228 | *.jfm
229 | *.pfx
230 | *.publishsettings
231 | orleans.codegen.cs
232 |
233 | # Including strong name files can present a security risk
234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
235 | #*.snk
236 |
237 | # Since there are multiple workflows, uncomment next line to ignore bower_components
238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
239 | #bower_components/
240 |
241 | # RIA/Silverlight projects
242 | Generated_Code/
243 |
244 | # Backup & report files from converting an old project file
245 | # to a newer Visual Studio version. Backup files are not needed,
246 | # because we have git ;-)
247 | _UpgradeReport_Files/
248 | Backup*/
249 | UpgradeLog*.XML
250 | UpgradeLog*.htm
251 | ServiceFabricBackup/
252 | *.rptproj.bak
253 |
254 | # SQL Server files
255 | *.mdf
256 | *.ldf
257 | *.ndf
258 |
259 | # Business Intelligence projects
260 | *.rdl.data
261 | *.bim.layout
262 | *.bim_*.settings
263 | *.rptproj.rsuser
264 | *- [Bb]ackup.rdl
265 | *- [Bb]ackup ([0-9]).rdl
266 | *- [Bb]ackup ([0-9][0-9]).rdl
267 |
268 | # Microsoft Fakes
269 | FakesAssemblies/
270 |
271 | # GhostDoc plugin setting file
272 | *.GhostDoc.xml
273 |
274 | # Node.js Tools for Visual Studio
275 | .ntvs_analysis.dat
276 | node_modules/
277 |
278 | # Visual Studio 6 build log
279 | *.plg
280 |
281 | # Visual Studio 6 workspace options file
282 | *.opt
283 |
284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
285 | *.vbw
286 |
287 | # Visual Studio LightSwitch build output
288 | **/*.HTMLClient/GeneratedArtifacts
289 | **/*.DesktopClient/GeneratedArtifacts
290 | **/*.DesktopClient/ModelManifest.xml
291 | **/*.Server/GeneratedArtifacts
292 | **/*.Server/ModelManifest.xml
293 | _Pvt_Extensions
294 |
295 | # Paket dependency manager
296 | .paket/paket.exe
297 | paket-files/
298 |
299 | # FAKE - F# Make
300 | .fake/
301 |
302 | # CodeRush personal settings
303 | .cr/personal
304 |
305 | # Python Tools for Visual Studio (PTVS)
306 | __pycache__/
307 | *.pyc
308 |
309 | # Cake - Uncomment if you are using it
310 | # tools/**
311 | # !tools/packages.config
312 |
313 | # Tabs Studio
314 | *.tss
315 |
316 | # Telerik's JustMock configuration file
317 | *.jmconfig
318 |
319 | # BizTalk build output
320 | *.btp.cs
321 | *.btm.cs
322 | *.odx.cs
323 | *.xsd.cs
324 |
325 | # OpenCover UI analysis results
326 | OpenCover/
327 |
328 | # Azure Stream Analytics local run output
329 | ASALocalRun/
330 |
331 | # MSBuild Binary and Structured Log
332 | *.binlog
333 |
334 | # NVidia Nsight GPU debugger configuration file
335 | *.nvuser
336 |
337 | # MFractors (Xamarin productivity tool) working folder
338 | .mfractor/
339 |
340 | # Local History for Visual Studio
341 | .localhistory/
342 |
343 | # BeatPulse healthcheck temp database
344 | healthchecksdb
345 |
346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
347 | MigrationBackup/
348 |
349 | # Ionide (cross platform F# VS Code tools) working folder
350 | .ionide/
351 |
--------------------------------------------------------------------------------
/BIMrx.Marconi SinglePage 1.1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BIMrxLAB/Revit2GraphQL/150d7d0de0be57fd433a4b2ff91886100130c182/BIMrx.Marconi SinglePage 1.1.pdf
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 gv73
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # GraphQL for Revit
2 | This project contains a GraphQL endpoint for Revit that can be accessed locally as well as remotely over the web.
3 |
4 | 
5 | Check out [BIMrx.Marconi.pdf](https://github.com/gregorvilkner/Revit2GraphQL/blob/master/BIMrx.Marconi%20SinglePage%201.1.pdf) for more information.
6 |
7 | ## Current Itteration
8 |
9 | The current repo includes projects for 2 individual Revit addins:
10 | 1) a webapi hosted in Revit that exposes a GraphQL controller at http://localhost:9000/api/graphql. a very basic "about" controller that can be used for simple get requests at http://localhost:9000/api/about
11 | 1) a marconi client that allows interoperability with your revit session over the web at https://marconi4revitwebapp.azurewebsites.net/
12 |
13 | ## Getting Started: Nuget Dance and Versioning
14 |
15 | Personally, I always love to get latest. When Nuget suggests consolidations or updates I usually go for it. ~~Unfortunately, this is not possible here.~~ The main components that make this project work are described below.
16 |
17 | Here is what we know should not be updated:
18 |
19 | 1) ~~GraphQL-Parser - leave it at 3.0.0, which otherwise breakes GraphQL
20 | 2) System.Diagnostics.DiagnosticSource - leave it at 4.5.1, which otherwise breakes ServiceBus
21 | 3) ~~Newtonsoft.Json - it's a bit of a mess. You want to go low for Revit, and you can't go too high for GraphQL. GraphQL is actively trying to loose the Newtonsoft.Json dependency.
22 |
23 | Update as of 9/6/2020: The upgrade to GraphQL for .NET 3.0 enabled us to ditch a lot of Newtonsoft.Json references and go with System.Text.Json instead. This is making it a lot easier to life side by side with Revit. The last required Newtonsoft references are with the Microsoft.AspNet.WebApi.Client (requires 6.0.4) and Microsoft.Azure.ServiceBus (requires 10.0.3).
24 |
25 | ### Shared Infrastructure
26 |
27 | The Schema and the Resolver are both .NET Standard 2.0 projects. We're using .NET Standard so we can reference them in .NET Core web projects and in .NET Framework Revit addins. Also, this forces the Revit addins to be .NET Framework 4.7 at least.
28 |
29 | #### RevitGraphQLSchema
30 |
31 | The Schema defines the various GraphQL object types and holds interfaces for queries and mutations.
32 |
33 | It's sole dependency should be GraphQL ~~2.4.0.~~ 3.0.0
34 |
35 | #### RevitGraphQLResolver
36 |
37 | The Resolver is where GraphQL queries are received and resolved against the Revit API.
38 |
39 | Dependencies include GraphQL ~~2.4.0.~~ 3.0.0, GraphQL.SystemTextJson 3.0.0, and the very awesome WhiteShareq RevitTask 3.0.0.
40 |
41 | ### Local GraphQL Endpoint for Revit
42 |
43 | There are 2 projects that make up the local GraphQL endpoint for Revit: a web server and the command.
44 |
45 | #### RevitWebServer
46 |
47 | The library basically builds a selfhosted OWIN web server with 2 controllers: a simple About controller with a single GET method and the GraphQL controller with it's standard sole POST method. I've followed a couple of tutorials for OWIN'ing:
48 |
49 | 1) https://braincadet.com/category/c-sharp/
50 | 1) http://www.learnonlineasp.net/2017/10/use-owin-to-self-host-aspnet-web-api.html
51 |
52 | Dependencies include GraphQL ~~2.4.0.~~ 3.0.0, GraphQL.SystemTextJson 3.0.0, Newtonsoft.Json ~~12.0.3~~ 6.0.4, RevitTask 3.0.0, and a bunch of OWIN and AspNet.WebApi stuff.
53 |
54 | #### RevitGraphQLCommand
55 |
56 | This is the external command that hooks into Revit and has some very minimalistic WPF UI.
57 |
58 | Dependencies include ~~Newtonsoft.Json 9.0.1 (that's the on Revit likes),~~ RevitTask 3.0.0, and the Owin.Host.HttpListener 4.1.0 (that one trickled over from the webserver)
59 |
60 | ### Remote GraphQL using BIMrx.Marconi
61 |
62 | This external command uses the same resolver, but doesn't build an internal webserver. Instead we use a Azure ServiceBus client to listen and respond to queries from a messaging layer that uses Azure AMQP. The schema is exposed on a web page https://marconi4revitwebapp.azurewebsites.net/ and in the Revit addin. The request and response JObjects are routed through Azure Service Bus queues.
63 |
64 | Dependencies do not include OWIN stuff. Instead, we have GraphQL ~~2.4.0.~~ 3.0.0, GraphQL.SystemTextJson 3.0.0, Newtonsoft JSON 10.0.3 (required by ServiceBus ~~GraphQL, and newer versions won't work, unfortunately~~), RevitTask 3.0.0, and Microsoft.Azure.ServiceBus 4.1.3 together with Microsoft.Identity.Client 4.17.0.
65 |
66 | ## GraphQL Routes and Elements
67 |
68 | 1) hello returns the path of your revit file
69 | 1) FamilyCategories, Families, FamilySymbols
70 | 1) FamilyInstances with Parameters
71 | 1) ViewSchedules with data
72 | 1) MEP Systems - name, mep domain, and traversal of MEP Tree
73 | 1) Assemblies - entrance only: id, name
74 | 1) Sheets - entrance only: id, name
75 | 1) Phases - entrance only: id, name
76 |
77 | there is a mutation that let's you change parameters.
78 |
79 | ## .addin files to load the revit commands
80 |
81 | ~~~ XML
82 |
83 |
84 |
85 | Local GraphQL Endpoint
86 | C:\Users\xyz\source\repos\Revit2GraphQL\src\RevitGraphQLCommand\bin\Debug\RevitGraphQLCommand.dll
87 | 73dc677a-5a96-41dd-b3be-ca81d06dfc2c
88 | RevitGraphQLCommand.App
89 | Microdesk
90 | https://www.microdesk.com/bimrx/
91 |
92 |
93 | ~~~
94 |
95 | ~~~ XML
96 |
97 |
98 |
99 | BIMrx.Marconi
100 | C:\Users\xyz\source\repos\Revit2GraphQL\src\RevitMarconiCommand\bin\Debug\RevitMarconiCommand.dll
101 | 26516f0e-cdb2-43d0-9169-b4473db259ac
102 | RevitMarconiCommand.App
103 | Microdesk
104 | https://www.microdesk.com/bimrx/
105 |
106 |
107 | ~~~
108 |
109 |
110 |
--------------------------------------------------------------------------------
/graphiql.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BIMrxLAB/Revit2GraphQL/150d7d0de0be57fd433a4b2ff91886100130c182/graphiql.png
--------------------------------------------------------------------------------
/src/GraphQL4Revit.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30011.22
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RevitGraphQLResolver", "RevitGraphQLResolver\RevitGraphQLResolver.csproj", "{F5E2F94E-DC93-4A71-A8DF-5C13D97BC601}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RevitWebServer", "RevitWebServer\RevitWebServer.csproj", "{053728E3-50DB-46BF-9D23-772570BD24B7}"
9 | EndProject
10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RevitGraphQLSchema", "RevitGraphQLSchema\RevitGraphQLSchema.csproj", "{B5B78760-CC43-477D-A6EE-CE1276DCCB66}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RevitMarconiCommand", "RevitMarconiCommand\RevitMarconiCommand.csproj", "{DC38D4E5-D9CC-41B8-AA8E-B7722B6DB47A}"
13 | EndProject
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RevitGraphQLCommand", "RevitGraphQLCommand\RevitGraphQLCommand.csproj", "{A60D9874-A5E5-4E2B-8660-EB51CC2C60B3}"
15 | EndProject
16 | Global
17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
18 | Debug|Any CPU = Debug|Any CPU
19 | Release|Any CPU = Release|Any CPU
20 | EndGlobalSection
21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
22 | {F5E2F94E-DC93-4A71-A8DF-5C13D97BC601}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 | {F5E2F94E-DC93-4A71-A8DF-5C13D97BC601}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 | {F5E2F94E-DC93-4A71-A8DF-5C13D97BC601}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 | {F5E2F94E-DC93-4A71-A8DF-5C13D97BC601}.Release|Any CPU.Build.0 = Release|Any CPU
26 | {053728E3-50DB-46BF-9D23-772570BD24B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {053728E3-50DB-46BF-9D23-772570BD24B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {053728E3-50DB-46BF-9D23-772570BD24B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {053728E3-50DB-46BF-9D23-772570BD24B7}.Release|Any CPU.Build.0 = Release|Any CPU
30 | {B5B78760-CC43-477D-A6EE-CE1276DCCB66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31 | {B5B78760-CC43-477D-A6EE-CE1276DCCB66}.Debug|Any CPU.Build.0 = Debug|Any CPU
32 | {B5B78760-CC43-477D-A6EE-CE1276DCCB66}.Release|Any CPU.ActiveCfg = Release|Any CPU
33 | {B5B78760-CC43-477D-A6EE-CE1276DCCB66}.Release|Any CPU.Build.0 = Release|Any CPU
34 | {DC38D4E5-D9CC-41B8-AA8E-B7722B6DB47A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35 | {DC38D4E5-D9CC-41B8-AA8E-B7722B6DB47A}.Debug|Any CPU.Build.0 = Debug|Any CPU
36 | {DC38D4E5-D9CC-41B8-AA8E-B7722B6DB47A}.Release|Any CPU.ActiveCfg = Release|Any CPU
37 | {DC38D4E5-D9CC-41B8-AA8E-B7722B6DB47A}.Release|Any CPU.Build.0 = Release|Any CPU
38 | {A60D9874-A5E5-4E2B-8660-EB51CC2C60B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39 | {A60D9874-A5E5-4E2B-8660-EB51CC2C60B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
40 | {A60D9874-A5E5-4E2B-8660-EB51CC2C60B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
41 | {A60D9874-A5E5-4E2B-8660-EB51CC2C60B3}.Release|Any CPU.Build.0 = Release|Any CPU
42 | EndGlobalSection
43 | GlobalSection(SolutionProperties) = preSolution
44 | HideSolutionNode = FALSE
45 | EndGlobalSection
46 | GlobalSection(ExtensibilityGlobals) = postSolution
47 | SolutionGuid = {580F69E9-E6F4-4647-BB23-08D52F7315B7}
48 | EndGlobalSection
49 | EndGlobal
50 |
--------------------------------------------------------------------------------
/src/RevitGraphQLCommand/App.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 | using System.Threading;
6 | using System.Windows.Media.Imaging;
7 | using System.Windows.Threading;
8 | using Autodesk.Revit.UI;
9 | using Autodesk.Revit.UI.Events;
10 |
11 | namespace RevitGraphQLCommand
12 | {
13 | ///
14 | /// This is the main class which defines the Application, and inherits from Revit's
15 | /// IExternalApplication class.
16 | ///
17 | class App : IExternalApplication
18 | {
19 | // class instance
20 | public static App ThisApp;
21 |
22 | // ModelessForm instance
23 | private Ui _mMyForm;
24 |
25 | // Separate thread to run Ui on
26 | private Thread _uiThread;
27 |
28 | public Result OnStartup(UIControlledApplication a)
29 | {
30 | _mMyForm = null; // no dialog needed yet; the command will bring it
31 | ThisApp = this; // static access to this application instance
32 |
33 | // Method to add Tab and Panel
34 | RibbonPanel panel = RibbonPanel(a);
35 | string thisAssemblyPath = Assembly.GetExecutingAssembly().Location;
36 |
37 | // BUTTON FOR THE MULTI-THREADED WPF OPTION
38 | if (panel.AddItem(
39 | new PushButtonData("Local GraphQL", "Local GraphQL", thisAssemblyPath,
40 | "RevitGraphQLCommand.EntryCommandSeparateThread")) is PushButton button2)
41 | {
42 | button2.ToolTip = "Visual interface to start/stop local GraphQL endpoint.";
43 | Uri uriImage = new Uri("pack://application:,,,/RevitGraphQLCommand;component/Resources/graphql.png");
44 | BitmapImage largeImage = new BitmapImage(uriImage);
45 | button2.LargeImage = largeImage;
46 | }
47 |
48 |
49 |
50 | // listeners/watchers for external events (if you choose to use them)
51 | a.ApplicationClosing += a_ApplicationClosing; //Set Application to Idling
52 | a.Idling += a_Idling;
53 |
54 | return Result.Succeeded;
55 | }
56 |
57 | ///
58 | /// What to do when the application is shut down.
59 | ///
60 | public Result OnShutdown(UIControlledApplication a)
61 | {
62 | return Result.Succeeded;
63 | }
64 |
65 | ///
66 | /// This is the method which launches the WPF window in a separate thread, and injects any methods that are
67 | /// wrapped by ExternalEventHandlers. This can be done in a number of different ways, and
68 | /// implementation will differ based on how the WPF is set up.
69 | ///
70 | /// The Revit UIApplication within the add-in will operate.
71 | public void ShowFormSeparateThread(UIApplication uiapp)
72 | {
73 | // If we do not have a thread started or has been terminated start a new one
74 | if (!(_uiThread is null) && _uiThread.IsAlive) return;
75 | //EXTERNAL EVENTS WITH ARGUMENTS
76 | //https://thebuildingcoder.typepad.com/blog/2020/02/external-communication-and-async-await-event-wrapper.html#2
77 | //https://github.com/WhiteSharq/RevitTask
78 |
79 | RevitTask aRevitTask = new RevitTask();
80 |
81 |
82 | _uiThread = new Thread(() =>
83 | {
84 | SynchronizationContext.SetSynchronizationContext(
85 | new DispatcherSynchronizationContext(
86 | Dispatcher.CurrentDispatcher));
87 | // The dialog becomes the owner responsible for disposing the objects given to it.
88 | _mMyForm = new Ui(uiapp, aRevitTask);
89 | _mMyForm.Closed += (s, e) => Dispatcher.CurrentDispatcher.InvokeShutdown();
90 | _mMyForm.Show();
91 | Dispatcher.Run();
92 | });
93 |
94 | _uiThread.SetApartmentState(ApartmentState.STA);
95 | _uiThread.IsBackground = true;
96 | _uiThread.Start();
97 | }
98 |
99 | #region Idling & Closing
100 |
101 | ///
102 | /// What to do when the application is idling. (Ideally nothing)
103 | ///
104 | void a_Idling(object sender, IdlingEventArgs e)
105 | {
106 | }
107 |
108 | ///
109 | /// What to do when the application is closing.)
110 | ///
111 | void a_ApplicationClosing(object sender, ApplicationClosingEventArgs e)
112 | {
113 | }
114 |
115 | #endregion
116 |
117 | #region Ribbon Panel
118 |
119 | public RibbonPanel RibbonPanel(UIControlledApplication a)
120 | {
121 |
122 | string tab = "GraphQL"; // Tab name
123 |
124 | // Empty ribbon panel
125 | RibbonPanel ribbonPanel = null;
126 | // Try to create ribbon tab.
127 | try
128 | {
129 | a.CreateRibbonTab(tab);
130 | }
131 | catch (Exception ex)
132 | {
133 | Util.HandleError(ex);
134 | }
135 |
136 | // Try to create ribbon panel.
137 | try
138 | {
139 | RibbonPanel panel = a.CreateRibbonPanel(tab, "Local");
140 | }
141 | catch (Exception ex)
142 | {
143 | Util.HandleError(ex);
144 | }
145 |
146 | // Search existing tab for your panel.
147 | List panels = a.GetRibbonPanels(tab);
148 | foreach (RibbonPanel p in panels.Where(p => p.Name == "Local"))
149 | {
150 | ribbonPanel = p;
151 | }
152 |
153 | //return panel
154 | return ribbonPanel;
155 | }
156 |
157 | #endregion
158 | }
159 | }
--------------------------------------------------------------------------------
/src/RevitGraphQLCommand/EntryCommandSeparateThread.cs:
--------------------------------------------------------------------------------
1 | using Autodesk.Revit.Attributes;
2 | using Autodesk.Revit.DB;
3 | using Autodesk.Revit.UI;
4 | using RevitWebServer;
5 | using System;
6 | using System.IO;
7 | using System.Linq;
8 | using System.Reflection;
9 | using System.Text;
10 |
11 | namespace RevitGraphQLCommand
12 | {
13 |
14 | ///
15 | /// This is the ExternalCommand which gets executed from the ExternalApplication. In a WPF context,
16 | /// this can be lean, as it just needs to show the WPF. Without a UI, this could contain the main
17 | /// order of operations for executing the business logic.
18 | ///
19 | [Transaction(TransactionMode.Manual)]
20 | public class EntryCommandSeparateThread : IExternalCommand
21 | {
22 | public virtual Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
23 | {
24 |
25 | AppDomain currentDomain = AppDomain.CurrentDomain;
26 | currentDomain.AssemblyResolve += new ResolveEventHandler(MyResolveEventHandler);
27 |
28 | try
29 | {
30 | App.ThisApp.ShowFormSeparateThread(commandData.Application);
31 | return Result.Succeeded;
32 | }
33 | catch (Exception ex)
34 | {
35 | message = ex.Message;
36 | return Result.Failed;
37 | }
38 |
39 |
40 | }
41 |
42 |
43 | // thank you Ken
44 | // https://forums.autodesk.com/t5/navisworks-api/could-not-load-file-or-assembly-newtonsoft-json/m-p/7460535#M3467
45 | private Assembly MyResolveEventHandler(object sender, ResolveEventArgs args)
46 | {
47 | if (args.Name.Contains("Microsoft.Owin"))
48 | {
49 | string assemblyFileName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Microsoft.Owin.dll";
50 | return Assembly.LoadFrom(assemblyFileName);
51 | }
52 | else
53 | {
54 | return null;
55 | }
56 | }
57 |
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/RevitGraphQLCommand/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("RevitCommand")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("RevitCommand")]
13 | [assembly: AssemblyCopyright("Copyright © 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("a60d9874-a5e5-4e2b-8660-eb51cc2c60b3")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/RevitGraphQLCommand/Resources/graphql.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BIMrxLAB/Revit2GraphQL/150d7d0de0be57fd433a4b2ff91886100130c182/src/RevitGraphQLCommand/Resources/graphql.png
--------------------------------------------------------------------------------
/src/RevitGraphQLCommand/Revit2GraphQL.addin:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Local GraphQL Endpoint
5 | RevitGraphQLCommand/RevitGraphQLCommand.dll
6 | 73dc677a-5a96-41dd-b3be-ca81d06dfc2c
7 | RevitGraphQLCommand.App
8 | Microdesk
9 | https://www.microdesk.com/bimrx/
10 |
11 |
--------------------------------------------------------------------------------
/src/RevitGraphQLCommand/RevitGraphQLCommand.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {A60D9874-A5E5-4E2B-8660-EB51CC2C60B3}
8 | Library
9 | Properties
10 | RevitGraphQLCommand
11 | RevitGraphQLCommand
12 | v4.7.2
13 | 512
14 | true
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 | ..\packages\Microsoft.Owin.Host.HttpListener.4.1.1\lib\net45\Microsoft.Owin.Host.HttpListener.dll
36 |
37 |
38 |
39 |
40 | False
41 | ..\..\..\..\..\..\..\Program Files\Autodesk\Revit 2020\RevitAPI.dll
42 |
43 |
44 | False
45 | ..\..\..\..\..\..\..\Program Files\Autodesk\Revit 2020\RevitAPIUI.dll
46 |
47 |
48 | ..\packages\RevitTask.3.0.0\lib\net47\RevitTask.dll
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 | Ui.xaml
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | Always
75 |
76 |
77 |
78 |
79 | {f5e2f94e-dc93-4a71-a8df-5c13d97bc601}
80 | RevitGraphQLResolver
81 |
82 |
83 | {b5b78760-cc43-477d-a6ee-ce1276dccb66}
84 | RevitGraphQLSchema
85 |
86 |
87 | {053728e3-50db-46bf-9d23-772570bd24b7}
88 | RevitWebServer
89 |
90 |
91 |
92 |
93 | Designer
94 | MSBuild:Compile
95 |
96 |
97 |
98 |
99 | Always
100 |
101 |
102 |
103 |
104 | if $(ConfigurationName) == Debug (
105 | mkdir "$(AppData)\Autodesk\REVIT\Addins\2020\$(TargetName)\"
106 | if exist "$(AppData)\Autodesk\REVIT\Addins\2020" copy "$(TargetDir)*.addin" "$(AppData)\Autodesk\REVIT\Addins\2020\"
107 | if exist "$(AppData)\Autodesk\REVIT\Addins\2020" copy "$(TargetDir)*" "$(AppData)\Autodesk\REVIT\Addins\2020\$(TargetName)\"
108 |
109 | )
110 |
111 |
112 |
--------------------------------------------------------------------------------
/src/RevitGraphQLCommand/Ui.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/RevitGraphQLCommand/Ui.xaml.cs:
--------------------------------------------------------------------------------
1 | using Autodesk.Revit.DB;
2 | using Autodesk.Revit.UI;
3 | using RevitWebServer;
4 | using System;
5 | using System.Windows;
6 |
7 | namespace RevitGraphQLCommand
8 | {
9 | ///
10 | /// Interaction logic for UI.xaml
11 | ///
12 | public partial class Ui : Window
13 | {
14 | private readonly UIDocument _uiDoc;
15 | private readonly Document _doc;
16 | public WebServer aWebServer { get; set; }
17 |
18 | RevitTask aRevitTask;
19 | public Ui(UIApplication uiApp, RevitTask _aRevitTask)
20 | {
21 | _uiDoc = uiApp.ActiveUIDocument;
22 | _doc = _uiDoc.Document;
23 |
24 | Closed += MainWindow_Closed;
25 |
26 | InitializeComponent();
27 | aRevitTask = _aRevitTask;
28 |
29 | }
30 |
31 | private void MainWindow_Closed(object sender, EventArgs e)
32 | {
33 | Close();
34 | }
35 |
36 | private void CheckBox_Checked(object sender, RoutedEventArgs e)
37 | {
38 | aWebServer = new WebServer("localhost", txtPort.Text, _doc, _uiDoc, aRevitTask);
39 | aWebServer.Start();
40 | }
41 |
42 | private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
43 | {
44 | aWebServer.Stop();
45 | }
46 |
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/RevitGraphQLCommand/Util.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Threading;
4 |
5 | namespace RevitGraphQLCommand
6 | {
7 | public static class Util
8 | {
9 | public static void LogThreadInfo(string name = "")
10 | {
11 | Thread th = Thread.CurrentThread;
12 | Debug.WriteLine($"Task Thread ID: {th.ManagedThreadId}, Thread Name: {th.Name}, Process Name: {name}");
13 | }
14 |
15 | public static void HandleError(Exception ex)
16 | {
17 | Debug.WriteLine(ex.Message);
18 | Debug.WriteLine(ex.Source);
19 | Debug.WriteLine(ex.StackTrace);
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/src/RevitGraphQLCommand/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/src/RevitGraphQLCommand/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/src/RevitGraphQLResolver/GraphQL/GraphQLHelpers.cs:
--------------------------------------------------------------------------------
1 | using GraphQL;
2 | using GraphQL.Language.AST;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 |
6 | namespace RevitGraphQLResolver.GraphQL
7 | {
8 | public static class GraphQlHelpers
9 | {
10 | public static List GetArgumentStrings(Field aField, string name)
11 | {
12 | var nameFilterArgument = aField.Arguments?.FirstOrDefault(x => x.Name == name);
13 | List nameFilterStrings = new List();
14 | if (nameFilterArgument != null)
15 | {
16 | nameFilterStrings = (nameFilterArgument.Value.Value as List