Skip to content

Commit

Permalink
Merge pull request #338 from Autodesk/21.x.x_update_for_revit_2021.1.4
Browse files Browse the repository at this point in the history
21.x.x update for Revit 2021.1.4
  • Loading branch information
o-babii authored Sep 20, 2021
2 parents 7c0ae31 + 555e107 commit 78c02ad
Show file tree
Hide file tree
Showing 12 changed files with 316 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,27 @@ <h3>Support Information</h3>
<h2 id="VersionHistory" name="VersionHistory">Version History</h2>

<div class="versionset">
<div class="version">21.4.2.0</div><div class="versioninfo-bullet">

<br><p>
General:
<ul>
<li>This version contains couple of bugfixes since the latest release of 21.4.1.0.
</ul>
<br>
</p>
<br> <p>
Bug Fixes:
<ul>
<li>Fixed issue with exporting model on C4R that has links to IFC for the Revit 2021.1.4.
<li>Fixed localization issue in German version.
<li>PEnum_ConductorFunctionEnum entity fixed according to IFC4x3 standards..
</ul>
</p>
<br>
</div>
<br>

<div class="version">21.4.1.0</div><div class="versioninfo-bullet">
<br><p>
General:
Expand Down
4 changes: 2 additions & 2 deletions Install/Program Files to Install/bundle/PackageContents.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<RuntimeRequirements OS="Win64" Platform="Revit" SeriesMin="R2021" SeriesMax="R2021" />
<Components Description="2021">
<RuntimeRequirements OS="Win64" Platform="Revit" SeriesMin="R2021" SeriesMax="R2021" />
<ComponentEntry AppName="IFC For Revit 2021" Version="21.4.1" ModuleName="./Contents/2021/IFCExporterUIOverride.addin" AppDescription="IFC For Revit 2021" />
<ComponentEntry AppName="IFC For Revit 2021" Version="21.4.1" ModuleName="./Contents/2021/Revit.IFC.addin" AppDescription="IFC For Revit 2021" />
<ComponentEntry AppName="IFC For Revit 2021" Version="21.4.2" ModuleName="./Contents/2021/IFCExporterUIOverride.addin" AppDescription="IFC For Revit 2021" />
<ComponentEntry AppName="IFC For Revit 2021" Version="21.4.2" ModuleName="./Contents/2021/Revit.IFC.addin" AppDescription="IFC For Revit 2021" />
</Components>
</ApplicationPackage>
2 changes: 1 addition & 1 deletion Install/RevitIFCSetupWix/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">

<Product Id="265F2178-D145-4443-BEEE-143A4600231F" Name="Revit IFC 2021" Language="1033" Version="21.4.1.0" Manufacturer="Autodesk" UpgradeCode="D8344D14-F520-44DA-9583-9AF4BD489CF8">
<Product Id="242D3B07-8ED1-41A5-842B-E410D560B2E7" Name="Revit IFC 2021" Language="1033" Version="21.4.2.0" Manufacturer="Autodesk" UpgradeCode="D8344D14-F520-44DA-9583-9AF4BD489CF8">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
Expand Down
2 changes: 1 addition & 1 deletion Install/RevitIFCSetupWix/RevitIFCSetupWix.wixproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ProductVersion>3.8</ProductVersion>
<ProjectGuid>7dfbd495-c588-4c7b-b8f6-5b793adb06f2</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>IFC for Revit 2021.4.1.0</OutputName>
<OutputName>IFC for Revit 2021.4.2.0</OutputName>
<OutputType>Package</OutputType>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
Expand Down
8 changes: 4 additions & 4 deletions Install/RevitIFCSetupWix/buildInstaller.bat
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ rem It is necessary to add the Wix bin directory to the system path temporarily
SET PATH=%PATH%;%WixRoot%

candle.exe -dProjectDir=%2 -ext WixUtilExtension %2Product.wxs
light.exe -ext WixUtilExtension -out RevitIFC2021.4.1.msi product.wixobj -ext WixUIExtension
light.exe -ext WixUtilExtension -out RevitIFC2021.4.2.msi product.wixobj -ext WixUIExtension

copy RevitIFC2021.4.1.msi %1..\Releasex64
del RevitIFC2021.4.1.msi
copy RevitIFC2021.4.2.msi %1..\Releasex64
del RevitIFC2021.4.2.msi

echo %1..\Releasex64\RevitIFC2021.4.1.msi
echo %1..\Releasex64\RevitIFC2021.4.2.msi
280 changes: 270 additions & 10 deletions Source/IFCExporterUIOverride/IFCCommandOverrideApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,16 @@ public void OnIFCExport(object sender, CommandEventArgs args)
if (selectedConfig.ExportLinkedFiles == true)
{
exportOptions.AddOption("ExportingLinks", true.ToString());
ExportLinkedDocuments(document, fullName, linksGUIDsCache, exportOptions);
try
{
// Newer version of export linked documents
ExportLinkedDocuments(document, fullName, linksGUIDsCache, exportOptions);
}
catch
{
// Older version which uses copy of linked file, doesn't work for cloud documents
ExportLinkedDocumentsOldVersion(document, fullName, linksGUIDsCache, exportOptions);
}
exportOptions.AddOption("ExportingLinks", false.ToString());
}
}
Expand Down Expand Up @@ -396,6 +405,20 @@ private void AddExpandedElementIdContent(ref string messageString, string format
messageString += string.Format(formatString, ElementIdListToString(items));
}

private string GetLinkFileName(Document linkDocument, string linkPathName)
{
int index = linkPathName.LastIndexOf("\\");
if (index <= 0)
return linkDocument.Title;

string linkFileName = linkPathName.Substring(index + 1);
// remove the extension
index = linkFileName.LastIndexOf('.');
if (index > 0)
linkFileName = linkFileName.Substring(0, index);
return linkFileName;
}

public void ExportLinkedDocuments(Autodesk.Revit.DB.Document document, string fileName, Dictionary<ElementId, string> linksGUIDsCache, IFCExportOptions exportOptions)
{
// get the extension
Expand Down Expand Up @@ -440,17 +463,254 @@ public void ExportLinkedDocuments(Autodesk.Revit.DB.Document document, string fi
linkPathName = linkDocument.PathName;

// get the link file name
String linkFileName = "";
index = linkPathName.LastIndexOf("\\");
if (index > 0)
linkFileName = linkPathName.Substring(index + 1);
string linkFileName = GetLinkFileName(linkDocument, linkPathName);

// add to names count dictionary
if (!rvtLinkNamesDict.Keys.Contains(linkFileName))
rvtLinkNamesDict.Add(linkFileName, 0);
rvtLinkNamesDict[linkFileName]++;

// add to names instances dictionary
if (!rvtLinkNamesToInstancesDict.Keys.Contains(linkPathName))
rvtLinkNamesToInstancesDict.Add(linkPathName, new List<RevitLinkInstance>());
rvtLinkNamesToInstancesDict[linkPathName].Add(rvtLinkInstance);
}
}
catch
{
}

// get the link instances
// We will keep track of the instances we can't export.
// Reasons we can't export:
// 1. The path for the linked instance doesn't exist.
// 2. Couldn't create a temporary document for exporting the linked instance.
// 3. The document for the linked instance can't be found.
// 4. The linked instance is mirrored, non-conformal, or scaled.
IList<string> pathDoesntExist = new List<string>();
IList<string> noTempDoc = new List<string>();
IList<ElementId> cantFindDoc = new List<ElementId>();
IList<ElementId> nonConformalInst = new List<ElementId>();
IList<ElementId> scaledInst = new List<ElementId>();
IList<ElementId> instHasReflection = new List<ElementId>();

foreach (KeyValuePair<string, List<RevitLinkInstance>> linkPathNames in rvtLinkNamesToInstancesDict)
{
string linkPathName = linkPathNames.Key;

// get the link instances
List<RevitLinkInstance> currRvtLinkInstances = rvtLinkNamesToInstancesDict[linkPathName];
IList<string> serTransforms = new List<string>();
IList<string> linkFileNames = new List<string>();

Document linkDocument = null;
double lengthScaleFactorLink = 1.0;

foreach (RevitLinkInstance currRvtLinkInstance in currRvtLinkInstances)
{
// Nothing to report if the element itself is null.
if (currRvtLinkInstance == null)
continue;

// get the link document and the unit scale
if (linkDocument == null)
{
linkDocument = currRvtLinkInstance.GetLinkDocument();

lengthScaleFactorLink = UnitUtils.ConvertFromInternalUnits(
1.0,
linkDocument.GetUnits().GetFormatOptions(SpecTypeId.Length).GetUnitTypeId());
}

if (linkDocument == null)
{
cantFindDoc.Add(currRvtLinkInstance.Id);
continue;
}

// get the link transform
Transform tr = currRvtLinkInstance.GetTransform();

// We can't handle non-conformal, scaled, or mirrored transforms.
if (!tr.IsConformal)
{
nonConformalInst.Add(currRvtLinkInstance.Id);
continue;
}

if (tr.HasReflection)
{
instHasReflection.Add(currRvtLinkInstance.Id);
continue;
}

if (!MathUtil.IsAlmostEqual(tr.Determinant, 1.0))
{
scaledInst.Add(currRvtLinkInstance.Id);
continue;
}

// get the link file path and name
String linkFileName = GetLinkFileName(linkDocument, linkPathName);

//if link was an IFC file then make a different formating to the file name
if ((linkPathName.Length >= 4 && linkPathName.Substring(linkPathName.Length - 4).ToLower() == ".ifc") ||
(linkPathName.Length >= 7 && linkPathName.Substring(linkPathName.Length - 7).ToLower() == ".ifcxml") ||
(linkPathName.Length >= 7 && linkPathName.Substring(linkPathName.Length - 7).ToLower() == ".ifczip"))
{
String fName = fileName;

//get output path and add to the new file name
index = fName.LastIndexOf("\\");
if (index > 0)
fName = fName.Substring(0, index + 1);
else
fName = "";

//construct IFC file name
linkFileName = fName + linkFileName + "-";

//add guid
linkFileName += linksGUIDsCache[currRvtLinkInstance.Id];
}
else
linkFileName = linkDocument.Title;
{
// check if there are multiple instances with the same name
bool bMultiple = (rvtLinkNamesDict[linkFileName] > 1);

// remove the extension
index = linkFileName.LastIndexOf('.');
if (index > 0)
linkFileName = linkFileName.Substring(0, index);
// add the path
linkFileName = fileName + "-" + linkFileName;

// add the guid
if (bMultiple)
{
linkFileName += "-";
linkFileName += linksGUIDsCache[currRvtLinkInstance.Id];
}
}

// add the extension
linkFileName += sExtension;

linkFileNames.Add(linkFileName);

// scale the transform origin
tr.Origin *= lengthScaleFactorLink;

// serialize transform
serTransforms.Add(SerializeTransform(tr));
}

// IFC export requires an open transaction, although no changes should be made
if (linkDocument != null)
{
Transaction transaction = new Transaction(linkDocument, "Export IFC Link");
transaction.Start();
FailureHandlingOptions failureOptions = transaction.GetFailureHandlingOptions();
failureOptions.SetClearAfterRollback(false);
transaction.SetFailureHandlingOptions(failureOptions);

// export
try
{
int numLinkInstancesToExport = linkFileNames.Count;
exportOptions.AddOption("NumberOfExportedLinkInstances", numLinkInstancesToExport.ToString());

for (int ind = 0; ind < numLinkInstancesToExport; ind++)
{
string optionName = (ind == 0) ? "ExportLinkInstanceTransform" : "ExportLinkInstanceTransform" + (ind + 1).ToString();
exportOptions.AddOption(optionName, serTransforms[ind]);

// Don't pass in file name for the first link instance.
if (ind == 0)
continue;
optionName = "ExportLinkInstanceFileName" + (ind + 1).ToString();
exportOptions.AddOption(optionName, linkFileNames[ind]);
}
// Pass in the first value; the rest will be in the options.
String path_ = Path.GetDirectoryName(linkFileNames[0]);
String fileName_ = Path.GetFileName(linkFileNames[0]);
bool result = linkDocument.Export(path_, fileName_, exportOptions); // pass in the options here
}
catch
{
}

// rollback the transaction
transaction.RollBack();
}

// Show user errors, if any.
int numBadInstances = pathDoesntExist.Count + noTempDoc.Count + cantFindDoc.Count + nonConformalInst.Count
+ scaledInst.Count + instHasReflection.Count;
if (numBadInstances > 0)
{
using (TaskDialog taskDialog = new TaskDialog(Properties.Resources.IFCExport))
{
taskDialog.MainInstruction = string.Format(Properties.Resources.LinkInstanceExportErrorMain, numBadInstances);
taskDialog.MainIcon = TaskDialogIcon.TaskDialogIconWarning;
taskDialog.TitleAutoPrefix = false;

string expandedContent = "";
AddExpandedStringContent(ref expandedContent, Properties.Resources.LinkInstanceExportErrorPath, pathDoesntExist);
AddExpandedStringContent(ref expandedContent, Properties.Resources.LinkInstanceExportCantCreateDoc, noTempDoc);
AddExpandedElementIdContent(ref expandedContent, Properties.Resources.LinkInstanceExportCantFindDoc, cantFindDoc);
AddExpandedElementIdContent(ref expandedContent, Properties.Resources.LinkInstanceExportNonConformal, nonConformalInst);
AddExpandedElementIdContent(ref expandedContent, Properties.Resources.LinkInstanceExportScaled, scaledInst);
AddExpandedElementIdContent(ref expandedContent, Properties.Resources.LinkInstanceExportHasReflection, instHasReflection);

taskDialog.ExpandedContent = expandedContent;
TaskDialogResult result = taskDialog.Show();
}
}
}
}

public void ExportLinkedDocumentsOldVersion(Autodesk.Revit.DB.Document document, string fileName, Dictionary<ElementId, string> linksGUIDsCache, IFCExportOptions exportOptions)
{
// get the extension
int index = fileName.LastIndexOf('.');
if (index <= 0)
return;
string sExtension = fileName.Substring(index);
fileName = fileName.Substring(0, index);

// get all the revit link instances
FilteredElementCollector collector = new FilteredElementCollector(document);
ElementFilter elementFilter = new ElementClassFilter(typeof(RevitLinkInstance));
List<RevitLinkInstance> rvtLinkInstances = collector.WherePasses(elementFilter).Cast<RevitLinkInstance>().ToList();

IDictionary<String, int> rvtLinkNamesDict = new Dictionary<String, int>();
IDictionary<String, List<RevitLinkInstance>> rvtLinkNamesToInstancesDict = new Dictionary<String, List<RevitLinkInstance>>();

try
{
// get the link types
foreach (RevitLinkInstance rvtLinkInstance in rvtLinkInstances)
{
// get the instance
if (rvtLinkInstance == null)
continue;

// check the cache
if (linksGUIDsCache.Keys.Contains(rvtLinkInstance.Id) == false)
continue;

// get the link document
Document linkDocument = rvtLinkInstance.GetLinkDocument();
if (linkDocument == null)
continue;

// get the link file path and name
String linkPathName = "";
Parameter originalFileNameParam = linkDocument.ProjectInformation.LookupParameter("Original IFC File Name");
if (originalFileNameParam != null && originalFileNameParam.StorageType == StorageType.String)
linkPathName = originalFileNameParam.AsString();
else
linkPathName = linkDocument.PathName;

// get the link file name
string linkFileName = GetLinkFileName(linkDocument, linkPathName);

// add to names count dictionary
if (!rvtLinkNamesDict.Keys.Contains(linkFileName))
Expand Down
4 changes: 2 additions & 2 deletions Source/IFCExporterUIOverride/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@
// The following information is used in the Open Source version as the release version number.
// The number will show up in the Title bar of the export dialog as well as at the IFC header file
// This number must be manually updated prior to releasing the new version
[assembly: AssemblyVersion("21.4.1.0")]
[assembly: AssemblyFileVersion("21.4.1.0")]
[assembly: AssemblyVersion("21.4.2.0")]
[assembly: AssemblyFileVersion("21.4.2.0")]
#endif
Loading

0 comments on commit 78c02ad

Please sign in to comment.