-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip group creation in acad * in progress changes from fieldtrip * feat(dui3): extracts group from acad * fix(dui3): post dev merge edits
- Loading branch information
1 parent
722d091
commit ba26ee0
Showing
6 changed files
with
116 additions
and
19 deletions.
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
47 changes: 47 additions & 0 deletions
47
Connectors/Autocad/Speckle.Connectors.AutocadShared/HostApp/AutocadGroupUnpacker.cs
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using Autodesk.AutoCAD.DatabaseServices; | ||
using Speckle.Connectors.Autocad.Operations.Send; | ||
using Speckle.Core.Models.Instances; | ||
|
||
namespace Speckle.Connectors.Autocad.HostApp; | ||
|
||
/// <summary> | ||
/// Unpacks a selection of atomic objects into their groups. This resource expects to be injected "fresh" in each send operation (scoped lifetime). | ||
/// </summary> | ||
public class AutocadGroupUnpacker | ||
{ | ||
public List<GroupProxy> UnpackGroups(IEnumerable<AutocadRootObject> autocadObjects) | ||
{ | ||
var groupProxies = new Dictionary<string, GroupProxy>(); | ||
|
||
using var transaction = Application.DocumentManager.CurrentDocument.Database.TransactionManager.StartTransaction(); | ||
|
||
foreach (var (dbObject, applicationId) in autocadObjects) | ||
{ | ||
var persistentReactorIds = dbObject.GetPersistentReactorIds(); | ||
foreach (ObjectId oReactorId in persistentReactorIds) | ||
{ | ||
var obj = transaction.GetObject(oReactorId, OpenMode.ForRead); | ||
if (obj is not Group group) | ||
{ | ||
continue; | ||
} | ||
var groupAppId = group.Handle.ToString(); | ||
if (groupProxies.TryGetValue(groupAppId, out GroupProxy groupProxy)) | ||
{ | ||
groupProxy.objects.Add(applicationId); | ||
} | ||
else | ||
{ | ||
groupProxies[groupAppId] = new() | ||
{ | ||
applicationId = groupAppId, | ||
name = group.Name, | ||
objects = [applicationId] | ||
}; | ||
} | ||
} | ||
} | ||
|
||
return groupProxies.Values.ToList(); | ||
} | ||
} |
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