Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceIFC added Out reference to get the ElementId #423

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Source/Revit.IFC.Import/Importer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,10 @@ private bool DocumentUpToDate(Document doc, string ifcFileName)
/// <param name="document">The host document for the import.</param>
/// <param name="origFullFileName">The full file name of the document.</param>
/// <param name="options">The list of configurable options for this import.</param>
public void ReferenceIFC(Document document, string origFullFileName, IDictionary<String, String> options)
public void ReferenceIFC(Document document, string origFullFileName, IDictionary<String, String> options, out ElementId revitLinkTypeId)
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be better to just return the ElementId instead?

Copy link
Author

Choose a reason for hiding this comment

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

that was my first idea, but I've thought that changing the return method from void to ElementId could it be potentially more distruptive for existing codes which uses this DLL rather than leaving to void and using an out reference

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, I guess it depends if it is overridden or not. I would think changing void to ElementId as a return wouldn't be so bad, would it? Vs. changing the signature?

Copy link
Author

Choose a reason for hiding this comment

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

well, returning ElementId it would be cleaner and more straightforward too, if you think that's ok for compatibility I'd also prefer that way,

do you want me to create another pull request with the implementation?

revitLinkTypeId = ElementId.InvalidElementId;

// We need to generate a local file name for all of the intermediate files (the log file, the cache file, and the shared parameters file).
string localFileName = ImporterIFCUtils.GetLocalFileName(document, origFullFileName);
if (localFileName == null)
Expand Down Expand Up @@ -506,7 +508,7 @@ public void ReferenceIFC(Document document, string origFullFileName, IDictionary
// If we have an original Revit link file name, don't create a new RevitLinkType -
// we will use the existing one.
bool useExistingType = (TheOptions.RevitLinkFileName != null);
ElementId revitLinkTypeId = IFCImportFile.LinkInFile(origFullFileName, localFileName, ifcDocument, originalDocument, useExistingType, !useCachedRevitFile);
revitLinkTypeId = IFCImportFile.LinkInFile(origFullFileName, localFileName, ifcDocument, originalDocument, useExistingType, !useCachedRevitFile);
}
}

Expand Down