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

CNX-9228 : minimal working revit receive operation that receives levels #3286

Draft
wants to merge 6 commits into
base: dui3/alpha
Choose a base branch
from

Conversation

connorivy
Copy link
Contributor

Description & motivation

Changes:

To-do before merge:

  • Invoking common receive operation located in Speckle.Connectors.Utils.Operations with custom RevitHostObjectBuilder
    • Wrapped entire thing in RevitTask to execute in API context
    • Brought over the transactionManager (with slightly different method names) to provided transaction manipulation
    • Brought over the ErrorPreprocessingService (formerly called the ErrorEater) which can be used to either deal with Revit errors or alert the user
    • Brought over the "YieldToUIThread" method to pump the event loop and keep the UI refreshed. The previous one was based on the Avalonia Dispactcher, so this new one would need some testing to see if it is really working.
  • RevitConverterToHost which is similar to other host app receive converters
  • Brought over level conversion to Revit except left out a chunk of code dealing with receiving levels that have a "referenceOnly" property that I'm not fully understanding. Matteo is probably the best person to explain this.

Screenshots:

Validation of changes:

Checklist:

  • My pull request follows the guidelines in the Contributing guide?
  • My pull request does not duplicate any other open Pull Requests for the same update/change?
  • My commits are related to the pull request and do not amend unrelated code or documentation.
  • My code follows a similar style to existing code.
  • I have added appropriate tests.
  • I have updated or added relevant documentation.

References

@connorivy connorivy changed the title Cnx 9228 : minimal working revit receive operation Cnx 9228 : minimal working revit receive operation that receives levels Apr 16, 2024
Copy link
Contributor

@BovineOx BovineOx left a comment

Choose a reason for hiding this comment

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

We should probably be a bit picky about which bits we pull across from the old converters/connectors as we're getting into areas we want to make good/better and we will need more alignment

return result;
}

private ISpeckleObjectToHostConversion? GetToHostConversion(Type? targetType)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why would Type be null?


// factory for conversions
builder
.RegisterType<Factory<string, IHostObjectToSpeckleConversion>>()
.As<IFactory<string, IHostObjectToSpeckleConversion>>();
builder
.RegisterType<Factory<string, ISpeckleObjectToHostConversion>>()
.As<IFactory<string, ISpeckleObjectToHostConversion>>();

// POC: do we need ToSpeckleScalingService as is, do we need to interface it out?
builder.RegisterType<ToSpeckleScalingService>().AsSelf().InstancePerLifetimeScope();
Copy link
Contributor

Choose a reason for hiding this comment

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

These should all be interfaced out


namespace Speckle.Converters.RevitShared.Services;

public class ErrorPreprocessingService : IFailuresPreprocessor
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems completely out of scope tbh, we need to design and POC the reporting and this far we've largely been ignoring it. I think this should come out for now - was this a copy and paste?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was copy paste. Removing for now, but this is a decently important class in Revit that we should make sure we reimplement. I've added a POC comment.

return UnitUtils.ConvertToInternalUnits(value, UnitsToNative(units));
}

private static ForgeTypeId UnitsToNative(string units)
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this being done elsewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought the same thing but I don't think so. In the contextStack, we have an IHostToSpeckleUnitConverter which goes from hostUnit to string, but not string to HostUnit. Maybe we should add this to that interface instead?

/// </summary>
public sealed class TransactionManagementService : ITransactionManagementService
{
private readonly Lazy<RevitConversionContextStack> _lazyContextStack;
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason for making this lazy? Is this essentially a singleton with the context of a conversion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was needed because it was being instantiated in a dependency of the binding (right when Revit was opened before there was an active document) which was causing an error because the context stack is instantiated using the active document. However, this is no longer needed after moving the uow out to the binding.

return TransactionStatus.Uninitialized;
}

private void HandleFailedCommit(TransactionStatus status)
Copy link
Contributor

Choose a reason for hiding this comment

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

This feels like it maybe doing too much and is using SpeckleLog directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you are right. Removed the error handling and added POC comments

@AlanRynne AlanRynne marked this pull request as draft April 22, 2024 19:53
@AlanRynne
Copy link
Member

Moving this to draft as we'll get receive in later on

@AlanRynne AlanRynne changed the title Cnx 9228 : minimal working revit receive operation that receives levels CNX-9228 : minimal working revit receive operation that receives levels Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants