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

Revit receive first pass: reference geometry workflow (CNX-403) #254

Merged
merged 37 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
54a3a45
feat(dui3): re-enables receive binding
didimitrie Sep 9, 2024
0af84a8
chore(revit): drastic cleanup
didimitrie Sep 9, 2024
bdbb20e
feat(revit): starts scaffolding revit root to host converter
didimitrie Sep 9, 2024
24f86ce
RenderMaterialToHostConverter added back
kekesidavid Sep 10, 2024
a4abd26
casting to GeometryObject instead of GeometryElement
kekesidavid Sep 10, 2024
8f84a9e
feat(dui3): fallback display values and refactors out material converter
didimitrie Sep 10, 2024
807d9ff
feat(dui3): creates DS and adds point support
didimitrie Sep 10, 2024
05f30e3
feat(dui3): closed nurbs fallback to display values
didimitrie Sep 10, 2024
cfb20de
David/cnx 443 selection (#231)
kekesidavid Sep 10, 2024
7f1e00e
wip
kekesidavid Sep 12, 2024
71f857f
Merge branch 'dev' into grouping-sandbox
didimitrie Sep 12, 2024
9823cec
feat(revit): wraps receive in correct context
didimitrie Sep 12, 2024
92bbddb
wip
didimitrie Sep 12, 2024
5d8d572
feat(dui3): adds prototype grouping by collection
didimitrie Sep 12, 2024
18c8d44
remove invalid characters from group name
kekesidavid Sep 12, 2024
7ce34d6
hide warnings preprocessor
kekesidavid Sep 12, 2024
38ed784
exception handling and error log
kekesidavid Sep 12, 2024
e1b0832
added cancellation and progress reporting
kekesidavid Sep 12, 2024
81f35f6
chore: comments and minor cleanup
didimitrie Sep 12, 2024
0cc0897
Merge pull request #237 from specklesystems/grouping-sandbox
didimitrie Sep 12, 2024
0e87060
David/cnx 409 2 add rendermaterial and color manager to connector (#242)
kekesidavid Sep 16, 2024
e77b2e4
Minor cleanup
oguzhankoral Sep 16, 2024
10d0988
Add object application id into objects of its layer render material p…
oguzhankoral Sep 16, 2024
90834bd
feat(dui3): adds compatibility for objects with display values
didimitrie Sep 16, 2024
1de58a3
Merge pull request #243 from specklesystems/oguzhan/cnx-470-add-suppo…
didimitrie Sep 16, 2024
57407d4
Use LocalToGlobal logic for revit receive
oguzhankoral Sep 16, 2024
e1053df
Use common local to global util for arcgis too
oguzhankoral Sep 16, 2024
206524a
Remove unnecessary registration
oguzhankoral Sep 16, 2024
70e43dd
Remove using
oguzhankoral Sep 16, 2024
4e523ac
Remove unnecessart ToList
oguzhankoral Sep 16, 2024
b8b9355
Register LocalToGlobalConverterUtils for connectors not as common
oguzhankoral Sep 17, 2024
f74f9bc
Merge pull request #244 from specklesystems/oguzhan/cnx-442-handle-in…
didimitrie Sep 17, 2024
5caf403
purge materials and groups in Revit before update (#245)
kekesidavid Sep 18, 2024
5e52cdd
assign categories to DirectShapes after receive, updated revit invali…
kekesidavid Sep 18, 2024
2fa3477
Merge remote-tracking branch 'origin/dev' into revit-receive
oguzhankoral Sep 19, 2024
dc394fa
Post conflict resolving problems
oguzhankoral Sep 19, 2024
7a42a10
minor changes, logging, comments (#257)
kekesidavid Sep 19, 2024
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
Prev Previous commit
Next Next commit
feat(dui3): adds prototype grouping by collection
and adds todos
  • Loading branch information
didimitrie committed Sep 12, 2024
commit 5d8d572ab6e744c0c3a72f2cd455258dc3ca4ca4
Original file line number Diff line number Diff line change
Expand Up @@ -17,71 +17,64 @@ public RevitGroupManager(IRevitConversionContextStack contextStack, ITransaction
_transactionManager = transactionManager;
}

public void CreateGroups()
{
// build edge list of the element graph in the bakeobjects method
// pass the edge list to the GroupManager
// in the GroupManager CreateGroups method:
// 1. find leaf nodes
// 2. group leaf nodes by parent id
// 3. make revit groups from each leaf group
// 4. replace the parent id of the leaves with the new group id everywhere in the edge list
// 5. remove leaf edges
// 6. repeat the above until we have edges

return;
}

// We cannot add objects to groups in revit, we need to create a group all at once with all its subkids
// We need to create groups at the end of the day in a separate new transaction
public void AddToGroupMapping(TraversalContext tc, DirectShape ds)
{
var collectionPath = GetLayerPath(tc);
var currentLayerName = "Base Group";
var previousGroup = _baseGroup;
FakeGroup? previousGroup = null;
var currentDepth = 0;

foreach (var collection in collectionPath)
{
currentLayerName += "::" + collection.name;
if (_groupCache.TryGetValue(currentLayerName, out FakeGroup g))
{
previousGroup = g;
currentDepth++;
continue;
}

var group = new FakeGroup()
{
Name = currentLayerName,
Name = collection.name, // TODO: Sanitize all names according to revit's liking
Depth = currentDepth++,
Parent = previousGroup
Parent = previousGroup!
};
_groupCache[currentLayerName] = group;
previousGroup = group;
}

previousGroup.Ids.Add(ds.Id);
previousGroup!.Ids.Add(ds.Id);
}

private readonly Dictionary<string, FakeGroup> _groupCache = new();

public void BakeGroups()
public void BakeGroups(string baseGroupName)
{
var orderedGroups = _groupCache.Values.OrderByDescending(group => group.Depth);
Group? lastGroup = null;

foreach (var group in orderedGroups)
{
var docGroup = _contextStack.Current.Document.Create.NewGroup(group.Ids); // TODO
group.Parent.Ids.Add(docGroup.Id);
var docGroup = _contextStack.Current.Document.Create.NewGroup(group.Ids);
if (group.Parent != null)
{
group.Parent.Ids.Add(docGroup.Id);
}
docGroup.GroupType.Name = group.Name;
lastGroup = docGroup;
}
}

private FakeGroup _baseGroup = new() { Name = "Base Group", Depth = 0 };
}
lastGroup!.GroupType.Name = baseGroupName;
}

sealed class FakeGroup
{
public List<ElementId> Ids { get; set; } = new();
public int Depth { get; set; }
public string Name { get; set; }
public string HostId { get; set; } // will be used on baking, should be subsumed into ids
public FakeGroup Parent { get; set; }
private sealed class FakeGroup
{
public List<ElementId> Ids { get; set; } = new();
public int Depth { get; set; }
public string Name { get; set; }
public FakeGroup Parent { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,14 @@ public Task<HostObjectBuilderResult> Build(
string modelName,
Action<string, double?>? onOperationProgressed,
CancellationToken cancellationToken
)
{
return RevitTask.RunAsync(
() => BuildSync(rootObject, projectName, modelName, onOperationProgressed, cancellationToken)
);
}
#pragma warning disable IDE0060
) =>
RevitTask.RunAsync(() => BuildSync(rootObject, projectName, modelName, onOperationProgressed, cancellationToken));

private HostObjectBuilderResult BuildSync(
Base rootObject,
string projectName,
string modelName,
#pragma warning disable IDE0060
Action<string, double?>? onOperationProgressed,
CancellationToken cancellationToken
)
Expand All @@ -82,6 +79,8 @@ CancellationToken cancellationToken

Dictionary<string, List<string>> applicationIdMap = new();

// TODO: progress reporting
// TODO: cancellation
var conversionResults = BakeObjects(objectsToConvert, out elementIds);

using (var _ = SpeckleActivityFactory.Start("Commit"))
Expand All @@ -90,11 +89,17 @@ CancellationToken cancellationToken
transactionGroup.Assimilate();
}

// TODO: swallow warning
// https://github.com/speckleworks/SpeckleRevitReboot/blob/master/SpeckleRevitReboot/ErrorEater.cs
// how to use: https://github.com/speckleworks/SpeckleRevitReboot/blob/cc0fb0ee1d3a8a314b58cc98c3de4994fb5816f9/SpeckleRevitReboot/UI/Receiver.cs#L147
using TransactionGroup createGroupTransaction = new(_contextStack.Current.Document, "Creating group");
createGroupTransaction.Start();
_transactionManager.StartTransaction();

_groupManager.BakeGroups();
// TODO: needs try catch and logging
// TODO: check selection logic
var baseGroupName = $"Project {projectName} - Model {modelName}";
_groupManager.BakeGroups(baseGroupName);

using (var _ = SpeckleActivityFactory.Start("Commit"))
{
Expand Down Expand Up @@ -139,7 +144,6 @@ private HostObjectBuilderResult BakeObjects(IEnumerable<TraversalContext> object
}

elemIds = elementIds;

return new(bakedObjectIds, conversionResults);
}
}
Expand Down