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
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(revit): wraps receive in correct context
  • Loading branch information
didimitrie committed Sep 12, 2024
commit 9823cece8297b05ef67d0d9dc42a62894a460b0a
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Autodesk.Revit.DB;
using Revit.Async;
using Speckle.Connectors.Revit.HostApp;
using Speckle.Connectors.Utils.Builders;
using Speckle.Connectors.Utils.Conversion;
Expand Down Expand Up @@ -49,50 +50,63 @@ public Task<HostObjectBuilderResult> Build(
string modelName,
Action<string, double?>? onOperationProgressed,
CancellationToken cancellationToken
) =>
_syncToThread.RunOnThread(() =>
{
using var activity = SpeckleActivityFactory.Start("Build");
IEnumerable<TraversalContext> objectsToConvert;
using (var _ = SpeckleActivityFactory.Start("Traverse"))
{
objectsToConvert = _traverseFunction.Traverse(rootObject).Where(obj => obj.Current is not Collection);
}

var elementIds = new List<ElementId>();

using TransactionGroup transactionGroup =
new(_contextStack.Current.Document, $"Received data from {projectName}");
transactionGroup.Start();
_transactionManager.StartTransaction();

Dictionary<string, List<string>> applicationIdMap = new();
var conversionResults = BakeObjects(objectsToConvert, out elementIds);
)
{
return RevitTask.RunAsync(
() => BuildSync(rootObject, projectName, modelName, onOperationProgressed, cancellationToken)
);
}
#pragma warning disable IDE0060
private HostObjectBuilderResult BuildSync(
Base rootObject,
string projectName,
string modelName,
Action<string, double?>? onOperationProgressed,
CancellationToken cancellationToken
)
#pragma warning restore IDE0060
{
using var activity = SpeckleActivityFactory.Start("Build");
IEnumerable<TraversalContext> objectsToConvert;

using (var _ = SpeckleActivityFactory.Start("Commit"))
{
_transactionManager.CommitTransaction();
transactionGroup.Assimilate();
}
using (var _ = SpeckleActivityFactory.Start("Traverse"))
{
objectsToConvert = _traverseFunction.Traverse(rootObject).Where(obj => obj.Current is not Collection);
}

//var groupProxies = (rootObject["groupProxies"] as List<object>)?.Cast<GroupProxy>().ToList();
_groupManager.CreateGroups();
var elementIds = new List<ElementId>();

// creating group has to be in a separate tranasction, else Revit will show a warning
using TransactionGroup createGroupTransaction = new(_contextStack.Current.Document, "Creating group");
createGroupTransaction.Start();
_transactionManager.StartTransaction();
using TransactionGroup transactionGroup = new(_contextStack.Current.Document, $"Received data from {projectName}");
transactionGroup.Start();
_transactionManager.StartTransaction();

_contextStack.Current.Document.Create.NewGroup(elementIds);
Dictionary<string, List<string>> applicationIdMap = new();
var conversionResults = BakeObjects(objectsToConvert, out elementIds);

using (var _ = SpeckleActivityFactory.Start("Commit"))
{
_transactionManager.CommitTransaction();
createGroupTransaction.Assimilate();
}
using (var _ = SpeckleActivityFactory.Start("Commit"))
{
_transactionManager.CommitTransaction();
transactionGroup.Assimilate();
}

return conversionResults;
});
//var groupProxies = (rootObject["groupProxies"] as List<object>)?.Cast<GroupProxy>().ToList();
//_groupManager.CreateGroups();

// creating group has to be in a separate tranasction, else Revit will show a warning
// using TransactionGroup createGroupTransaction = new(_contextStack.Current.Document, "Creating group");
// createGroupTransaction.Start();
// _transactionManager.StartTransaction();
//
// _contextStack.Current.Document.Create.NewGroup(elementIds);
//
// using (var _ = SpeckleActivityFactory.Start("Commit"))
// {
// _transactionManager.CommitTransaction();
// createGroupTransaction.Assimilate();
// }

return conversionResults;
}

// POC: Potentially refactor out into an IObjectBaker.
private HostObjectBuilderResult BakeObjects(IEnumerable<TraversalContext> objectsGraph, out List<ElementId> elemIds)
Expand Down Expand Up @@ -129,7 +143,7 @@ private HostObjectBuilderResult BakeObjects(IEnumerable<TraversalContext> object
}

// create group
//_contextStack.Current.Document.Create.NewGroup(elementIds);
_contextStack.Current.Document.Create.NewGroup(elementIds);
elemIds = elementIds;

return new(bakedObjectIds, conversionResults);
Expand Down