1
- namespace Fesh.Revit
1
+ namespace Fesh.Revit
2
2
3
3
open Autodesk.Revit .UI
4
4
open Autodesk.Revit .DB
@@ -57,7 +57,7 @@ type DebugUtils private () =
57
57
static member logToFile filePrefix ( content : string ) =
58
58
let checkedPrefix = if isNull filePrefix then " NULL-PREFIX" else filePrefix
59
59
let checkedContent = if String.IsNullOrWhiteSpace content then " content is String.IsNullOrWhiteSpace" else content
60
- let time = DateTime.UtcNow.ToString( " yyyy-MM-dd_HH-mm-ss-fff" ) // ensure unique name
60
+ let time = DateTime.UtcNow.ToString " yyyy-MM-dd_HH-mm-ss-fff" // ensure unique name
61
61
let filename = sprintf " %s Fesh.AutoCAD.Log-%s .txt" checkedPrefix time
62
62
async {
63
63
try
@@ -80,12 +80,12 @@ type DebugUtils private () =
80
80
DebugUtils.logToFile " App.alertFailed-" errMsg
81
81
TaskDialog.Show( " Fesh AddIn. normal alert failed" , errMsg) |> ignore
82
82
83
- | _ when logFileOnDesktopCount.Value < 10 ->
83
+ | _ when logFileOnDesktopCount.Value < 5 ->
84
84
incr logFileOnDesktopCount
85
85
DebugUtils.logToFile " App.alert-" msg
86
86
TaskDialog.Show( " Fesh AddIn alert" , msg) |> ignore
87
87
88
- | _ -> () // do nothing , there are already 10 log files on the desktop
88
+ | _ -> () // do nothing , there are already 5 log files on the desktop
89
89
90
90
91
91
/// logs text to Fesh editor window in green
@@ -101,6 +101,7 @@ type DebugUtils private () =
101
101
[<Transaction( TransactionMode.Manual) >]
102
102
type internal FsiRunEventHandler ( fesh : Fesh , queue : ConcurrentQueue < UIApplication -> unit >) =
103
103
member this.GetName () = " Run in Fesh"
104
+
104
105
member this.Execute ( app : UIApplication ) =
105
106
let f = ref Unchecked.defaultof< UIApplication-> unit>
106
107
while queue.TryDequeue( f) do //using a queue is only needed if a single script calls into a transaction more than once
@@ -111,7 +112,7 @@ type internal FsiRunEventHandler (fesh:Fesh, queue: ConcurrentQueue< UIApplicati
111
112
112
113
interface IExternalEventHandler with
113
114
member this.GetName () = this.GetName()
114
- member this.Execute ( app : UIApplication ) = this.Execute( app)
115
+ member this.Execute ( app : UIApplication ) = this.Execute app
115
116
116
117
117
118
[<Regeneration( RegenerationOption.Manual) >]
@@ -128,8 +129,8 @@ type FeshAddin()= // : IExternalApplication = // don't rename ! This is referenc
128
129
129
130
/// Runs a F# function via the IExternalEventHandler pattern for mode-less dialogs
130
131
/// This is the only way to run code from mode-less dialogs such as Fesh editor
131
- member this.RunOnApp ( f : UIApplication -> unit ) =
132
- this.RequestQueue.Enqueue( f )
132
+ member this.RunOnApp ( transaction : UIApplication -> unit ) =
133
+ this.RequestQueue.Enqueue transaction
133
134
match this.ExternalEv with
134
135
| None ->
135
136
DebugUtils.alert " ExternalEvent not set up yet"
@@ -143,8 +144,8 @@ type FeshAddin()= // : IExternalApplication = // don't rename ! This is referenc
143
144
144
145
/// runs a F# function via the IExternalEventHandler pattern for mode-less dialogs
145
146
/// this is the only way to run code from mode-less dialogs such as Fesh editor
146
- member this.RunOnDoc ( f : Document -> unit ) =
147
- this.RunOnApp ( fun app -> f app.ActiveUIDocument.Document)
147
+ member this.RunOnDoc ( transaction : Document -> unit ) =
148
+ this.RunOnApp ( fun app -> transaction app.ActiveUIDocument.Document)
148
149
149
150
150
151
member this.OnStartup ( uiConApp : UIControlledApplication ) =
@@ -157,15 +158,15 @@ type FeshAddin()= // : IExternalApplication = // don't rename ! This is referenc
157
158
let button = new PushButtonData( " Fesh" , " Open Fesh F# Editor" , thisAssemblyPath, " Fesh.Revit.StartEditorCommand" ) // a reference to type StartEditorCommand()
158
159
button.ToolTip <- " This will open Fesh in a new window, the F# Scripting Editor."
159
160
160
- let uriImage32 = new Uri( " pack://application:,,,/Fesh.Revit;component/Media32/logo32.png" ) // build from VS not via "dotnet build" to include. <Resource Include="Media\LogoCursorTr32.png" />
161
- let uriImage16 = new Uri( " pack://application:,,,/Fesh.Revit;component/Media32/logo16.png" )
162
- button.LargeImage <- Media.Imaging.BitmapImage( uriImage32) //for ribbon in tab
163
- button.Image <- Media.Imaging.BitmapImage( uriImage16) //for quick access toolbar
161
+ let uriImage32 = new Uri " pack://application:,,,/Fesh.Revit;component/Media32/logo32.png" // build from VS not via "dotnet build" to include. <Resource Include="Media\LogoCursorTr32.png" />
162
+ let uriImage16 = new Uri " pack://application:,,,/Fesh.Revit;component/Media32/logo16.png"
163
+ button.LargeImage <- Media.Imaging.BitmapImage uriImage32 //for ribbon in tab
164
+ button.Image <- Media.Imaging.BitmapImage uriImage16 //for quick access toolbar
164
165
165
166
let tabId = " Fesh"
166
167
uiConApp.CreateRibbonTab( tabId)
167
168
let panel = uiConApp.CreateRibbonPanel( tabId, " Fesh" )
168
- panel.AddItem( button) |> ignore
169
+ panel.AddItem button |> ignore
169
170
170
171
Result.Succeeded
171
172
@@ -192,8 +193,8 @@ type FeshAddin()= // : IExternalApplication = // don't rename ! This is referenc
192
193
193
194
194
195
interface IExternalApplication with
195
- member this.OnStartup ( uiConApp : UIControlledApplication ) = this.OnStartup( uiConApp)
196
- member this.OnShutdown ( app : UIControlledApplication ) = this.OnShutdown( app)
196
+ member this.OnStartup ( uiConApp : UIControlledApplication ) = this.OnStartup uiConApp
197
+ member this.OnShutdown ( app : UIControlledApplication ) = this.OnShutdown app
197
198
198
199
//member this.Queue = queue
199
200
@@ -237,18 +238,18 @@ type StartEditorCommand() = // don't rename ! string referenced in OnStartup ->
237
238
// If Document.IsModifiable returns TRUE, then there is an active transaction open in that document.
238
239
// https://thebuildingcoder.typepad.com/blog/2015/06/archsample-active-transaction-and-adnrme-for-revit-mep-2016.html#3
239
240
240
- let appName = AppName.get( commandData.Application.Application.VersionNumber)
241
- let logo = new Uri( " pack://application:,,,/Fesh.Revit;component/Media32/logo.ico" )
241
+ let appName = AppName.get commandData.Application.Application.VersionNumber
242
+ let logo = new Uri " pack://application:,,,/Fesh.Revit;component/Media32/logo.ico"
242
243
let hostData = {
243
244
hostName = appName
244
245
mainWindowHandel = winHandle
245
246
fsiCanRun = canRun
246
247
logo = Some logo
247
- defaultCode = Some ( DefaultCode.get( appName) )
248
- hostAssembly = Some ( Reflection.Assembly.GetAssembly( typeof< FeshAddin>) )
248
+ defaultCode = Some ( DefaultCode.get appName)
249
+ hostAssembly = Some ( Reflection.Assembly.GetAssembly typeof< FeshAddin>)
249
250
}
250
251
251
- let feshApp = Fesh.App.createEditorForHosting( hostData)
252
+ let feshApp = Fesh.App.createEditorForHosting hostData
252
253
DebugUtils.Fesh <- Some feshApp
253
254
254
255
//TODO make a C# plugin that loads Fesh.addin once uiConApp.ControlledApplication.ApplicationInitialized to avoid missing method exceptions in FSI
0 commit comments