Skip to content

Commit

Permalink
fix(revit): directshape fallback receive category assignment (#2890)
Browse files Browse the repository at this point in the history
* fixes category enums for assigning direct shape for fallback behavior

also includes slight refactor of rhino updating views and construction planes

* formatting

* fixed mesh setting bug
  • Loading branch information
clairekuang authored Sep 6, 2023
1 parent 24d6c87 commit 0e5d4cd
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 46 deletions.
4 changes: 4 additions & 0 deletions ConnectorAutocadCivil/ConnectorAutocadCivil.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
"ConnectorAutocadCivil\\ConnectorAutocad2021\\ConnectorAutocad2021.csproj",
"ConnectorAutocadCivil\\ConnectorAutocad2022\\ConnectorAutocad2022.csproj",
"ConnectorAutocadCivil\\ConnectorAutocad2023\\ConnectorAutocad2023.csproj",
"ConnectorAutocadCivil\\ConnectorAutocad2024\\ConnectorAutocad2024.csproj",
"ConnectorAutocadCivil\\ConnectorAutocadCivil\\ConnectorAutocadCivilShared.shproj",
"ConnectorAutocadCivil\\ConnectorCivil2021\\ConnectorCivil2021.csproj",
"ConnectorAutocadCivil\\ConnectorCivil2022\\ConnectorCivil2022.csproj",
"ConnectorAutocadCivil\\ConnectorCivil2023\\ConnectorCivil2023.csproj",
"ConnectorAutocadCivil\\ConnectorCivil2024\\ConnectorCivil2024.csproj",
"Core\\Core\\Core.csproj",
"Core\\Tests\\TestsUnit.csproj",
"Core\\Transports\\DiskTransport\\DiskTransport.csproj",
Expand All @@ -17,10 +19,12 @@
"Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocad2021\\ConverterAutocad2021.csproj",
"Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocad2022\\ConverterAutocad2022.csproj",
"Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocad2023\\ConverterAutocad2023.csproj",
"Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocad2024\\ConverterAutocad2024.csproj",
"Objects\\Converters\\ConverterAutocadCivil\\ConverterAutocadCivilShared\\ConverterAutocadCivilShared.shproj",
"Objects\\Converters\\ConverterAutocadCivil\\ConverterCivil2021\\ConverterCivil2021.csproj",
"Objects\\Converters\\ConverterAutocadCivil\\ConverterCivil2022\\ConverterCivil2022.csproj",
"Objects\\Converters\\ConverterAutocadCivil\\ConverterCivil2023\\ConverterCivil2023.csproj",
"Objects\\Converters\\ConverterAutocadCivil\\ConverterCivil2024\\ConverterCivil2024.csproj",
"Objects\\Objects\\Objects.csproj",
"Objects\\Tests\\Tests.csproj"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public override async Task<StreamState> ReceiveStream(StreamState state, Progres
var containers = Preview
.Select(o => o.Container)
.Distinct()
.ToList()
.Where(o => !string.IsNullOrEmpty(o))
.OrderBy(path => path.Count(c => c == ':'))
.ToList();
// if on create mode, make sure the parent commit layer is created first
Expand Down Expand Up @@ -219,8 +219,8 @@ public override async Task<StreamState> ReceiveStream(StreamState state, Progres
// Check converter (ViewToNative and LevelToNative) to make sure these names correspond!
var name =
state.ReceiveMode == ReceiveMode.Create
? $"{commitLayerName} - {previewObj.applicationId}"
: previewObj.applicationId;
? $"{commitLayerName} - {StoredObjects[previewObj.OriginalId]["name"] as string}"
: StoredObjects[previewObj.OriginalId]["name"] as string;
var viewId = Doc.NamedViews.FindByName(name);
var planeId = Doc.NamedConstructionPlanes.Find(name);
if (viewId != -1)
Expand Down Expand Up @@ -338,14 +338,11 @@ ApplicationObject NewAppObj()
.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries)
.LastOrDefault();

// get the application id and container
// special cases for views and levels, since we are searching for them by name instead of application id
var applicationId =
speckleType.Contains("View") || speckleType.Contains("Level")
? current["name"] as string
: current.applicationId;
var container = speckleType.Contains("View") || speckleType.Contains("Level") ? null : containerId;
return new ApplicationObject(current.id, speckleType) { applicationId = applicationId, Container = container };
return new ApplicationObject(current.id, speckleType)
{
applicationId = current.applicationId,
Container = containerId
};
}

// skip if it is the base commit collection
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using Autodesk.Revit.DB;
Expand Down Expand Up @@ -54,38 +54,43 @@ public ApplicationObject DisplayableObjectToNative(Base obj)

public RevitCategory GetSpeckleObjectCategory(Base @object)
{
switch (@object)
if (Enum.TryParse<RevitCategory>(@object["category"] as string, out RevitCategory category))
return category;
else
{
case BE.Beam _:
case BE.Brace _:
case BE.TeklaStructures.TeklaContourPlate _:
return RevitCategory.StructuralFraming;
case BE.TeklaStructures.Bolts _:
return RevitCategory.StructConnectionBolts;
case BE.TeklaStructures.Welds _:
return RevitCategory.StructConnectionWelds;
case BE.Floor _:
return RevitCategory.Floors;
case BE.Ceiling _:
return RevitCategory.Ceilings;
case BE.Column _:
return RevitCategory.Columns;
case BE.Pipe _:
return RevitCategory.PipeSegments;
case BE.Rebar _:
return RevitCategory.Rebar;
case BE.Topography _:
return RevitCategory.Topography;
case BE.Wall _:
return RevitCategory.Walls;
case BE.Roof _:
return RevitCategory.Roofs;
case BE.Duct _:
return RevitCategory.DuctSystem;
case BE.CableTray _:
return RevitCategory.CableTray;
default:
return RevitCategory.GenericModel;
switch (@object)
{
case BE.Beam _:
case BE.Brace _:
case BE.TeklaStructures.TeklaContourPlate _:
return RevitCategory.StructuralFraming;
case BE.TeklaStructures.Bolts _:
return RevitCategory.StructConnectionBolts;
case BE.TeklaStructures.Welds _:
return RevitCategory.StructConnectionWelds;
case BE.Floor _:
return RevitCategory.Floors;
case BE.Ceiling _:
return RevitCategory.Ceilings;
case BE.Column _:
return RevitCategory.Columns;
case BE.Pipe _:
return RevitCategory.PipeSegments;
case BE.Rebar _:
return RevitCategory.Rebar;
case BE.Topography _:
return RevitCategory.Topography;
case BE.Wall _:
return RevitCategory.Walls;
case BE.Roof _:
return RevitCategory.Roofs;
case BE.Duct _:
return RevitCategory.DuctSystem;
case BE.CableTray _:
return RevitCategory.CableTray;
default:
return RevitCategory.GenericModel;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,11 @@ public void SetConverterSettings(object settings)
{
if (settings is Dictionary<string, string> temp)
Settings = temp;

// TODO: Both settings bellow are here for backwards compatibility and should be removed after consolidating settings
else if (settings is MeshSettings meshSettings)
SelectedMeshSettings = meshSettings;
if (Settings.TryGetValue("preprocessGeometry", out string setting))
bool.TryParse(setting, out PreprocessGeometry);
var s = (MeshSettings)settings;
SelectedMeshSettings = s;
}

public void SetContextDocument(object doc)
Expand Down

0 comments on commit 0e5d4cd

Please sign in to comment.