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

Messaging tweaked and bug in roof push fixed #1285

Merged
merged 5 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Revit_Core_Engine/Compute/GenerateProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ private static Family GenerateFreeformFamily(this Document document, BH.oM.Physi
}
catch (Exception ex)
{
BH.Engine.Base.Compute.RecordError($"Creation of a freeform Revit profile geometry failed because the family could not be temporarily saved in {m_TempFolder}. Please make sure the folder exists and you have access to it.");
BH.Engine.Base.Compute.RecordError($"Creation of a freeform Revit profile geometry failed because the family could not be temporarily saved in {m_TempFolder}. Please make sure the folder exists and you have access to it, then try to empty it in case the issue persists.");
familyDocument.Close(false);
return null;
}
Expand Down
3 changes: 3 additions & 0 deletions Revit_Core_Engine/Convert/Physical/ToRevit/Floor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ public static Floor ToRevitFloor(this oM.Physical.Elements.Floor floor, Document

PlanarSurface planarSurface = floor.Location as PlanarSurface;
if (planarSurface == null)
{
BH.Engine.Base.Compute.RecordError("Conversion from BHoM to Revit failed because only planar, non-disjoint floors are currently supported.");
return null;
}

settings = settings.DefaultIfNull();

Expand Down
26 changes: 22 additions & 4 deletions Revit_Core_Engine/Convert/Physical/ToRevit/RoofBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;

namespace BH.Revit.Engine.Core
{
Expand All @@ -49,14 +50,17 @@ public static RoofBase ToRevitRoofBase(this oM.Physical.Elements.Roof roof, Docu
if (roof == null || roof.Location == null || document == null)
return null;

PlanarSurface planarSurface = roof.Location as PlanarSurface;
if (planarSurface == null)
return null;

RoofBase roofBase = refObjects.GetValue<RoofBase>(document, roof.BHoM_Guid);
if (roofBase != null)
return roofBase;

PlanarSurface planarSurface = roof.Location as PlanarSurface;
if (planarSurface == null)
{
BH.Engine.Base.Compute.RecordError("Conversion from BHoM to Revit failed because only planar, non-disjoint roofs are currently supported.");
return null;
}

settings = settings.DefaultIfNull();

RoofType roofType = roof.ElementType(document, settings);
Expand Down Expand Up @@ -109,6 +113,20 @@ public static RoofBase ToRevitRoofBase(this oM.Physical.Elements.Roof roof, Docu
if (roofBase == null)
return null;

document.Regenerate();

if (planarSurface.InternalBoundaries != null)
{
foreach (ICurve hole in planarSurface.InternalBoundaries)
{
document.Create.NewOpening(roofBase, Create.CurveArray(hole.IProject(plane).IToRevitCurves()), true);
}
}

if (roof.Openings?.Any() == true)
BH.Engine.Base.Compute.RecordWarning("BHoM currently does not support implicit conversion of roof openings to Revit, so they have been ignored." +
"\nIn order to push openings to Revit, please push them as individual ModelInstances with this roof as host.");

// Copy parameters from BHoM object to Revit element
roofBase.CopyParameters(roof, settings);

Expand Down
16 changes: 12 additions & 4 deletions Revit_Core_Engine/Convert/Physical/ToRevit/Wall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;

namespace BH.Revit.Engine.Core
{
Expand All @@ -49,14 +50,17 @@ public static Wall ToRevitWall(this oM.Physical.Elements.Wall wall, Document doc
if (wall == null || wall.Location == null || document == null)
return null;

PlanarSurface planarSurface = wall.Location as PlanarSurface;
if (planarSurface == null)
return null;

Wall revitWall = refObjects.GetValue<Wall>(document, wall.BHoM_Guid);
if (revitWall != null)
return revitWall;

PlanarSurface planarSurface = wall.Location as PlanarSurface;
if (planarSurface == null)
{
BH.Engine.Base.Compute.RecordError("Conversion from BHoM to Revit failed because only planar, non-disjoint walls are currently supported.");
return null;
}

settings = settings.DefaultIfNull();

WallType wallType = wall.ElementType(document, settings);
Expand All @@ -82,6 +86,10 @@ public static Wall ToRevitWall(this oM.Physical.Elements.Wall wall, Document doc
if (revitWall == null)
return null;

if (planarSurface.InternalBoundaries?.Any() == true || wall.Openings?.Any() == true)
BH.Engine.Base.Compute.RecordWarning("BHoM currently does not support implicit conversion of wall openings to Revit, so they have been ignored." +
"\nIn order to push openings to Revit, please push them as individual ModelInstances with this wall as host.");

// Copy parameters from BHoM object to Revit element
revitWall.CopyParameters(wall, settings);

Expand Down
5 changes: 4 additions & 1 deletion Revit_Core_Engine/Convert/Structure/FromRevit/Panels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ public static partial class Convert

foreach (PlanarSurface planarSurface in surfaces.Keys)
{
if (planarSurface.ExternalBoundary == null)
continue;

List<ICurve> internalBoundaries = new List<ICurve>();
if (surfaces[planarSurface] != null)
internalBoundaries.AddRange(surfaces[planarSurface].Select(x => x.ExternalBoundary.ITranslate(translation)));
Expand All @@ -144,7 +147,7 @@ public static partial class Convert

if (result.Count == 0)
{
result.Add(new oM.Structure.Elements.Panel { Property = property2D });
result.Add(new oM.Structure.Elements.Panel { Name = hostObject.Name, Property = property2D });
BH.Engine.Base.Compute.RecordError(String.Format("Conversion of Revit panel's location to BHoM failed. A panel without location is returned. Revit ElementId : {0}", hostObject.Id));
}

Expand Down
47 changes: 32 additions & 15 deletions Revit_Core_Engine/Query/AnalyticalOutlines.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,37 +45,54 @@ public static partial class Query
[Output("outlines", "The analytical outlines of the host object.")]
public static List<ICurve> AnalyticalOutlines(this HostObject hostObject, RevitSettings settings = null)
{
List<ICurve> result = new List<ICurve>();

#if (REVIT2018 || REVIT2019 || REVIT2020 || REVIT2021 || REVIT2022)
AnalyticalModel analyticalModel = hostObject.GetAnalyticalModel();
if (analyticalModel == null)
{
//TODO: appropriate warning or not - physical preferred?
return null;
}

settings = settings.DefaultIfNull();

List<ICurve> wallCurves = analyticalModel.GetCurves(AnalyticalCurveType.ActiveCurves).ToList().FromRevit();
if (wallCurves.Any(x => x == null))
foreach (Curve curve in analyticalModel.GetCurves(AnalyticalCurveType.ActiveCurves))
{
hostObject.UnsupportedOutlineCurveWarning();
return null;
ICurve converted = curve.IFromRevit();
if (converted is NurbsCurve)
{
BH.Engine.Base.Compute.RecordWarning("At least one of the analytical outline curves has a nurbs form - it has been simplified to a polyline.");
converted = new Polyline { ControlPoints = curve.Tessellate().Select(x => x.PointFromRevit()).ToList() };
}

result.Add(converted);
}

List<ICurve> result = BH.Engine.Geometry.Compute.IJoin(wallCurves, settings.DistanceTolerance).ConvertAll(c => c as ICurve);
settings = settings.DefaultIfNull();
result = BH.Engine.Geometry.Compute.IJoin(result, settings.DistanceTolerance).ConvertAll(c => c as ICurve);

#else
Document doc = hostObject.Document;
AnalyticalToPhysicalAssociationManager manager = AnalyticalToPhysicalAssociationManager.GetAnalyticalToPhysicalAssociationManager(doc);
AnalyticalPanel analyticalModel = doc.GetElement(manager.GetAssociatedElementId(hostObject.Id)) as AnalyticalPanel;
if (analyticalModel == null)
return null;

List<ICurve> result = new List<ICurve> { analyticalModel.GetOuterContour().FromRevit() };
result.AddRange(analyticalModel.GetAnalyticalOpeningsIds().Select(x => (doc.GetElement(x) as AnalyticalOpening).GetOuterContour().FromRevit()));
List<CurveLoop> loops = new List<CurveLoop> { analyticalModel.GetOuterContour() };
loops.AddRange(analyticalModel.GetAnalyticalOpeningsIds().Select(x => (doc.GetElement(x) as AnalyticalOpening).GetOuterContour()));

if (result.Any(x => x == null))
foreach (CurveLoop loop in loops)
{
hostObject.UnsupportedOutlineCurveWarning();
return null;
PolyCurve convertedLoop = new PolyCurve();
foreach (Curve curve in loop)
{
ICurve converted = curve.IFromRevit();
if (converted is NurbsCurve)
{
BH.Engine.Base.Compute.RecordWarning("At least one of the analytical outline curves has a nurbs form - it has been simplified to a polyline.");
converted = new Polyline { ControlPoints = curve.Tessellate().Select(x => x.PointFromRevit()).ToList() };
}

convertedLoop.Curves.Add(converted);
}

result.Add(convertedLoop);
}
#endif
if (result.Any(x => !x.IIsClosed(settings.DistanceTolerance)))
Expand Down