Skip to content

Commit d19056a

Browse files
committed
First Commit
1 parent 7ba2821 commit d19056a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+3135
-1
lines changed

EditRevitFile/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
5+
</startup>
6+
</configuration>

EditRevitFile/Compress/Compress.cs

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
using OpenMcdf;
2+
using System.IO;
3+
using System.Collections.Generic;
4+
5+
namespace EditRevitFile
6+
{
7+
public static class Compress
8+
{
9+
public static void RevitFile(string filesLocation, string fileSaveLoc)
10+
{
11+
RvtFile rvtFile = setRvtFileData(filesLocation);
12+
13+
CompoundFile cf = new CompoundFile();
14+
CFStream basicInfoFile = cf.RootStorage.AddStream("BasicFileInfo");
15+
basicInfoFile.SetData(rvtFile.basicFileInfo);
16+
CFStream contents = cf.RootStorage.AddStream("Contents");
17+
contents.SetData(rvtFile.contents);
18+
CFStream projectInformation = cf.RootStorage.AddStream("ProjectInformation");
19+
projectInformation.SetData(rvtFile.projectInformation);
20+
CFStream revitPreview = cf.RootStorage.AddStream("RevitPreview4.0");
21+
revitPreview.SetData(rvtFile.revitPreview40);
22+
CFStream transmissionData = cf.RootStorage.AddStream("TransmissionData");
23+
transmissionData.SetData(rvtFile.TransmissionData);
24+
25+
CFStorage formats = cf.RootStorage.AddStorage("Formats");
26+
CFStream formatsLatest = formats.AddStream("Latest");
27+
formatsLatest.SetData(rvtFile.formats.latest);
28+
29+
CFStorage global = cf.RootStorage.AddStorage("Global");
30+
CFStream contentDocuments = global.AddStream("ContentDocuments");
31+
contentDocuments.SetData(rvtFile.global.contentDocuments);
32+
CFStream documentIncrementTable = global.AddStream("DocumentIncrementTable");
33+
documentIncrementTable.SetData(rvtFile.global.documentIncrementTable);
34+
CFStream elemTable = global.AddStream("ElemTable");
35+
elemTable.SetData(rvtFile.global.elemTable);
36+
CFStream history = global.AddStream("History");
37+
history.SetData(rvtFile.global.history);
38+
CFStream globalLatest = global.AddStream("Latest");
39+
globalLatest.SetData(rvtFile.global.latest);
40+
CFStream partitionTable = global.AddStream("PartitionTable");
41+
partitionTable.SetData(rvtFile.global.partitionTable);
42+
43+
CFStorage partitions = cf.RootStorage.AddStorage("Partitions");
44+
foreach (var partition in rvtFile.partitions)
45+
{
46+
CFStream partitionStream = partitions.AddStream(partition.Key);
47+
partitionStream.SetData(partition.Value);
48+
}
49+
50+
cf.Save(fileSaveLoc);
51+
cf.Close();
52+
}
53+
54+
public static RvtFile setRvtFileData(string path)
55+
{
56+
RvtFile result = new RvtFile();
57+
result.basicFileInfo = File.ReadAllBytes(Path.Combine(path, "BasicFileInfo"));
58+
result.contents = File.ReadAllBytes(Path.Combine(path, "Contents"));
59+
result.projectInformation = File.ReadAllBytes(Path.Combine(path, "ProjectInformation"));
60+
result.revitPreview40 = File.ReadAllBytes(Path.Combine(path, "RevitPreview4.0"));
61+
result.TransmissionData = File.ReadAllBytes(Path.Combine(path, "TransmissionData"));
62+
63+
Formats formats = new Formats();
64+
formats.latest = File.ReadAllBytes(Path.Combine(path, "Formats", "Latest"));
65+
result.formats = formats;
66+
67+
Global global = new Global();
68+
global.contentDocuments = File.ReadAllBytes(Path.Combine(path, "Global", "ContentDocuments"));
69+
global.documentIncrementTable = File.ReadAllBytes(Path.Combine(path, "Global", "DocumentIncrementTable"));
70+
global.elemTable = File.ReadAllBytes(Path.Combine(path, "Global", "ElemTable"));
71+
global.history = File.ReadAllBytes(Path.Combine(path, "Global", "History"));
72+
global.latest = File.ReadAllBytes(Path.Combine(path, "Global", "Latest"));
73+
global.partitionTable = File.ReadAllBytes(Path.Combine(path, "Global", "PartitionTable"));
74+
result.global = global;
75+
76+
Dictionary<string, byte[]> partitions = new Dictionary<string, byte[]>();
77+
string partitionsPath = Path.Combine(path, "Partitions");
78+
foreach (var filePath in Directory.GetFiles(partitionsPath))
79+
{
80+
string fileName = Path.GetFileName(filePath);
81+
partitions[fileName] = File.ReadAllBytes(filePath);
82+
}
83+
result.partitions = partitions;
84+
85+
return result;
86+
}
87+
}
88+
}

EditRevitFile/EditRevitFile.csproj

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{9779A42C-D21F-4A38-8238-0C0BF02F64AC}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<RootNamespace>EditRevitFile</RootNamespace>
10+
<AssemblyName>EditRevitFile</AssemblyName>
11+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<Deterministic>true</Deterministic>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
37+
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
38+
</Reference>
39+
<Reference Include="OpenMcdf, Version=2.3.1.0, Culture=neutral, PublicKeyToken=fdbb1629d7c00800, processorArchitecture=MSIL">
40+
<HintPath>..\packages\OpenMcdf.2.3.1\lib\net40\OpenMcdf.dll</HintPath>
41+
</Reference>
42+
<Reference Include="System" />
43+
<Reference Include="System.Core" />
44+
<Reference Include="System.IO.Packaging, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
45+
<HintPath>..\packages\System.IO.Packaging.8.0.0\lib\net462\System.IO.Packaging.dll</HintPath>
46+
</Reference>
47+
<Reference Include="System.Xml.Linq" />
48+
<Reference Include="System.Data.DataSetExtensions" />
49+
<Reference Include="Microsoft.CSharp" />
50+
<Reference Include="System.Data" />
51+
<Reference Include="System.Deployment" />
52+
<Reference Include="System.Drawing" />
53+
<Reference Include="System.Net.Http" />
54+
<Reference Include="System.Windows.Forms" />
55+
<Reference Include="System.Xml" />
56+
<Reference Include="WindowsBase" />
57+
</ItemGroup>
58+
<ItemGroup>
59+
<Compile Include="Compress\Compress.cs" />
60+
<Compile Include="Form1.cs">
61+
<SubType>Form</SubType>
62+
</Compile>
63+
<Compile Include="Form1.Designer.cs">
64+
<DependentUpon>Form1.cs</DependentUpon>
65+
</Compile>
66+
<Compile Include="FormAux\FileEncoding.cs" />
67+
<Compile Include="FormAux\GetInfo.cs" />
68+
<Compile Include="FormAux\ProcessRevitFile.cs" />
69+
<Compile Include="FormAux\WritteInfo.cs" />
70+
<Compile Include="Objects\CMDF.cs" />
71+
<Compile Include="Objects\InfoConfigUser.cs" />
72+
<Compile Include="Objects\RvtFile.cs" />
73+
<Compile Include="Preview\PreviewEdit.cs" />
74+
<Compile Include="Program.cs" />
75+
<Compile Include="Properties\AssemblyInfo.cs" />
76+
<EmbeddedResource Include="Form1.resx">
77+
<DependentUpon>Form1.cs</DependentUpon>
78+
</EmbeddedResource>
79+
<EmbeddedResource Include="Properties\Resources.resx">
80+
<Generator>ResXFileCodeGenerator</Generator>
81+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
82+
<SubType>Designer</SubType>
83+
</EmbeddedResource>
84+
<Compile Include="Properties\Resources.Designer.cs">
85+
<AutoGen>True</AutoGen>
86+
<DependentUpon>Resources.resx</DependentUpon>
87+
</Compile>
88+
<None Include="packages.config" />
89+
<None Include="Properties\Settings.settings">
90+
<Generator>SettingsSingleFileGenerator</Generator>
91+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
92+
</None>
93+
<Compile Include="Properties\Settings.Designer.cs">
94+
<AutoGen>True</AutoGen>
95+
<DependentUpon>Settings.settings</DependentUpon>
96+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
97+
</Compile>
98+
<None Include="template.bin">
99+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
100+
</None>
101+
<None Include="template2.bin">
102+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
103+
</None>
104+
</ItemGroup>
105+
<ItemGroup>
106+
<None Include="App.config" />
107+
</ItemGroup>
108+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
109+
</Project>

EditRevitFile/Form1.Designer.cs

Lines changed: 109 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)