Skip to content

Commit

Permalink
add image cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
johnpierson committed Apr 19, 2024
1 parent b353834 commit c5e070b
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 13 deletions.
Binary file modified _Release/Revit2021/Relay/Relay.dll
Binary file not shown.
Binary file modified _Release/Revit2022/Relay/Relay.dll
Binary file not shown.
Binary file modified _Release/Revit2023/Relay/Relay.dll
Binary file not shown.
Binary file modified _Release/Revit2024/Relay/Relay.dll
Binary file not shown.
Binary file modified _Release/Revit2025/Relay/Relay.dll
Binary file not shown.
22 changes: 20 additions & 2 deletions src/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class App : IExternalApplication
{
public Result OnStartup(UIControlledApplication a)
{
CleanupOldImages();

//set the Revit version for reuse
Globals.RevitVersion = a.ControlledApplication.VersionNumber;

Expand All @@ -26,8 +28,6 @@ public Result OnStartup(UIControlledApplication a)
var resetRibbon = relayIni.Read("ResetRibbon", "Settings");
//it the path is default, read that
Globals.BasePath = path.ToLower().Equals("default") ? Globals.ExecutingPath : path;

Globals.ResetRibbonOnSync = bool.Parse(resetRibbon);
}
//you screwed up the path mapping, sorry this tool is using the default then
catch (Exception)
Expand Down Expand Up @@ -159,5 +159,23 @@ private void ComponentManagerOnUIElementActivated(object sender, UIElementActiva
// suppress the error if it happens
}
}

internal void CleanupOldImages()
{
var relayImages = Directory.GetFiles(Globals.UserTemp, "relayImage*.png");

foreach (var image in relayImages)
{
try
{
File.Delete(image);
}
catch (Exception)
{
//do nothing
}

}
}
}
}
7 changes: 0 additions & 7 deletions src/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ public Result Execute(ExternalCommandData commandData, ref string message, Eleme
{
UIApplication uiapp = commandData.Application;

#if DEBUG
//if (Globals.ResetRibbonOnSync)
//{
// RibbonUtils.ClearRibbon();
//}
#endif

RibbonUtils.SyncGraphs(uiapp);
RibbonUtils.HideUnused();

Expand Down
2 changes: 0 additions & 2 deletions src/Utilities/Globals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ public partial class Globals

public static string CurrentGraphToRun { get; set; } = "";

public static bool ResetRibbonOnSync { get; set; } = false;

public static Dictionary<string, RibbonItem> RelayButtons = new Dictionary<string, RibbonItem>();
public static Dictionary<string, List<RibbonItem>> RelayPanels = new Dictionary<string, List<RibbonItem>>();

}
}
4 changes: 2 additions & 2 deletions src/Utilities/RibbonUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static void AddItems(Autodesk.Revit.UI.RibbonPanel panelToUse, string[] d
//trying out using temp icons to enable button hiding and deleting later
if (File.Exists(icon32))
{
var temp32 = Path.Combine(Globals.UserTemp, $"{Guid.NewGuid().ToString()}.png");
var temp32 = Path.Combine(Globals.UserTemp, $"relayImage{Guid.NewGuid()}.png");
File.Copy(icon32, temp32);
icon32 = temp32;
}
Expand All @@ -63,7 +63,7 @@ public static void AddItems(Autodesk.Revit.UI.RibbonPanel panelToUse, string[] d
//trying out using temp icons to enable button hiding and deleting later
if (File.Exists(icon16))
{
var temp16 = Path.Combine(Globals.UserTemp, $"{Guid.NewGuid().ToString()}.png");
var temp16 = Path.Combine(Globals.UserTemp, $"relayImage{Guid.NewGuid()}.png");
File.Copy(icon16, temp16);
icon16 = temp16;
}
Expand Down

0 comments on commit c5e070b

Please sign in to comment.