Skip to content

Commit

Permalink
QGIS attributes in Revit (#3595)
Browse files Browse the repository at this point in the history
duplicating attribute receive functionality from GisPolygon to GisFeature
  • Loading branch information
KatKatKateryna authored Jul 26, 2024
1 parent 82d9820 commit eeb7161
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,10 @@ public object ConvertToNativeObject(Base @object)
case PolygonElement o:
return PolygonElementToNative(o);

case GisFeature o:
return GisFeatureToNative(o);


#if (REVIT2024)
case RevitToposolid o:
return ToposolidToNative(o);
Expand Down Expand Up @@ -910,6 +914,8 @@ public bool CanConvertToNative(Base @object)
Organization.DataTable _ => true,
// GIS
PolygonElement _ => true,
GisFeature feat when (feat.GetMembers(DynamicBaseMemberType.All).TryGetValue("displayValue", out var value) &&
value is List<Base> valueList && valueList.Count > 0) => true,
_ => false,
};
if (objRes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,34 @@ namespace Objects.Converter.Revit;

public partial class ConverterRevit
{
public ApplicationObject GisFeatureToNative(GisFeature gisFeature)
{
// targeting Polygon features with List of Meshes as dispayValue
var speckleDirectShape = new Objects.BuiltElements.Revit.DirectShape()
{
applicationId = gisFeature.applicationId ??= Guid.NewGuid().ToString(),
baseGeometries = new List<Base>(),
parameters = new Base(),
name = "",
category = RevitCategory.GenericModel
};

var traversal = new GraphTraversal(DefaultTraversal.DefaultRule);
var meshes = traversal.Traverse(gisFeature).Select(tc => tc.current).Where(b => b is Mesh);

speckleDirectShape.baseGeometries.AddRange(meshes);

foreach (var kvp in gisFeature.attributes.GetMembers())
{
speckleDirectShape.parameters[kvp.Key] = new Objects.BuiltElements.Revit.Parameter()
{
name = kvp.Key,
value = kvp.Value
};
}
return DirectShapeToNative(speckleDirectShape, ToNativeMeshSettingEnum.Default);

}
public ApplicationObject PolygonElementToNative(PolygonElement polygonElement)
{
var speckleDirectShape = new Objects.BuiltElements.Revit.DirectShape()
Expand Down

0 comments on commit eeb7161

Please sign in to comment.