public static IClosedPlanar3D Profile(this MEPCurve mEPCurve) { Spatial.Plane plane = mEPCurve?.Plane(); if (plane == null) { return(null); } switch (mEPCurve.ConnectorProfileType()) { case Autodesk.Revit.DB.ConnectorProfileType.Rectangular: double width = Units.Convert.ToSI(mEPCurve.Width, Units.UnitType.Feet); double height = Units.Convert.ToSI(mEPCurve.Height, Units.UnitType.Feet); Planar.Point2D origin = new Planar.Point2D(-width / 2, -height / 2); Planar.Vector2D heightDirection = plane.Convert(plane.AxisY); return(new Rectangle3D(plane, new Planar.Rectangle2D(origin, width, height, heightDirection))); case Autodesk.Revit.DB.ConnectorProfileType.Round: double diameter = Units.Convert.ToSI(mEPCurve.Diameter, Units.UnitType.Feet); double radius = diameter / 2; return(new Circle3D(plane, radius)); case Autodesk.Revit.DB.ConnectorProfileType.Oval: throw new System.NotImplementedException(); } return(null); }
public override bool FromJObject(JObject jObject) { if (!base.FromJObject(jObject)) { return(false); } if (jObject.ContainsKey("Location")) { location = new Planar.Point2D(jObject.Value <JObject>("Location")); } if (jObject.ContainsKey("Elbow")) { elbow = new Planar.Point2D(jObject.Value <JObject>("Elbow")); } if (jObject.ContainsKey("End")) { end = new Planar.Point2D(jObject.Value <JObject>("End")); } if (jObject.ContainsKey("ReferenceId")) { referenceId = new IntegerId(jObject.Value <JObject>("ReferenceId")); } return(true); }
public Tag(TagType tagType, IntegerId viewId, Planar.Point2D location, Planar.Point2D elbow, Planar.Point2D end, IntegerId referenceId) : base(tagType, viewId) { this.location = location == null ? null : new Planar.Point2D(location); this.referenceId = referenceId == null ? null : new IntegerId(referenceId); this.elbow = elbow == null ? null : new Planar.Point2D(elbow); this.end = end == null ? null : new Planar.Point2D(end); }
private static List <Face3D> Profiles_RoofBase(this RoofBase roofBase) { List <Face3D> face3Ds = TopProfiles(roofBase); IEnumerable <ElementId> elementIds = roofBase.GetDependentElements(new ElementCategoryFilter(BuiltInCategory.OST_Windows)); if (elementIds == null || elementIds.Count() == 0) { return(face3Ds); } foreach (ElementId elementId in elementIds) { Element element = roofBase.Document.GetElement(elementId); if (element == null) { continue; } BoundingBoxXYZ boundingBoxXYZ = element.get_BoundingBox(null); Point3D point3D = ((boundingBoxXYZ.Max + boundingBoxXYZ.Min) / 2).ToSAM(); foreach (Face3D face3D in face3Ds) { List <Planar.IClosed2D> internalEdges = face3D.InternalEdge2Ds; if (internalEdges == null || internalEdges.Count == 0) { continue; } Spatial.Plane plane = face3D.GetPlane(); Point3D point3D_Projected = plane.Project(point3D); Planar.Point2D point2D = plane.Convert(point3D_Projected); for (int i = 0; i < internalEdges.Count; i++) { Planar.IClosed2D internalEdge = internalEdges[i]; if (internalEdge.Inside(point2D)) { face3D.RemoveInternalEdge(i); break; } } } } return(face3Ds); }
public static Tag ToSAM(this IndependentTag independentTag, ConvertSettings convertSettings) { if (independentTag == null) { return(null); } Document document = independentTag.Document; if (document == null) { return(null); } Tag result = convertSettings?.GetObject <Tag>(independentTag.Id); if (result != null) { return(result); } TagType tagType = ToSAM_TagType(document.GetElement(independentTag.GetTypeId()) as FamilySymbol, convertSettings); if (tagType == null) { return(null); } ElementId elementId = independentTag.OwnerViewId; if (elementId == null) { return(null); } View view = document.GetElement(elementId) as View; if (view == null) { return(null); } IntegerId viewId = Query.IntegerId(view); #if Revit2017 IntegerId referenceId = null; #else IntegerId referenceId = Query.IntegerId(document.GetElement(independentTag.GetTaggedReference())); #endif if (referenceId == null) { return(null); } Spatial.Point3D location = ToSAM(independentTag.TagHeadPosition); if (location == null) { return(null); } Planar.Point2D elbow = null; Planar.Point2D end = null; if (independentTag.HasLeader) { #if Revit2017 #else if (independentTag.HasElbow) { Spatial.Point3D elbow3D = ToSAM(independentTag.LeaderElbow); if (elbow3D != null) { elbow = new Planar.Point2D(elbow3D.X, elbow3D.Y); } } #endif if (independentTag.LeaderEndCondition == LeaderEndCondition.Free) { Spatial.Point3D end3D = ToSAM(independentTag.LeaderEnd); if (end3D != null) { end = new Planar.Point2D(end3D.X, end3D.Y); } } } result = new Tag(tagType, viewId, new Planar.Point2D(location.X, location.Y), elbow, end, referenceId); if (result != null) { result.SetValue(ElementParameter.RevitId, Query.IntegerId(independentTag)); result.SetValue(TagParameter.Leader, independentTag.HasLeader); result.SetValue(TagParameter.Orientation, independentTag.TagOrientation.ToString()); Core.Revit.Modify.SetValues(independentTag, result); convertSettings?.Add(independentTag.Id, result); } return(result); }
public static IndependentTag ToRevit(this Tag tag, Document document, ConvertSettings convertSettings) { if (tag == null || document == null) { return(null); } Core.IntegerId integerId_Reference = tag.ReferenceId; if (integerId_Reference == null) { return(null); } if (tag.BuiltInCategory() == BuiltInCategory.OST_MEPSpaceTags) { return(null); } FamilySymbol familySymbol = tag.Type?.ToRevit(document, convertSettings); if (familySymbol == null) { return(null); } Core.IntegerId integerId_View = tag.ViewId; if (integerId_View == null) { return(null); } View view = Core.Revit.Query.Element <View>(document, integerId_View, true); if (view == null) { return(null); } Element element = Query.Find <Element>(document, integerId_Reference); if (element == null) { return(null); } if (!tag.TryGetValue(TagParameter.Leader, out bool leader)) { leader = false; } TagOrientation tagOrientation = TagOrientation.Horizontal; if (tag.TryGetValue(TagParameter.Orientation, out string orientation)) { Enum.TryParse(orientation, out tagOrientation); } Planar.Point2D point2D = tag.Location; if (point2D == null) { return(null); } UV uV = point2D.ToRevit(); #if Revit2017 IndependentTag result = null; #elif Revit2018 IndependentTag result = IndependentTag.Create(document, view.Id, new Reference(element), leader, TagMode.TM_ADDBY_CATEGORY, tagOrientation, new XYZ(uV.U, uV.V, 0)); result.ChangeTypeId(familySymbol.Id); #else IndependentTag result = IndependentTag.Create(document, familySymbol.Id, view.Id, new Reference(element), leader, tagOrientation, new XYZ(uV.U, uV.V, 0)); #endif if (leader) { UV elbow = tag.Elbow?.ToRevit(); if (elbow != null) { result.LeaderElbow = new XYZ(elbow.U, elbow.V, 0); } UV end = tag.End?.ToRevit(); if (end != null) { result.LeaderEnd = new XYZ(end.U, end.V, 0); } } return(result); }