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

Blocks POC (Rhino, Acad) #3519

Merged
merged 30 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
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 Jun 11, 2024
0648654
feat(dui3): rhino blocks send wip
didimitrie Jun 11, 2024
6313b22
feat(dui3): wip (works!) rhino blocks send & receive
didimitrie Jun 11, 2024
43471a2
some cleanup
didimitrie Jun 12, 2024
0c07f75
wip fixes
didimitrie Jun 12, 2024
4137515
wip cleanup
didimitrie Jun 12, 2024
96be32d
wip scaffolds acad
didimitrie Jun 12, 2024
2eb1f93
Merge branch 'dui3/alpha' into dim/dui3/blocks-poc
didimitrie Jun 13, 2024
1e92a17
wip acad send instances and co
didimitrie Jun 14, 2024
6d3b3db
wip acad - getting close to wrapping up send
didimitrie Jun 14, 2024
31da29f
wip - units
didimitrie Jun 15, 2024
c69a781
feat(dui3): blocks poc wip: adds rhino layer manager, moves instance …
didimitrie Jun 16, 2024
5c1c560
feat(dui3): blocks poc WIP - acad receive
didimitrie Jun 16, 2024
4460265
wip acad instance receives
didimitrie Jun 16, 2024
f6ff940
acad blocks - receive ok
didimitrie Jun 16, 2024
e08d946
feat(dui3): acad receive blocks ✅
didimitrie Jun 16, 2024
6cca93d
feat(dui3): blocks poc minor refactors
didimitrie Jun 16, 2024
97d3f65
feat(dui3): acad blocks proper cleanup
didimitrie Jun 16, 2024
ba4556e
feat(dui3): blocks poc ready(ish) rhino & acad
didimitrie Jun 17, 2024
850eef8
Merge branch 'dui3/alpha' into dim/dui3/blocks-poc
didimitrie Jun 17, 2024
6ae0a3f
chore(dui3): reverts accidental change
didimitrie Jun 17, 2024
bfd5d21
feat(dui3): adds comments/docs
didimitrie Jun 17, 2024
536fc6e
chore(dui3): comments
didimitrie Jun 18, 2024
3991441
fix(dui3): throws ex upwards
didimitrie Jun 24, 2024
6ffe054
fix(dui3): blocks correctly handled in acad
didimitrie Jun 25, 2024
844dd02
Merge branch 'dui3/alpha' into dim/dui3/blocks-poc
didimitrie Jun 26, 2024
0ee51df
Merge branch 'dui3/alpha' into dim/dui3/blocks-poc
adamhathcock Jun 27, 2024
33b2614
Merge remote-tracking branch 'origin/dui3/alpha' into dim/dui3/blocks…
adamhathcock Jun 27, 2024
88cb939
update core reference and fix to not use interfaces
adamhathcock Jun 27, 2024
52d1c65
remove extra files
adamhathcock Jun 27, 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
12 changes: 12 additions & 0 deletions Core/Core/Models/Instances/IInstanceComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Speckle.Core.Models.Instances;

/// <summary>
/// Abstracts over <see cref="InstanceProxy"/> and <see cref="InstanceDefinitionProxy"/> for sorting and grouping in receive operations.
/// </summary>
public interface IInstanceComponent
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 a very small interface and the name and the prop seem a bit incongruous, possibly you're expecting the interface to grow to have more props/ Just wondering if this is the right place. I can sort of see I think, but maybe worth a discussion.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't expect it to grow (yet), i just need to sort both by max depth in the same pass. Not too clean, i agree, but then again could we live with this as a POC?

{
/// <summary>
/// The maximum "depth" at which this <see cref="InstanceProxy"/> or <see cref="InstanceDefinitionProxy"/> was found. It's important to get right: as instances can be composed of other instances, we need to start from the deepest instance elements first when reconstructing them, starting with definitions first.
/// </summary>
public int MaxDepth { get; set; }
}
19 changes: 19 additions & 0 deletions Core/Core/Models/Instances/InstanceDefinitionProxy.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Collections.Generic;

namespace Speckle.Core.Models.Instances;

/// <summary>
/// A proxy class for an instance definition.
/// </summary>
public class InstanceDefinitionProxy : Base, IInstanceComponent
Copy link
Contributor

Choose a reason for hiding this comment

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

InstanceDefinitionProxy will be serialiseable and hence is derives from Base? I am circling Base atm with a view to us setting fire to it, at least in its current state, and moving to more concrete types, though I don't imagine we can avoid using it here if it is going to be serialized in place

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep! We can move things away from base when we get to it imho

{
/// <summary>
/// The original ids of the objects that are part of this definition, as present in the source host app. On receive, they will be mapped to corresponding newly created definition ids.
/// </summary>
public List<string> Objects { get; set; } // source app application ids for the objects

/// <summary>
/// The maximum "depth" at which this instance was found. It's important to get right: as instances can be composed of other instances, we need to start from the deepest instance elements first when reconstructing them.
/// </summary>
public int MaxDepth { get; set; }
}
29 changes: 29 additions & 0 deletions Core/Core/Models/Instances/InstanceProxy.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.DoubleNumerics;

namespace Speckle.Core.Models.Instances;

/// <summary>
/// A proxy class for an instance (e.g, a rhino block, or an autocad block reference).
/// </summary>
public class InstanceProxy : Base, IInstanceComponent
{
/// <summary>
/// The definition id as present in the original host app. On receive, it will be mapped to the newly created definition id.
/// </summary>
public string DefinitionId { get; set; }

/// <summary>
/// The transform of the instance reference.
/// </summary>
public Matrix4x4 Transform { get; set; }

/// <summary>
/// The units of the host application file.
/// </summary>
public string Units { get; set; } = Kits.Units.Meters;
Copy link
Contributor

Choose a reason for hiding this comment

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

How dare you mention Kits ;)

We should move that definition and avoid binding tighter to it

Copy link
Member Author

Choose a reason for hiding this comment

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

I am not sure how at this stage? I'm hesitant to move this out of core right now...


/// <summary>
/// The maximum "depth" at which this instance was found. It's important to get right: as instances can be composed of other instances, we need to start from the deepest instance elements first when reconstructing them.
/// </summary>
public int MaxDepth { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Speckle.Core.Credentials;
using Speckle.Connectors.Autocad.HostApp.Extensions;
using Speckle.Connectors.Utils;
using Speckle.Core.Logging;

namespace Speckle.Connectors.Autocad.Bindings;

Expand Down Expand Up @@ -108,34 +109,48 @@ public void HighlightModel(string modelCardId)
return;
}

HighlightObjectsOnView(objectIds);
HighlightObjectsOnView(objectIds, modelCardId);
}

private void HighlightObjectsOnView(ObjectId[] objectIds)
private void HighlightObjectsOnView(ObjectId[] objectIds, string? modelCardId = null)
{
var doc = Application.DocumentManager.MdiActiveDocument;

Parent.RunOnMainThread(() =>
{
doc.Editor.SetImpliedSelection(Array.Empty<ObjectId>()); // Deselects
doc.Editor.SetImpliedSelection(objectIds); // Selects
doc.Editor.UpdateScreen();
try
{
doc.Editor.SetImpliedSelection(Array.Empty<ObjectId>()); // Deselects
doc.Editor.SetImpliedSelection(objectIds); // Selects
doc.Editor.UpdateScreen();

Extents3d selectedExtents = new();

Extents3d selectedExtents = new();
var tr = doc.TransactionManager.StartTransaction();
foreach (ObjectId objectId in objectIds)
{
var entity = (Entity)tr.GetObject(objectId, OpenMode.ForRead);
if (entity != null)
{
selectedExtents.AddExtents(entity.GeometricExtents);
}
}

var tr = doc.TransactionManager.StartTransaction();
foreach (ObjectId objectId in objectIds)
doc.Editor.Zoom(selectedExtents);
tr.Commit();
Autodesk.AutoCAD.Internal.Utils.FlushGraphics();
}
catch (Exception ex) when (!ex.IsFatal())
{
var entity = (Entity)tr.GetObject(objectId, OpenMode.ForRead);
if (entity != null)
if (modelCardId != null)
{
Commands.SetModelError(modelCardId, new OperationCanceledException("Failed to highlight objects."));
}
else
{
selectedExtents.AddExtents(entity.GeometricExtents);
//???
didimitrie marked this conversation as resolved.
Show resolved Hide resolved
}
}

doc.Editor.Zoom(selectedExtents);
tr.Commit();
Autodesk.AutoCAD.Internal.Utils.FlushGraphics();
});
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Autodesk.AutoCAD.DatabaseServices;
using Speckle.Autofac;
using Speckle.Autofac.DependencyInjection;
using Speckle.Connectors.Autocad.Bindings;
Expand All @@ -15,6 +16,7 @@
using Speckle.Connectors.Utils;
using Speckle.Connectors.Utils.Builders;
using Speckle.Connectors.Utils.Caching;
using Speckle.Connectors.Utils.Instances;
using Speckle.Connectors.Utils.Operations;
using Speckle.Core.Models.GraphTraversal;

Expand Down Expand Up @@ -62,5 +64,6 @@ public void Load(SpeckleContainerBuilder builder)

// register send conversion cache
builder.AddSingleton<ISendConversionCache, SendConversionCache>();
builder.AddScoped<IInstanceObjectsManager<AutocadRootObject, List<Entity>>, AutocadInstanceObjectManager>();
}
}
Loading
Loading