How can I control if Rhino’s automatic file saving mechanism is running on RhinoCommon? On RhinoDotNet I used “RhUtil.RhinoApp( ).AppSettings( ).FileSettings( ).m_autosave”, but I don’t find any similar boolean variable. I need to make difference between autosave from Rhino and save from user.
Thanks, but I want to know if Rhino is saving automaticly the file, or the user is saving the file. In RhinoDoNet “m_autosave” is true if Rhino is saving, and false if user is saving. In RhinoCommon, “AutoSaveEnabled” is true if Rhino’s automatic file saving mechanism is enabled, so if user save the file, could be true.
Cant get it to work. Ill try to explain.
I’m adding a AddHandler Rhino.RhinoDoc.EndSaveDocument, AddressOf SaveDocument in OnLoad
Private Sub SaveDocument(ByVal sender As Object, ByVal e As Rhino.DocumentSaveEventArgs)
Dim App_Path = Rhino.RhinoDoc.ActiveDoc.Path
If App_Path <> "" Then
Dim saved As Date = System.IO.File.GetLastWriteTime(App_Path)
Dim datenow As Date = Now
Dim result = DateTime.Compare(saved, datenow.AddSeconds(-2))
If result < 0 Then
MsgBox("Autosave")
ElseIf result = 0 Then
MsgBox("User")
Else
MsgBox("User")
End If
End If
End Sub
What it should do is check the date of the file, compare it with Date.Now. If it is less then 2 seconds difference. Say its user. Else Autosave.
But it only works if you save 2 times after eachother fast because I guess EndSaveDocument is used just before it “Saves” the file.
Thanks for your help. I only wanted to know if there was any variable that indicates if atusave is running. But it seems on RhinoCommon doesn’t exists. I finally solved it checking the most recent command. If the most recent command is “Save”, I know user is saving.
File can be autosaved with command “_Autosave” (that’s controlled in the first part of the “if”).
In the second part, I use “Rhino.Commands.Command.InCommand( )” because when Rhino autosave automatically, does not run any command, but if InCommand( ) is false, and I am writing the file, I know Rhino is autosaving.
InCommand( ) indicates if Rhino is currently running a command.
I need it because user is working with some temporal geometries that I don’t write in the file. When user saves I delete these geometries. He knows that when he saves, these temporal geometries will disappear. But, if suddenly Rhino autosaves and the user is working with these geometries, it will dissapear too. I have to control this, deleting the geometries only when user saves.
I thought that on RhinoDoNet m_autosave indicates if Rhino is autosaving, but I think I was wrong, indicates if Rhino autosave is enable, like AutoSaveEnabled on RhinoCommon. I started the migration from RhinoDotNet to RhinoCommon just in that moment and I didn’t test it well.
Anyway, I think I have solved it doing what I explained on my last post.