Skip to content

Commit

Permalink
fix(civil3d): added units to civil classes missing them (#3591)
Browse files Browse the repository at this point in the history
added units to civil classes missing them
  • Loading branch information
clairekuang authored Jul 25, 2024
1 parent af53b70 commit ffc35bf
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ public CivilAlignment AlignmentToSpeckle(CivilDB.Alignment alignment)
stationEquationDirections = directions,
offset = alignment.IsOffsetAlignment ? alignment.OffsetAlignmentInfo.NominalOffset : 0,
site = alignment.SiteName ?? "",
style = alignment.StyleName ?? ""
style = alignment.StyleName ?? "",
units = ModelUnits
};

AddNameAndDescriptionProperty(alignment.Name, alignment.Description, speckleAlignment);
Expand Down Expand Up @@ -542,7 +543,8 @@ public CivilProfile ProfileToSpeckle(CivilDB.Profile profile)
offset = profile.Offset,
style = profile.StyleName ?? "",
startStation = profile.StartingStation,
endStation = profile.EndingStation
endStation = profile.EndingStation,
units = ModelUnits
};

AddNameAndDescriptionProperty(profile.Name, profile.Description, speckleProfile);
Expand Down Expand Up @@ -615,8 +617,6 @@ public CivilProfile ProfileToSpeckle(CivilDB.Profile profile)
speckleProfile.displayValue = PolylineToSpeckle(pvis, profile.Closed);
}

speckleProfile.units = ModelUnits;

return speckleProfile;
}
private Line ProfileLineToSpeckle(ProfileTangent tangent)
Expand Down Expand Up @@ -1136,6 +1136,7 @@ public Pipe PipeToSpeckle(PressurePipe pipe)
private CivilDataField AppliedSubassemblyParamToSpeckle(IAppliedSubassemblyParam param)
{
CivilDataField baseParam = new(param.KeyName, param.ValueType.Name, param.ValueAsObject, null, null, param.DisplayName);

return baseParam;
}

Expand All @@ -1155,7 +1156,11 @@ private CivilAppliedSubassembly AppliedSubassemblyToSpeckle(AppliedSubassembly a
Point soePoint = PointToSpeckle(appliedSubassembly.OriginStationOffsetElevationToBaseline);
List<CivilDataField> speckleParameters = appliedSubassembly.Parameters.Select(p => AppliedSubassemblyParamToSpeckle(p)).ToList();

CivilAppliedSubassembly speckleAppliedSubassembly = new(appliedSubassembly.SubassemblyId.ToString(), subassembly.Name, speckleShapes, soePoint, speckleParameters);
CivilAppliedSubassembly speckleAppliedSubassembly = new(appliedSubassembly.SubassemblyId.ToString(), subassembly.Name, speckleShapes, soePoint, speckleParameters)
{
units = ModelUnits
};

return speckleAppliedSubassembly;
}

Expand Down Expand Up @@ -1201,7 +1206,11 @@ private CivilBaselineRegion BaselineRegionToSpeckle(BaselineRegion region)
}

// create the speckle region
CivilBaselineRegion speckleRegion = new(region.Name, region.StartStation, region.EndStation, assembly.Id.ToString(), assembly.Name, speckleAppliedAssemblies);
CivilBaselineRegion speckleRegion = new(region.Name, region.StartStation, region.EndStation, assembly.Id.ToString(), assembly.Name, speckleAppliedAssemblies)
{
units = ModelUnits
};

return speckleRegion;
}

Expand Down Expand Up @@ -1229,7 +1238,11 @@ private CivilCalculatedLink CalculatedLinkToSpeckle(CalculatedLink link)
specklePoints.Add(specklePoint);
}

CivilCalculatedLink speckleLink = new(codes, specklePoints);
CivilCalculatedLink speckleLink = new(codes, specklePoints)
{
units = ModelUnits
};

return speckleLink;
}

Expand All @@ -1240,7 +1253,11 @@ private CivilCalculatedPoint CalculatedPointToSpeckle(CalculatedPoint point)
Vector normalBaseline = VectorToSpeckle(point.NormalToBaseline);
Vector normalSubAssembly = VectorToSpeckle(point.NormalToSubassembly);
Point soePoint = PointToSpeckle(point.StationOffsetElevationToBaseline);
CivilCalculatedPoint speckleCalculatedPoint = new(specklePoint, codes, normalBaseline, normalSubAssembly, soePoint);
CivilCalculatedPoint speckleCalculatedPoint = new(specklePoint, codes, normalBaseline, normalSubAssembly, soePoint)
{
units = ModelUnits
};

return speckleCalculatedPoint;
}

Expand Down Expand Up @@ -1269,15 +1286,21 @@ private CivilBaseline BaselineToSpeckle(CivilDB.Baseline baseline)
var profile = Trans.GetObject(baseline.ProfileId, OpenMode.ForRead) as CivilDB.Profile;
CivilProfile speckleProfile = ProfileToSpeckle(profile);

speckleBaseline = new(baseline.Name, speckleRegions, baseline.SortedStations().ToList(), baseline.StartStation, baseline.EndStation, speckleAlignment, speckleProfile);
speckleBaseline = new(baseline.Name, speckleRegions, baseline.SortedStations().ToList(), baseline.StartStation, baseline.EndStation, speckleAlignment, speckleProfile)
{
units = ModelUnits
};
}
else
{
// get the baseline featureline
var featureline = Trans.GetObject(baseline.FeatureLineId, OpenMode.ForRead) as CivilDB.FeatureLine;
Featureline speckleFeatureline = FeaturelineToSpeckle(featureline);

speckleBaseline = new(baseline.Name, speckleRegions, baseline.SortedStations().ToList(), baseline.StartStation, baseline.EndStation, speckleFeatureline);
speckleBaseline = new(baseline.Name, speckleRegions, baseline.SortedStations().ToList(), baseline.StartStation, baseline.EndStation, speckleFeatureline)
{
units = ModelUnits
};
}

return speckleBaseline;
Expand Down
2 changes: 2 additions & 0 deletions Objects/Objects/BuiltElements/Baseline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ protected Baseline(string name, bool isFeaturelineBased)
public Featureline? featureline { get; internal set; }

public bool isFeaturelineBased { get; set; }

public string units { get; set; }
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ List<CivilDataField> parameters

[DetachProperty]
public List<CivilDataField> parameters { get; set; }

public string units { get; set; }
}
2 changes: 2 additions & 0 deletions Objects/Objects/BuiltElements/Civil/CivilBaselineRegion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ List<CivilAppliedAssembly> appliedAssemblies

[DetachProperty]
public List<CivilAppliedAssembly> appliedAssemblies { get; set; }

public string units { get; set; }
}
2 changes: 2 additions & 0 deletions Objects/Objects/BuiltElements/Civil/CivilCalculatedLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ public CivilCalculatedLink(List<string> codes, List<CivilCalculatedPoint> points

[DetachProperty]
public List<CivilCalculatedPoint> points { get; set; }

public string units { get; set; }
}
2 changes: 2 additions & 0 deletions Objects/Objects/BuiltElements/Civil/CivilCalculatedPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ Point stationOffsetElevationToBaseline
public Vector normalToSubassembly { get; set; }

public Point stationOffsetElevationToBaseline { get; set; }

public string units { get; set; }
}

0 comments on commit ffc35bf

Please sign in to comment.