-
Notifications
You must be signed in to change notification settings - Fork 27
Dim/revit materials #149
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
Merged
Merged
Dim/revit materials #149
Changes from 17 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
6e81a46
chore: cleans up display value extractor
didimitrie 7741b4c
feat: generates render material proxy maps in revit send
didimitrie 52e2f6a
chore: removes unused code
didimitrie 13fcf89
feat(revit): material proxies wip
didimitrie 408f651
wip
didimitrie a18b789
Merge branch 'dev' into dim/revit-materials
didimitrie 9d33286
removes unused converted cache
didimitrie 13cacae
wip
didimitrie 5acd5a7
chore: cleanup part 1
didimitrie f1dba34
chore: finished cleanup (moved revit render material proxy cache out)
didimitrie bbf7586
Merge branch 'dev' into dim/revit-materials
didimitrie 61cde3c
fix(revit): invalid progress reporting on send
didimitrie 45e3eaa
Merge branch 'dev' into dim/revit-materials
didimitrie 76de6ae
feat(rhino): adds rhino support for revit proxy materials
didimitrie 35934a0
fix(acad): checks group names for invalid chars
didimitrie 59db1c8
fix(acad): checks material name for invalid chars
didimitrie 7a3899c
feat(acad): adds support for baking fallback objects properly
didimitrie 19d6ff1
wip: arcgis support for multiple fallback values
didimitrie 8cece65
Fix build errors (#166)
oguzhankoral b76636c
fix: arcgis
didimitrie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/ElementUnpacker.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
using Autodesk.Revit.DB; | ||
using Speckle.Converters.RevitShared.Helpers; | ||
|
||
namespace Speckle.Connectors.Revit.HostApp; | ||
|
||
/// <summary> | ||
/// Class that unpacks a given set of selection elements into atomic objects. | ||
/// </summary> | ||
public class ElementUnpacker | ||
{ | ||
private readonly IRevitConversionContextStack _contextStack; | ||
|
||
public ElementUnpacker(IRevitConversionContextStack contextStack) | ||
{ | ||
_contextStack = contextStack; | ||
} | ||
|
||
/// <summary> | ||
/// Unpacks a random set of revit objects into atomic objects. It currently unpacks groups recurisvely, nested families into atomic family instances. | ||
/// This method will also "pack" curtain walls if necessary (ie, if mullions or panels are selected without their parent curtain wall, they are sent independently; if the parent curtain wall is selected, they will be removed out as the curtain wall will include all its children). | ||
/// </summary> | ||
/// <param name="selectionElements"></param> | ||
/// <returns></returns> | ||
public IEnumerable<Element> UnpackSelectionForConversion(IEnumerable<Element> selectionElements) | ||
{ | ||
// Note: steps kept separate on purpose. | ||
// Step 1: unpack groups | ||
var atomicObjects = UnpackElements(selectionElements); | ||
|
||
// Step 2: pack curtain wall elements, once we know the full extent of our flattened item list. | ||
// The behaviour we're looking for: | ||
// If parent wall is part of selection, does not select individual elements out. Otherwise, selects individual elements (Panels, Mullions) as atomic objects. | ||
return PackCurtainWallElements(atomicObjects); | ||
} | ||
|
||
private List<Element> UnpackElements(IEnumerable<Element> elements) | ||
{ | ||
var unpackedElements = new List<Element>(); // note: could be a hashset/map so we prevent duplicates (?) | ||
|
||
foreach (var element in elements) | ||
{ | ||
// UNPACK: Groups | ||
if (element is Group g) | ||
{ | ||
// POC: this might screw up generating hosting rel generation here, because nested families in groups get flattened out by GetMemberIds(). | ||
var groupElements = g.GetMemberIds().Select(_contextStack.Current.Document.GetElement); | ||
unpackedElements.AddRange(UnpackElements(groupElements)); | ||
} | ||
// UNPACK: Family instances (as they potentially have nested families inside) | ||
else if (element is FamilyInstance familyInstance) | ||
{ | ||
var familyElements = familyInstance | ||
.GetSubComponentIds() | ||
.Select(_contextStack.Current.Document.GetElement) | ||
.ToArray(); | ||
|
||
if (familyElements.Length != 0) | ||
{ | ||
unpackedElements.AddRange(UnpackElements(familyElements)); | ||
} | ||
|
||
unpackedElements.Add(familyInstance); | ||
} | ||
else | ||
{ | ||
unpackedElements.Add(element); | ||
} | ||
} | ||
// Why filtering for duplicates? Well, well, well... it's related to the comment above on groups: if a group | ||
// contains a nested family, GetMemberIds() will return... duplicates of the exploded family components. | ||
return unpackedElements.GroupBy(el => el.Id).Select(g => g.First()).ToList(); // no disinctBy in here sadly. | ||
} | ||
|
||
private List<Element> PackCurtainWallElements(List<Element> elements) | ||
{ | ||
var ids = elements.Select(el => el.Id).ToArray(); | ||
elements.RemoveAll(element => | ||
(element is Mullion m && ids.Contains(m.Host.Id)) || (element is Panel p && ids.Contains(p.Host.Id)) | ||
); | ||
return elements; | ||
} | ||
|
||
/// <summary> | ||
/// Given a set of atomic elements, it will return a list of all their ids as well as their subelements. This currently handles <b>curtain walls</b> and <b>stacked walls</b>. | ||
/// This might not be an exhaustive list of valid objects with "subelements" in revit, and will need revisiting. | ||
/// </summary> | ||
/// <param name="elements"></param> | ||
/// <returns></returns> | ||
public List<string> GetElementsAndSubelementIdsFromAtomicObjects(List<Element> elements) | ||
{ | ||
var ids = new HashSet<string>(); | ||
foreach (var element in elements) | ||
{ | ||
switch (element) | ||
{ | ||
case Wall wall: | ||
if (wall.CurtainGrid is { } grid) | ||
{ | ||
foreach (var mullionId in grid.GetMullionIds()) | ||
{ | ||
ids.Add(mullionId.ToString()); | ||
} | ||
foreach (var panelId in grid.GetPanelIds()) | ||
{ | ||
ids.Add(panelId.ToString()); | ||
} | ||
} | ||
else if (wall.IsStackedWall) | ||
{ | ||
foreach (var stackedWallId in wall.GetStackedWallMemberIds()) | ||
{ | ||
ids.Add(stackedWallId.ToString()); | ||
} | ||
} | ||
break; | ||
default: | ||
break; | ||
} | ||
|
||
ids.Add(element.Id.ToString()); | ||
} | ||
|
||
return ids.ToList(); | ||
} | ||
} |
91 changes: 0 additions & 91 deletions
91
Connectors/Revit/Speckle.Connectors.RevitShared/HostApp/SendSelectionUnpacker.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.