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

unpack parameters as Dictionary #344

Closed
wants to merge 20 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
aee97d2
updates constructors and deprecates any unused code & functionality
clairekuang Oct 28, 2024
114356c
updates arcs and polycurves
clairekuang Oct 29, 2024
a400494
removes set only circle props
clairekuang Oct 29, 2024
47be734
updates box conversions
clairekuang Oct 30, 2024
eee9d17
Merge branch 'dev' into claire/cnx-687-purge-unused-classes-from-objects
clairekuang Oct 30, 2024
129395d
Merge branch 'dev' into claire/cnx-687-purge-unused-classes-from-objects
clairekuang Oct 30, 2024
6706def
fixes model curves and transforms
clairekuang Oct 31, 2024
232d859
Update ModelCurveToSpeckleTopLevelConverter.cs
clairekuang Nov 1, 2024
ff221a5
unpack parameters as Dictionnary
KatKatKateryna Nov 3, 2024
4595e35
Merge branch 'dev' into claire/cnx-687-purge-unused-classes-from-objects
clairekuang Nov 4, 2024
2d47837
Merge branch 'dev' into claire/cnx-687-purge-unused-classes-from-objects
clairekuang Nov 5, 2024
ad74743
bumps nugets
clairekuang Nov 5, 2024
a43332e
Merge branch 'claire/cnx-687-purge-unused-classes-from-objects' of ht…
clairekuang Nov 5, 2024
d65d53a
fixes package locks and arc
clairekuang Nov 5, 2024
ae08faa
updates rhino arc test
clairekuang Nov 5, 2024
bfc8807
Merge branch 'claire/cnx-687-purge-unused-classes-from-objects' into …
KatKatKateryna Nov 5, 2024
e8fede2
Merge branch 'dev' into claire_classes_ArcGIS_parameters
KatKatKateryna Nov 5, 2024
7d12302
add lists
KatKatKateryna Nov 5, 2024
9faedac
Merge branch 'dev' into claire_classes_ArcGIS_parameters
KatKatKateryna Nov 5, 2024
5343efc
refactor
KatKatKateryna Nov 6, 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
Next Next commit
updates constructors and deprecates any unused code & functionality
clairekuang committed Oct 28, 2024
commit aee97d2c77aa35126a154234e9f8e5316cacfc4f
Original file line number Diff line number Diff line change
@@ -110,10 +110,14 @@ private RenderMaterialProxy ConvertMaterialToRenderMaterialProxy(Material materi
diffuseColor.Blue
);

string name = material.Name;
double opacity = material.Opacity.Percentage;

RenderMaterial renderMaterial = new(opacity: opacity, diffuse: diffuse) { name = name, applicationId = id };
RenderMaterial renderMaterial =
new()
{
name = material.Name,
opacity = material.Opacity.Percentage,
diffuse = diffuse.ToArgb(),
applicationId = id
};

// Add additional properties
renderMaterial["ior"] = material.Refraction.Index;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging;
using Rhino;
using Rhino.DocObjects;
using Rhino.Render;
@@ -180,9 +180,14 @@ private SpeckleRenderMaterial ConvertRenderMaterialToSpeckle(RenderMaterial rend
: pbRenderMaterial.Emission.AsSystemColor(); // pbRenderMaterial.emission gives wrong color for emission materials, and material.emissioncolor gives the wrong value for most others *shrug*

SpeckleRenderMaterial speckleRenderMaterial =
new(opacity, pbRenderMaterial.Metallic, pbRenderMaterial.Roughness, diffuse, emissive)
new()
{
name = renderMaterialName,
opacity = opacity,
metalness = pbRenderMaterial.Metallic,
roughness = pbRenderMaterial.Roughness,
diffuse = diffuse.ToArgb(),
emissive = emissive.ToArgb(),
applicationId = renderMaterial.Id.ToString()
};

This file was deleted.

Original file line number Diff line number Diff line change
@@ -186,49 +186,10 @@ List<string> fieldAdded
{
if (field.Value is Base attributeBase)
{
// only traverse Base if it's Rhino userStrings, or Revit parameter, or Base containing Revit parameters
if (field.Key == "parameters")
{
foreach (KeyValuePair<string, object?> attributField in attributeBase.GetMembers(DynamicBaseMemberType.Dynamic))
{
// only iterate through elements if they are actually Revit Parameters or parameter IDs
if (
attributField.Value is Objects.BuiltElements.Revit.Parameter
|| attributField.Key == "applicationId"
|| attributField.Key == "id"
)
{
KeyValuePair<string, object?> newAttributField =
new($"{field.Key}.{attributField.Key}", attributField.Value);
Func<Base, object?> functionAdded = x => (function(x) as Base)?[attributField.Key];
TraverseAttributes(newAttributField, functionAdded, fieldsAndFunctions, fieldAdded);
}
}
}
else if (field.Key == "userStrings")
{
foreach (KeyValuePair<string, object?> attributField in attributeBase.GetMembers(DynamicBaseMemberType.Dynamic))
{
KeyValuePair<string, object?> newAttributField = new($"{field.Key}.{attributField.Key}", attributField.Value);
Func<Base, object?> functionAdded = x => (function(x) as Base)?[attributField.Key];
TraverseAttributes(newAttributField, functionAdded, fieldsAndFunctions, fieldAdded);
}
}
else if (field.Value is Objects.BuiltElements.Revit.Parameter)
{
foreach (
KeyValuePair<string, object?> attributField in attributeBase.GetMembers(DynamicBaseMemberType.Instance)
)
{
KeyValuePair<string, object?> newAttributField = new($"{field.Key}.{attributField.Key}", attributField.Value);
Func<Base, object?> functionAdded = x => (function(x) as Base)?[attributField.Key];
TraverseAttributes(newAttributField, functionAdded, fieldsAndFunctions, fieldAdded);
}
}
else
{
// for now, ignore all other properties of Base type
}
// Revit parameters are sent under the `properties` field as a `Dictionary<string,object?>`.
// This is the same for attributes from other applications. No Speckle objects should have attributes of type `Base`.
// Currently we are not sending any rhino user strings.
// TODO: add support for attributes of type `Dictionary<string,object?>`
}
else if (field.Value is IList attributeList)
{
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System.Xml.Linq;
using ArcGIS.Desktop.Mapping;
using Speckle.Objects.BuiltElements.Revit;
using Speckle.Sdk.Common;
using Speckle.Sdk.Models;

namespace Speckle.Converters.ArcGIS3.Utils;

@@ -70,35 +68,6 @@ private void NormalizeAngle()
}
}

public static double? RotationFromRevitData(Base rootObject)
{
// rewrite function to take into account Local reference point in Revit, and Transformation matrix
foreach (KeyValuePair<string, object?> prop in rootObject.GetMembers(DynamicBaseMemberType.Dynamic))
{
if (prop.Key == "info")
{
ProjectInfo? revitProjInfo = (ProjectInfo?)rootObject[prop.Key];
if (revitProjInfo != null)
{
try
{
if (revitProjInfo["locations"] is List<Base> locationList && locationList.Count > 0)
{
Base location = locationList[0];
return Convert.ToDouble(location["trueNorth"]);
}
}
catch (Exception ex) when (ex is FormatException || ex is InvalidCastException || ex is OverflowException)
{
// origin not found, do nothing
}
break;
}
}
}
return null;
}

/// <summary>
/// Initializes a new instance of <see cref="CRSoffsetRotation"/>.
/// </summary>
35 changes: 0 additions & 35 deletions Converters/ArcGIS/Speckle.Converters.ArcGIS3/Utils/CRSorigin.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using ArcGIS.Core.Geometry;
using Speckle.Objects.BuiltElements.Revit;
using Speckle.Sdk.Models;

namespace Speckle.Converters.ArcGIS3.Utils;

@@ -23,39 +21,6 @@ public CRSorigin(double latDegrees, double lonDegrees)
LonDegrees = lonDegrees;
}

public static CRSorigin? FromRevitData(Base rootObject)
{
// rewrite function to take into account Local reference point in Revit, and Transformation matrix
foreach (KeyValuePair<string, object?> prop in rootObject.GetMembers(DynamicBaseMemberType.Dynamic))
{
if (prop.Key == "info")
{
ProjectInfo? revitProjInfo = (ProjectInfo?)rootObject[prop.Key];
if (revitProjInfo != null)
{
try
{
double lat = Convert.ToDouble(revitProjInfo["latitude"]);
double lon = Convert.ToDouble(revitProjInfo["longitude"]);
double trueNorth;
if (revitProjInfo["locations"] is List<Base> locationList && locationList.Count > 0)
{
Base location = locationList[0];
trueNorth = Convert.ToDouble(location["trueNorth"]);
}
return new CRSorigin(lat * 180 / Math.PI, lon * 180 / Math.PI);
}
catch (Exception ex) when (ex is FormatException || ex is InvalidCastException || ex is OverflowException)
{
// origin not found, do nothing
}
break;
}
}
}
return null;
}

public SpatialReference CreateCustomCRS()
{
string wktString =
Loading