Skip to content

Commit

Permalink
Fixes #1, Addresses #5 (need to verify)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnpierson committed Apr 6, 2023
1 parent e9667a7 commit ea3d066
Show file tree
Hide file tree
Showing 11 changed files with 145 additions and 31 deletions.
Binary file modified _Release/2023/Fetch.dll
Binary file not shown.
Binary file added _Release/2024/Fetch.dll
Binary file not shown.
9 changes: 3 additions & 6 deletions src/Fetch.2023/Fetch.2023.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,17 @@
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Revit_All_Main_Versions_API_x64">
<Version>2023.0.0</Version>
</PackageReference>
<PackageReference Include="WindowsAPICodePack">
<Version>1.1.2</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<None Include="Fetch.addin" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<Import Project="..\Fetch.SharedProject\Fetch.SharedProject.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
Expand Down
73 changes: 73 additions & 0 deletions src/Fetch.2024/Fetch.2024.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{9C839D66-9571-42EA-B54F-D1C0A2BA2B16}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Fetch</RootNamespace>
<AssemblyName>Fetch</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="PresentationCore" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Windows.Presentation" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Revit_All_Main_Versions_API_x64">
<Version>2024.0.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<None Include="Fetch.addin" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<Import Project="..\Fetch.SharedProject\Fetch.SharedProject.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>if $(ConfigurationName) == Debug copy "$(ProjectDir)..\Fetch.SharedProject\Fetch-Debug.addin" "$(AppData)\Autodesk\REVIT\Addins\2024"
if $(ConfigurationName) == Debug copy "$(ProjectDir)$(OutputPath)Fetch.dll" "$(AppData)\Autodesk\REVIT\Addins\2024\fetch"

if $(ConfigurationName) == Release copy "$(ProjectDir)$(OutputPath)Fetch.dll" "$(ProjectDir)..\..\_Release\2024"
if $(ConfigurationName) == Release copy "$(ProjectDir)Fetch.addin" "$(ProjectDir)..\..\_Release"</PostBuildEvent>
</PropertyGroup>
</Project>
11 changes: 11 additions & 0 deletions src/Fetch.2024/Fetch.addin
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<RevitAddIns>
<AddIn Type="Application">
<Name>Fetch</Name>
<Assembly>.\Fetch\Fetch.dll</Assembly>
<FullClassName>Fetch.App</FullClassName>
<ClientId>5f9dbc60-6b94-4138-ae16-fa49ffc3e6ce</ClientId>
<VendorId>DesignTechUnraveled</VendorId>
<VendorDescription>Design Tech Unraveled, http://designtechunraveled.com</VendorDescription>
</AddIn>
</RevitAddIns>
40 changes: 37 additions & 3 deletions src/Fetch.SharedProject/App.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Autodesk.Revit.UI;
Expand All @@ -9,13 +11,16 @@ internal class App : IExternalApplication
{
public Result OnStartup(UIControlledApplication application)
{
//store revit version
Globals.RevitVersion = application.ControlledApplication.VersionNumber;

//try to find the dynamo version and see if it is running already in a revit session with the same version
if (!FindDynamoVersions())
{
return Result.Failed;
}

Globals.TaskbarManager = Microsoft.WindowsAPICodePack.Taskbar.TaskbarManager.Instance;
Globals.TaskbarManager.SetProgressValue(0, 3);
VerifyDynamoLoaded();

//if the URL is local, then we do a copy
Commands.Commands.ReadIni();
Expand Down Expand Up @@ -66,7 +71,36 @@ public bool FindDynamoVersions()

return true;
}
/// <summary>
/// Gets all processes running on the machine then checks if they are "Revit" based. Then if it does find any it checks if Dynamo dll's are in memory.
/// If yes it changes Global "IsDynamoInMemory" to True
/// </summary>
public static void VerifyDynamoLoaded()
{
List<bool> tempBoolList = new List<bool>();

foreach (Process process in Process.GetProcessesByName("revit"))
{
if (process.MainModule.FileName.Contains(Globals.RevitVersion))
{
foreach (ProcessModule module in process.Modules)
{
if (module.FileName.ToLower().Contains("dynamo"))
{
tempBoolList.Add(true);
}
}
}
}
if (tempBoolList.Count() > 0)
{
Globals.IsDynamoInMemory = true;
}
else
{
Globals.IsDynamoInMemory = false;
}
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Fetch")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyCopyright("Copyright © 2023 Design Tech Unraveled")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2023.0.0.1")]
[assembly: AssemblyFileVersion("2023.0.0.1")]
[assembly: AssemblyVersion("0.0.2")]
[assembly: AssemblyFileVersion("0.0.2")]
15 changes: 3 additions & 12 deletions src/Fetch.SharedProject/Commands/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
using Autodesk.Internal.Windows;
using Autodesk.Windows;
using Fetch.Classes;
using Microsoft.WindowsAPICodePack.Taskbar;
using UIFramework;

using FontFamily = System.Windows.Media.FontFamily;

namespace Fetch.Commands
Expand All @@ -26,8 +25,6 @@ internal class Commands

internal static string DownloadPath = Path.Combine(Globals.TempPath,$"{DateTime.Now:yyyyMMdd}_packages.zip");

internal static TaskbarManager TaskbarManager;


public static void ReadIni()
{
Expand Down Expand Up @@ -60,9 +57,7 @@ private static void UnzipPackages()
{
DeleteOldPackages();
System.IO.Compression.ZipFile.ExtractToDirectory(DownloadPath, Globals.DefaultDynamoPackagePath);
Globals.TaskbarManager.SetProgressValue(3, 3);
Globals.TaskbarManager.SetProgressState(TaskbarProgressBarState.NoProgress);


ShowNotification();
}

Expand All @@ -78,7 +73,6 @@ private static void DeleteOldPackages()
{
dir.Delete(true);
}
Globals.TaskbarManager.SetProgressValue(2, 3);
}

internal static void SyncPackagesFromLocalPath()
Expand Down Expand Up @@ -130,7 +124,6 @@ private static void DownloadFileCallback2(object sender, AsyncCompletedEventArgs
return;
}

Globals.TaskbarManager.SetProgressValue(1, 3);

UnzipPackages();
}
Expand All @@ -142,14 +135,12 @@ private static void DownloadFileCallback2(object sender, AsyncCompletedEventArgs
/// <param name="e"></param>
private static void FdOnDownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
Globals.TaskbarManager.SetProgressValue(1,3);

UnzipPackages();
}

private static void PackageWatcherOnCreated(object sender, FileSystemEventArgs e)
{
TaskbarManager.SetProgressValue(10,100);

}

#endregion
Expand Down
1 change: 1 addition & 0 deletions src/Fetch.SharedProject/Fetch.SharedProject.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)App.cs" />
<Compile Include="$(MSBuildThisFileDirectory)AssemblyInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Classes\FetchIniFile.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Commands\Commands.cs" />
<Compile Include="$(MSBuildThisFileDirectory)FileDownloader.cs" />
Expand Down
6 changes: 3 additions & 3 deletions src/Fetch.SharedProject/Globals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
using System.IO;
using System.Reflection;
using System.Text;
using Microsoft.WindowsAPICodePack.Taskbar;

namespace Fetch
{
internal class Globals
{
internal static string RevitVersion { get; set; }
internal static string ExecutingPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
public static string UserRoaming => Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

public static string TempPath = Path.GetTempPath();
public static Version DynamoVersion { get; set; }
public static bool IsDynamoInMemory { get; set; }
public static string DefaultDynamoPackagePath { get; set; }
public static string PackageURL { get; set; }

public static FileSystemWatcher PackageWatcher { get; set; }

public static TaskbarManager TaskbarManager { get; set; }

}
}
15 changes: 11 additions & 4 deletions src/Fetch.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fetch.2023", "Fetch.2023\Fe
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Fetch.SharedProject", "Fetch.SharedProject\Fetch.SharedProject.shproj", "{A569D3FE-79A6-4A6F-80E3-66497997F859}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fetch.2024", "Fetch.2024\Fetch.2024.csproj", "{9C839D66-9571-42EA-B54F-D1C0A2BA2B16}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
Fetch.SharedProject\Fetch.SharedProject.projitems*{6dec72db-6655-495e-be15-2cdb73229785}*SharedItemsImports = 4
Fetch.SharedProject\Fetch.SharedProject.projitems*{a569d3fe-79a6-4a6f-80e3-66497997f859}*SharedItemsImports = 13
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Expand All @@ -21,11 +19,20 @@ Global
{6DEC72DB-6655-495E-BE15-2CDB73229785}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6DEC72DB-6655-495E-BE15-2CDB73229785}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6DEC72DB-6655-495E-BE15-2CDB73229785}.Release|Any CPU.Build.0 = Release|Any CPU
{9C839D66-9571-42EA-B54F-D1C0A2BA2B16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9C839D66-9571-42EA-B54F-D1C0A2BA2B16}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9C839D66-9571-42EA-B54F-D1C0A2BA2B16}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9C839D66-9571-42EA-B54F-D1C0A2BA2B16}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A6BB5E99-DF70-450B-A6A2-181D06076A69}
EndGlobalSection
GlobalSection(SharedMSBuildProjectFiles) = preSolution
Fetch.SharedProject\Fetch.SharedProject.projitems*{6dec72db-6655-495e-be15-2cdb73229785}*SharedItemsImports = 4
Fetch.SharedProject\Fetch.SharedProject.projitems*{9c839d66-9571-42ea-b54f-d1c0a2ba2b16}*SharedItemsImports = 4
Fetch.SharedProject\Fetch.SharedProject.projitems*{a569d3fe-79a6-4a6f-80e3-66497997f859}*SharedItemsImports = 13
EndGlobalSection
EndGlobal

1 comment on commit ea3d066

@johnpierson
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit includes the process checker code from @brencass

Please sign in to comment.