-
Notifications
You must be signed in to change notification settings - Fork 175
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
Blocks POC (Rhino, Acad) #3519
Merged
Merged
Blocks POC (Rhino, Acad) #3519
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
9c65d1a
feat(dui3): adds instance def and instance proxy classes to core
didimitrie 0648654
feat(dui3): rhino blocks send wip
didimitrie 6313b22
feat(dui3): wip (works!) rhino blocks send & receive
didimitrie 43471a2
some cleanup
didimitrie 0c07f75
wip fixes
didimitrie 4137515
wip cleanup
didimitrie 96be32d
wip scaffolds acad
didimitrie 2eb1f93
Merge branch 'dui3/alpha' into dim/dui3/blocks-poc
didimitrie 1e92a17
wip acad send instances and co
didimitrie 6d3b3db
wip acad - getting close to wrapping up send
didimitrie 31da29f
wip - units
didimitrie c69a781
feat(dui3): blocks poc wip: adds rhino layer manager, moves instance …
didimitrie 5c1c560
feat(dui3): blocks poc WIP - acad receive
didimitrie 4460265
wip acad instance receives
didimitrie f6ff940
acad blocks - receive ok
didimitrie e08d946
feat(dui3): acad receive blocks ✅
didimitrie 6cca93d
feat(dui3): blocks poc minor refactors
didimitrie 97d3f65
feat(dui3): acad blocks proper cleanup
didimitrie ba4556e
feat(dui3): blocks poc ready(ish) rhino & acad
didimitrie 850eef8
Merge branch 'dui3/alpha' into dim/dui3/blocks-poc
didimitrie 6ae0a3f
chore(dui3): reverts accidental change
didimitrie bfd5d21
feat(dui3): adds comments/docs
didimitrie 536fc6e
chore(dui3): comments
didimitrie 3991441
fix(dui3): throws ex upwards
didimitrie 6ffe054
fix(dui3): blocks correctly handled in acad
didimitrie 844dd02
Merge branch 'dui3/alpha' into dim/dui3/blocks-poc
didimitrie 0ee51df
Merge branch 'dui3/alpha' into dim/dui3/blocks-poc
adamhathcock 33b2614
Merge remote-tracking branch 'origin/dui3/alpha' into dim/dui3/blocks…
adamhathcock 88cb939
update core reference and fix to not use interfaces
adamhathcock 52d1c65
remove extra files
adamhathcock 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 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 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 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 |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
using Speckle.Core.Logging; | ||
using Speckle.Core.Models; | ||
using Speckle.Core.Models.Instances; | ||
using Speckle.Rhino7.Interfaces; | ||
|
||
namespace Speckle.Connectors.Rhino7.HostApp; | ||
|
||
|
@@ -19,15 +20,15 @@ namespace Speckle.Connectors.Rhino7.HostApp; | |
/// </summary> | ||
public class RhinoInstanceObjectsManager : IInstanceObjectsManager<RhinoObject, List<string>> | ||
{ | ||
private readonly IConversionContextStack<RhinoDoc, UnitSystem> _contextStack; | ||
private readonly IConversionContextStack<IRhinoDoc, RhinoUnitSystem> _contextStack; | ||
private readonly Dictionary<string, InstanceProxy> _instanceProxies = new(); | ||
private readonly Dictionary<string, List<InstanceProxy>> _instanceProxiesByDefinitionId = new(); | ||
private readonly Dictionary<string, InstanceDefinitionProxy> _definitionProxies = new(); | ||
private readonly Dictionary<string, RhinoObject> _flatAtomicObjects = new(); | ||
private readonly RhinoLayerManager _layerManager; | ||
|
||
public RhinoInstanceObjectsManager( | ||
IConversionContextStack<RhinoDoc, UnitSystem> contextStack, | ||
IConversionContextStack<IRhinoDoc, RhinoUnitSystem> contextStack, | ||
RhinoLayerManager layerManager | ||
) | ||
{ | ||
|
@@ -52,14 +53,15 @@ private void UnpackInstance(InstanceObject instance, int depth = 0) | |
{ | ||
var instanceId = instance.Id.ToString(); | ||
var instanceDefinitionId = instance.InstanceDefinition.Id.ToString(); | ||
var currentDoc = RhinoDoc.ActiveDoc; // POC: too much right now to interface around | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we have the ticket for this and drop that into the POC comment? This is easily unit testable and this would block that, we could make the ticket to complete this an add some unit tests |
||
|
||
_instanceProxies[instanceId] = new InstanceProxy() | ||
{ | ||
applicationId = instanceId, | ||
DefinitionId = instance.InstanceDefinition.Id.ToString(), | ||
Transform = XFormToMatrix(instance.InstanceXform), | ||
MaxDepth = depth, | ||
Units = _contextStack.Current.Document.ModelUnitSystem.ToSpeckleString() | ||
Units = currentDoc.ModelUnitSystem.ToSpeckleString() | ||
}; | ||
|
||
// For each block instance that has the same definition, we need to keep track of the "maximum depth" at which is found. | ||
|
@@ -125,7 +127,9 @@ public BakeResult BakeInstances( | |
Action<string, double?>? onOperationProgressed | ||
) | ||
{ | ||
var doc = _contextStack.Current.Document; | ||
// var doc = _contextStack.Current.Document; | ||
var doc = RhinoDoc.ActiveDoc; // POC: too much right now to interface around | ||
|
||
var sortedInstanceComponents = instanceComponents | ||
.OrderByDescending(x => x.obj.MaxDepth) // Sort by max depth, so we start baking from the deepest element first | ||
.ThenBy(x => x.obj is InstanceDefinitionProxy ? 0 : 1) // Ensure we bake the deepest definition first, then any instances that depend on it | ||
|
@@ -214,11 +218,12 @@ instanceOrDefinition is InstanceProxy instanceProxy | |
|
||
public void PurgeInstances(string namePrefix) | ||
{ | ||
foreach (var definition in _contextStack.Current.Document.InstanceDefinitions) | ||
var currentDoc = RhinoDoc.ActiveDoc; // POC: too much right now to interface around | ||
foreach (var definition in currentDoc.InstanceDefinitions) | ||
{ | ||
if (!definition.IsDeleted && definition.Name.Contains(namePrefix)) | ||
{ | ||
_contextStack.Current.Document.InstanceDefinitions.Delete(definition.Index, true, false); | ||
currentDoc.InstanceDefinitions.Delete(definition.Index, true, false); | ||
} | ||
} | ||
} | ||
|
@@ -228,10 +233,8 @@ private Matrix4x4 XFormToMatrix(Transform t) => | |
|
||
private Transform MatrixToTransform(Matrix4x4 matrix, string units) | ||
{ | ||
var conversionFactor = Units.GetConversionFactor( | ||
units, | ||
_contextStack.Current.Document.ModelUnitSystem.ToSpeckleString() | ||
); | ||
var currentDoc = RhinoDoc.ActiveDoc; // POC: too much right now to interface around | ||
var conversionFactor = Units.GetConversionFactor(units, currentDoc.ModelUnitSystem.ToSpeckleString()); | ||
|
||
var t = Transform.Identity; | ||
t.M00 = matrix.M11; | ||
|
This file contains 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 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 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 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 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 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 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 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 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
Oops, something went wrong.
You are viewing a condensed version of this merge commit. You can view the full changes here.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are into Rhino now and my brain is melting and it's probably worth considering my ACAD comments first.
Also I wonder if these can be made to be more DRY though I suspect not, maybe that's one for later IF
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They could be with an abstract class in between, but i'd settle with them as they are as "good enough" for now. We'd need to test this against other host apps to fully understand the patterns at play first (eg., tekla, revit)