Skip to content

Commit

Permalink
fix(dui3): cleans up base layer prefix from invalid chars - fixes sec…
Browse files Browse the repository at this point in the history
…ond receive cleanup issues (#101)

* fix(dui3): cleans up base layer prefix from invalid chars - fixes second receive cleanup issues

and adds extra defensibility around layer naming in acad.

* fix(dui3): corrects by layer purge in acad

i have no idea how i even wrote this code in the first place
  • Loading branch information
didimitrie authored Aug 4, 2024
1 parent bf0f2b3 commit 6366f03
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public AutocadLayerManager(AutocadContext autocadContext)
/// </summary>
public void CreateLayerForReceive(Collection layerCollection)
{
string layerName = layerCollection.name;
string layerName = _autocadContext.RemoveInvalidChars(layerCollection.name);
if (!_uniqueLayerNames.Add(layerName))
{
return;
Expand Down Expand Up @@ -94,7 +94,7 @@ public void DeleteAllLayersByPrefix(string prefix)
SelectionSet selectionResult = Doc.Editor.SelectAll(selectionFilter).Value;
if (selectionResult == null)
{
return;
continue;
}
foreach (SelectedObject selectedObject in selectionResult)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,23 @@ public class AutocadHostObjectBuilder : IHostObjectBuilder

// private readonly HashSet<string> _uniqueLayerNames = new();
private readonly AutocadInstanceObjectManager _instanceObjectsManager;
private readonly AutocadContext _autocadContext;

public AutocadHostObjectBuilder(
IRootToHostConverter converter,
GraphTraversal traversalFunction,
AutocadLayerManager autocadLayerManager,
AutocadInstanceObjectManager instanceObjectsManager,
ISyncToThread syncToThread
ISyncToThread syncToThread,
AutocadContext autocadContext
)
{
_converter = converter;
_traversalFunction = traversalFunction;
_autocadLayerManager = autocadLayerManager;
_instanceObjectsManager = instanceObjectsManager;
_syncToThread = syncToThread;
_autocadContext = autocadContext;
}

public Task<HostObjectBuilderResult> Build(
Expand All @@ -57,8 +60,7 @@ CancellationToken _
// Layer filter for received commit with project and model name
_autocadLayerManager.CreateLayerFilter(projectName, modelName);

//TODO: make the layerManager handle \/ ?
string baseLayerPrefix = $"SPK-{projectName}-{modelName}-";
string baseLayerPrefix = _autocadContext.RemoveInvalidChars($"SPK-{projectName}-{modelName}-");

PreReceiveDeepClean(baseLayerPrefix);

Expand Down

0 comments on commit 6366f03

Please sign in to comment.