/// <summary> /// Creates a Conduit by a curve. /// </summary> /// <param name="conduitType">Type of the conduit.</param> /// <param name="curve">The curve.</param> /// <param name="featureline">The featureline.</param> /// <returns></returns> public static Conduit ByCurveFeatureline(Revit.Elements.Element conduitType, Autodesk.DesignScript.Geometry.Curve curve, Featureline featureline) { Utils.Log(string.Format("Conduit.ByCurveFeatureline started...", "")); var totalTransform = RevitUtils.DocumentTotalTransform(); if (!SessionVariables.ParametersCreated) { UtilsObjectsLocation.CheckParameters(DocumentManager.Instance.CurrentDBDocument); } var pipe = Conduit.ByCurve(conduitType, curve); // new Conduit(oType, s, e); var start = curve.StartPoint; var end = curve.EndPoint; var startSOE = featureline.GetStationOffsetElevationByPoint(start); var endSOE = featureline.GetStationOffsetElevationByPoint(end); double startStation = (double)startSOE["Station"]; double startOffset = (double)startSOE["Offset"]; double startElevation = (double)startSOE["Elevation"]; double endStation = (double)endSOE["Station"]; double endOffset = (double)endSOE["Offset"]; double endElevation = (double)endSOE["Elevation"]; pipe.SetParameterByName(ADSK_Parameters.Instance.Corridor.Name, featureline.Baseline.CorridorName); pipe.SetParameterByName(ADSK_Parameters.Instance.BaselineIndex.Name, featureline.Baseline.Index); pipe.SetParameterByName(ADSK_Parameters.Instance.RegionIndex.Name, featureline.BaselineRegionIndex); // 1.1.0 pipe.SetParameterByName(ADSK_Parameters.Instance.RegionRelative.Name, startStation - featureline.Start); // 1.1.0 pipe.SetParameterByName(ADSK_Parameters.Instance.RegionNormalized.Name, (startStation - featureline.Start) / (featureline.End - featureline.Start)); // 1.1.0 pipe.SetParameterByName(ADSK_Parameters.Instance.Code.Name, featureline.Code); pipe.SetParameterByName(ADSK_Parameters.Instance.Side.Name, featureline.Side.ToString()); pipe.SetParameterByName(ADSK_Parameters.Instance.X.Name, Math.Round(curve.StartPoint.X, 3)); pipe.SetParameterByName(ADSK_Parameters.Instance.Y.Name, Math.Round(curve.StartPoint.Y, 3)); pipe.SetParameterByName(ADSK_Parameters.Instance.Z.Name, Math.Round(curve.StartPoint.Z, 3)); pipe.SetParameterByName(ADSK_Parameters.Instance.Station.Name, Math.Round(startStation, 3)); pipe.SetParameterByName(ADSK_Parameters.Instance.Offset.Name, Math.Round(startOffset, 3)); pipe.SetParameterByName(ADSK_Parameters.Instance.Elevation.Name, Math.Round(startElevation, 3)); pipe.SetParameterByName(ADSK_Parameters.Instance.Update.Name, 1); pipe.SetParameterByName(ADSK_Parameters.Instance.Delete.Name, 0); pipe.SetParameterByName(ADSK_Parameters.Instance.EndStation.Name, Math.Round(endStation, 3)); pipe.SetParameterByName(ADSK_Parameters.Instance.EndOffset.Name, Math.Round(endOffset, 3)); pipe.SetParameterByName(ADSK_Parameters.Instance.EndElevation.Name, Math.Round(endElevation, 3)); pipe.SetParameterByName(ADSK_Parameters.Instance.EndRegionRelative.Name, endStation - featureline.Start); // 1.1.0 pipe.SetParameterByName(ADSK_Parameters.Instance.EndRegionNormalized.Name, (endStation - featureline.Start) / (featureline.End - featureline.Start)); // 1.1.0 if (start != null) { start.Dispose(); } if (end != null) { end.Dispose(); } Utils.Log(string.Format("Conduit.ByCurveFeatureline completed.", "")); return(pipe); }
/// <summary> /// Creates a CableTray by two Points. /// </summary> /// <param name="cableTrayType">Type of the cable tray.</param> /// <param name="start">The start Point in WCS.</param> /// <param name="end">The end Point in WCS.</param> /// <returns></returns> public static CableTray ByPoints(Revit.Elements.Element cableTrayType, Autodesk.DesignScript.Geometry.Point start, Autodesk.DesignScript.Geometry.Point end) { Utils.Log(string.Format("CableTray.ByPoints started...", "")); if (!SessionVariables.ParametersCreated) { UtilsObjectsLocation.CheckParameters(DocumentManager.Instance.CurrentDBDocument); } TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument); var oType = cableTrayType.InternalElement as Autodesk.Revit.DB.Electrical.CableTrayType; var totalTransform = RevitUtils.DocumentTotalTransform(); var nstart = start.Transform(totalTransform) as Autodesk.DesignScript.Geometry.Point; var s = nstart.ToXyz(); var nend = end.Transform(totalTransform) as Autodesk.DesignScript.Geometry.Point; var e = nend.ToXyz(); TransactionManager.Instance.TransactionTaskDone(); if (nstart != null) { nstart.Dispose(); } if (nend != null) { nend.Dispose(); } Utils.Log(string.Format("CableTray.ByPoints completed.", "")); return(new CableTray(oType, s, e)); }
public static Autodesk.DesignScript.Geometry.Mesh GetMeshFromElem(Revit.Elements.Element element) { rDoc = RevitServices.Persistence.DocumentManager.Instance.CurrentDBDocument; geoOpt = rDoc.Application.Create.NewGeometryOptions(); geoOpt.ComputeReferences = true; geoOpt.IncludeNonVisibleObjects = false; object retrievedMeshes = GetMeshes(element); Autodesk.DesignScript.Geometry.Mesh m = null; if (retrievedMeshes is IList) { int counter = 0; while (retrievedMeshes is IList) { List <Autodesk.DesignScript.Geometry.Mesh> listData = (List <Autodesk.DesignScript.Geometry.Mesh>)retrievedMeshes; retrievedMeshes = listData[0]; counter++; if (counter > 100) { break; } } m = retrievedMeshes as Autodesk.DesignScript.Geometry.Mesh; } else { m = retrievedMeshes as Autodesk.DesignScript.Geometry.Mesh; } return(m); }
/// <summary> /// Create Conduits following a polycurve /// </summary> /// <param name="conduitType">The conduit type.</param> /// <param name="polyCurve">the Polycurve to follow.</param> /// <returns></returns> private static Conduit[] ByPolyCurve(Revit.Elements.Element conduitType, PolyCurve polyCurve) { Utils.Log(string.Format("Conduit.ByPolyCurve started...", "")); var oType = conduitType.InternalElement as Autodesk.Revit.DB.Electrical.ConduitType; IList <ElementId> ids = new List <ElementId>(); TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument); foreach (Autodesk.DesignScript.Geometry.Curve c in polyCurve.Curves()) { Conduit ct = Conduit.ByCurve(conduitType, c); ids.Add(ct.InternalMEPCurve.Id); } for (int i = 0; i < GetConduitByIds(ids).Length - 1; ++i) { Conduit ct1 = GetConduitByIds(ids)[i]; Conduit ct2 = GetConduitByIds(ids)[i + 1]; Fitting.Elbow(ct1, ct2); } TransactionManager.Instance.TransactionTaskDone(); Utils.Log(string.Format("Conduit.ByPolyCurve completed.", "")); return(GetConduitByIds(ids)); }
/// <summary> /// Creates a Conduit by a curve. /// </summary> /// <param name="conduitType">Type of the conduit.</param> /// <param name="curve">The curve.</param> /// <returns></returns> public static Conduit ByCurve(Revit.Elements.Element conduitType, Autodesk.DesignScript.Geometry.Curve curve) { Utils.Log(string.Format("Conduit.ByCurve started...", "")); var totalTransform = RevitUtils.DocumentTotalTransform(); if (!SessionVariables.ParametersCreated) { UtilsObjectsLocation.CheckParameters(DocumentManager.Instance.CurrentDBDocument); } var oType = conduitType.InternalElement as Autodesk.Revit.DB.Electrical.ConduitType; Autodesk.DesignScript.Geometry.Point start = curve.StartPoint.Transform(totalTransform) as Autodesk.DesignScript.Geometry.Point; var s = start.ToXyz(); Autodesk.DesignScript.Geometry.Point end = curve.EndPoint.Transform(totalTransform) as Autodesk.DesignScript.Geometry.Point; var e = end.ToXyz(); if (start != null) { start.Dispose(); } if (end != null) { end.Dispose(); } Utils.Log(string.Format("Conduit.ByCurve completed.", "")); return(new Conduit(oType, s, e)); }
/// <summary> /// Creates a pipe by two points. /// </summary> /// <param name="ductType">Type of the duct.</param> /// <param name="mechanicalSystemType">Type of the mechanical system.</param> /// <param name="start">The start.</param> /// <param name="end">The end.</param> /// <param name="level">The level.</param> /// <returns></returns> public static Duct ByPoints(Revit.Elements.Element ductType, Revit.Elements.Element mechanicalSystemType, Autodesk.DesignScript.Geometry.Point start, Autodesk.DesignScript.Geometry.Point end, Revit.Elements.Level level) { Utils.Log(string.Format("Duct.ByPoints started...", "")); var totalTransform = RevitUtils.DocumentTotalTransform(); if (!SessionVariables.ParametersCreated) { UtilsObjectsLocation.CheckParameters(DocumentManager.Instance.CurrentDBDocument); } var oType = ductType.InternalElement as Autodesk.Revit.DB.Mechanical.DuctType; var oSystemType = mechanicalSystemType.InternalElement as Autodesk.Revit.DB.Mechanical.MechanicalSystemType; start = start.Transform(totalTransform) as Autodesk.DesignScript.Geometry.Point; var s = start.ToXyz(); end = end.Transform(totalTransform) as Autodesk.DesignScript.Geometry.Point; var e = end.ToXyz(); var l = level.InternalElement as Autodesk.Revit.DB.Level; totalTransform.Dispose(); Utils.Log(string.Format("Duct.ByPoints completed.", "")); return(new Duct(oType, oSystemType, s, e, l)); }
/// <summary> /// Creates a pipe by curve. /// </summary> /// <param name="pipeType">Type of the pipe.</param> /// <param name="pipingSystemType">Type of the piping system.</param> /// <param name="curve">The curve.</param> /// <param name="level">The level.</param> /// <returns></returns> public static Pipe ByCurve(Revit.Elements.Element pipeType, Revit.Elements.Element pipingSystemType, Autodesk.DesignScript.Geometry.Curve curve, Revit.Elements.Level level) { Utils.Log(string.Format("Pipe.ByCurve started...", "")); if (!SessionVariables.ParametersCreated) { UtilsObjectsLocation.CheckParameters(DocumentManager.Instance.CurrentDBDocument); } var oType = pipeType.InternalElement as Autodesk.Revit.DB.Plumbing.PipeType; var oSystemType = pipingSystemType.InternalElement as Autodesk.Revit.DB.Plumbing.PipingSystemType; var totalTransform = RevitUtils.DocumentTotalTransform(); var start = curve.StartPoint.Transform(totalTransform) as Autodesk.DesignScript.Geometry.Point; var s = start.ToXyz(); var end = curve.EndPoint.Transform(totalTransform) as Autodesk.DesignScript.Geometry.Point; var e = end.ToXyz(); var l = level.InternalElement as Autodesk.Revit.DB.Level; if (start != null) { start.Dispose(); } if (end != null) { end.Dispose(); } Utils.Log(string.Format("Pipe.ByCurve completed.", "")); return(new Pipe(oType, oSystemType, s, e, l)); }
/// <summary> /// Update an elements location Point /// </summary> /// <param name="element"></param> /// <param name="point"></param> public static void UpdateLocationPoint(Revit.Elements.Element element, Point point) { if (element.InternalElement.Location.GetType() == typeof(Autodesk.Revit.DB.LocationPoint)) { Autodesk.Revit.DB.LocationPoint pt = (Autodesk.Revit.DB.LocationPoint)element.InternalElement.Location; pt.Point = point.ToRevitType(true); } }
private static ElementCurveReference TryGetCurveReference(Revit.Elements.Element curveObject, string nodeTypeString = "This node") { var cs = curveObject.InternalGeometry().OfType<Autodesk.Revit.DB.Curve>(); if (cs.Any()) return new ElementCurveReference(cs.First()); throw new ArgumentException(nodeTypeString + " requires a ElementCurveReference extracted from a Revit Element! " + "You supplied an " + curveObject.ToString() + ", but we could not extract a CurveReference from it!"); }
/// <summary> /// Update an elements location curve /// </summary> /// <param name="element"></param> /// <param name="curve"></param> public static void UpdateLocationCurve(Revit.Elements.Element element, Curve curve) { if (element.InternalElement.Location.GetType() == typeof(Autodesk.Revit.DB.LocationCurve)) { Autodesk.Revit.DB.LocationCurve pt = (Autodesk.Revit.DB.LocationCurve)element.InternalElement.Location; pt.Curve = curve.ToRevitType(true); } }
/// <summary> /// Creates a CableTray using the start and end points of a curve. /// </summary> /// <param name="cableTrayType">The CableTray Type.</param> /// <param name="curve">The Curve</param> /// <returns></returns> public static CableTray ByCurve(Revit.Elements.Element cableTrayType, Autodesk.DesignScript.Geometry.Curve curve) { if (!SessionVariables.ParametersCreated) { UtilsObjectsLocation.CheckParameters(DocumentManager.Instance.CurrentDBDocument); } return(CableTrayByCurve(cableTrayType, curve)); }
/// <summary> /// Creates a set of CableTrays following a PolyCurve specifying a maximum length. /// </summary> /// <param name="CableTrayType">The CableTray type.</param> /// <param name="polyCurve">The PolyCurve to follow.</param> /// <param name="maxLength">The maximum length of the CableTrays following the PolyCurve.</param> /// <returns></returns> private CableTray[] ByPolyCurve(Revit.Elements.Element CableTrayType, PolyCurve polyCurve, double maxLength) { Utils.Log(string.Format("CableTray.ByPolyCurve started...", "")); var oType = CableTrayType.InternalElement as Autodesk.Revit.DB.Electrical.CableTrayType; double length = polyCurve.Length; double subdivisions = Math.Ceiling(length / maxLength); double increment = 1 / subdivisions; IList <double> parameters = new List <double>(); double parameter = 0; IList <Autodesk.DesignScript.Geometry.Point> points = new List <Autodesk.DesignScript.Geometry.Point>(); while (parameter <= 1) { points.Add(polyCurve.PointAtParameter(parameter)); parameter = parameter + increment; } points.Add(polyCurve.EndPoint); points = Autodesk.DesignScript.Geometry.Point.PruneDuplicates(points); IList <ElementId> ids = new List <ElementId>(); TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument); var totalTransform = RevitUtils.DocumentTotalTransform(); for (int i = 0; i < points.Count - 1; ++i) { Autodesk.DesignScript.Geometry.Point start = points[i].Transform(totalTransform) as Autodesk.DesignScript.Geometry.Point; var s = start.ToXyz(); Autodesk.DesignScript.Geometry.Point end = points[i + 1].Transform(totalTransform) as Autodesk.DesignScript.Geometry.Point; var e = end.ToXyz(); Autodesk.Revit.DB.Electrical.CableTray p = Autodesk.Revit.DB.Electrical.CableTray.Create(DocumentManager.Instance.CurrentDBDocument, oType.Id, s, e, ElementId.InvalidElementId); ids.Add(p.Id); } for (int i = 0; i < GetCableTrayByIds(ids).Length - 1; ++i) { CableTray ct1 = GetCableTrayByIds(ids)[i]; CableTray ct2 = GetCableTrayByIds(ids)[i + 1]; Fitting.Elbow(ct1, ct2); } TransactionManager.Instance.TransactionTaskDone(); Utils.Log(string.Format("CableTray.ByPolyCurve completed.", "")); return(GetCableTrayByIds(ids)); }
/// <summary> /// Creates a pipe by curve. /// </summary> /// <param name="ductType">Type of the duct.</param> /// <param name="mechanicalSystemType">Type of the mechanical system.</param> /// <param name="level">The level.</param> /// <param name="curve">The curve.</param> /// <param name="featureline">The featureline.</param> /// <returns></returns> public static Duct ByCurveFeatureline(Revit.Elements.Element ductType, Revit.Elements.Element mechanicalSystemType, Revit.Elements.Level level, Autodesk.DesignScript.Geometry.Curve curve, Featureline featureline) { Utils.Log(string.Format("Duct.ByCurveFeatureline started...", "")); var totalTransform = RevitUtils.DocumentTotalTransform(); if (!SessionVariables.ParametersCreated) { UtilsObjectsLocation.CheckParameters(DocumentManager.Instance.CurrentDBDocument); } var oType = ductType.InternalElement as Autodesk.Revit.DB.Mechanical.DuctType; var oSystemType = mechanicalSystemType.InternalElement as Autodesk.Revit.DB.Mechanical.MechanicalSystemType; var start = curve.StartPoint.Transform(totalTransform) as Autodesk.DesignScript.Geometry.Point; var s = start.ToXyz(); var end = curve.EndPoint.Transform(totalTransform) as Autodesk.DesignScript.Geometry.Point; var e = end.ToXyz(); var l = level.InternalElement as Autodesk.Revit.DB.Level; var pipe = new Duct(oType, oSystemType, s, e, l); var startSOE = featureline.GetStationOffsetElevationByPoint(curve.StartPoint); var endSOE = featureline.GetStationOffsetElevationByPoint(curve.EndPoint); double startStation = (double)startSOE["Station"]; double startOffset = (double)startSOE["Offset"]; double startElevation = (double)startSOE["Elevation"]; double endStation = (double)endSOE["Station"]; double endOffset = (double)endSOE["Offset"]; double endElevation = (double)endSOE["Elevation"];; pipe.SetParameterByName(ADSK_Parameters.Instance.Corridor.Name, featureline.Baseline.CorridorName); pipe.SetParameterByName(ADSK_Parameters.Instance.BaselineIndex.Name, featureline.Baseline.Index); pipe.SetParameterByName(ADSK_Parameters.Instance.RegionIndex.Name, featureline.BaselineRegionIndex); // 1.1.0 pipe.SetParameterByName(ADSK_Parameters.Instance.RegionRelative.Name, startStation - featureline.Start); // 1.1.0 pipe.SetParameterByName(ADSK_Parameters.Instance.RegionNormalized.Name, (startStation - featureline.Start) / (featureline.End - featureline.Start)); // 1.1.0 pipe.SetParameterByName(ADSK_Parameters.Instance.Code.Name, featureline.Code); pipe.SetParameterByName(ADSK_Parameters.Instance.Side.Name, featureline.Side.ToString()); pipe.SetParameterByName(ADSK_Parameters.Instance.X.Name, Math.Round(curve.StartPoint.X, 3)); pipe.SetParameterByName(ADSK_Parameters.Instance.Y.Name, Math.Round(curve.StartPoint.Y, 3)); pipe.SetParameterByName(ADSK_Parameters.Instance.Z.Name, Math.Round(curve.StartPoint.Z, 3)); pipe.SetParameterByName(ADSK_Parameters.Instance.Station.Name, Math.Round(startStation, 3)); pipe.SetParameterByName(ADSK_Parameters.Instance.Offset.Name, Math.Round(startOffset, 3)); pipe.SetParameterByName(ADSK_Parameters.Instance.Elevation.Name, Math.Round(startElevation, 3)); pipe.SetParameterByName(ADSK_Parameters.Instance.Update.Name, 1); pipe.SetParameterByName(ADSK_Parameters.Instance.Delete.Name, 0); pipe.SetParameterByName(ADSK_Parameters.Instance.EndStation.Name, Math.Round(endStation, 3)); pipe.SetParameterByName(ADSK_Parameters.Instance.EndOffset.Name, Math.Round(endOffset, 3)); pipe.SetParameterByName(ADSK_Parameters.Instance.EndElevation.Name, Math.Round(endElevation, 3)); pipe.SetParameterByName(ADSK_Parameters.Instance.EndRegionRelative.Name, endStation - featureline.Start); // 1.1.0 pipe.SetParameterByName(ADSK_Parameters.Instance.EndRegionNormalized.Name, (endStation - featureline.Start) / (featureline.End - featureline.Start)); // 1.1.0 totalTransform.Dispose(); Utils.Log(string.Format("Duct.ByCurveFeatureline completed.", "")); return(pipe); }
private void SetParameterValue(Autodesk.Revit.DB.Parameter param, Revit.Elements.Element value) { if (param.StorageType != StorageType.ElementId) { throw new Exception("The parameter's storage type is not an Element."); } param.Set(value.InternalElementId); }
internal WatchViewModel ProcessThing(Element element, string tag, bool showRawData = true) { var id = element.Id; var node = new WatchViewModel(element.ToString(dynSettings.Controller.PreferenceSettings.NumberFormat, CultureInfo.InvariantCulture), tag); node.Clicked += () => DocumentManager.Instance.CurrentUIDocument.ShowElements(element.InternalElement); node.Link = id.ToString(CultureInfo.InvariantCulture); return node; }
internal WatchViewModel ProcessThing(Element element, string tag, bool showRawData = true) { var id = element.Id; var node = new WatchViewModel(element.Name, tag); node.Clicked += () => DocumentManager.Instance.CurrentUIDocument.ShowElements(element.InternalElement); node.Link = id.ToString(CultureInfo.InvariantCulture); return node; }
internal WatchViewModel ProcessThing(Element element, string tag, bool showRawData = true) { var id = element.Id; var node = new WatchViewModel(element.ToString(dynSettings.Controller.PreferenceSettings.NumberFormat, CultureInfo.InvariantCulture), tag); node.Clicked += () => DocumentManager.Instance.CurrentUIDocument.ShowElements(element.InternalElement); node.Link = id.ToString(CultureInfo.InvariantCulture); return(node); }
/// <summary> /// Update an elements location curve /// </summary> /// <param name="element"></param> /// <param name="curve"></param> public static void UpdateLocationCurve(Revit.Elements.Element element, Curve curve) { if (element.InternalElement.Location.GetType() == typeof(Autodesk.Revit.DB.LocationCurve)) { Autodesk.Revit.DB.Document document = DocumentManager.Instance.CurrentDBDocument; TransactionManager.Instance.EnsureInTransaction(document); Autodesk.Revit.DB.LocationCurve pt = (Autodesk.Revit.DB.LocationCurve)element.InternalElement.Location; pt.Curve = curve.ToRevitType(true); TransactionManager.Instance.TransactionTaskDone(); } }
/// <summary> /// Creates a Conduit by revit Conduit. /// </summary> /// <param name="element">The MEP Curve from Revit</param> /// <returns></returns> public static Conduit ByRevitElement(Revit.Elements.Element element) { if (element.InternalElement is Autodesk.Revit.DB.Electrical.Conduit) { var c = element.InternalElement as Autodesk.Revit.DB.Electrical.Conduit; var conduit = new Conduit(); conduit.InternalSetMEPCurve(c); return(conduit); } return(null); }
/// <summary> /// Creates a Conduit by revit Conduit. /// </summary> /// <param name="element">The MEP Curve from Revit</param> /// <returns></returns> public static Duct ByRevitElement(Revit.Elements.Element element) { if (element.InternalElement is Autodesk.Revit.DB.Mechanical.Duct) { var c = element.InternalElement as Autodesk.Revit.DB.Mechanical.Duct; var conduit = new Duct(); conduit.InternalSetMEPCurve(c); return(conduit); } return(null); }
private static ElementCurveReference TryGetCurveReference(Revit.Elements.Element curveObject, string nodeTypeString = "This node") { var cs = curveObject.InternalGeometry().OfType <Autodesk.Revit.DB.Curve>(); if (cs.Any()) { return(new ElementCurveReference(cs.First())); } throw new ArgumentException(string.Format(Properties.Resources.CurveReferenceExtractionFailure, nodeTypeString) + string.Format(Properties.Resources.CurveReferenceExtractionDetail, curveObject)); }
/// <summary> /// Creates a Conduit by revit Conduit. /// </summary> /// <param name="element">The MEP Curve from Revit</param> /// <returns></returns> public static Pipe ByRevitElement(Revit.Elements.Element element) { if (element.InternalElement is Autodesk.Revit.DB.Plumbing.Pipe) { var c = element.InternalElement as Autodesk.Revit.DB.Plumbing.Pipe; var conduit = new Pipe(); conduit.InternalSetMEPCurve(c); return(conduit); } return(null); }
/// <summary> /// Cover value to Offset value /// </summary> /// <param name="cover">Cover Value</param> /// <param name="barType">Rebar Bar Type</param> /// <returns>Offset</returns> public static double CoverToOffset(double cover, Revit.Elements.Element barType) { double offset = cover; if (barType.InternalElement != null) { Autodesk.Revit.DB.Structure.RebarBarType revitBarType = (Autodesk.Revit.DB.Structure.RebarBarType)barType.InternalElement; offset = cover + revitBarType.BarDiameter / 2; } return(offset); }
/// <summary> /// Normal Vector /// </summary> /// <param name="rebar"></param> /// <returns></returns> public static Vector GetNormal(Revit.Elements.Element rebar) { Autodesk.Revit.DB.Structure.Rebar bar = rebar.InternalElement as Autodesk.Revit.DB.Structure.Rebar; if (bar != null) { var sda = bar.GetShapeDrivenAccessor(); if (sda != null) { return(Vector.ByCoordinates(sda.Normal.X, sda.Normal.Y, sda.Normal.Z)); } } return(Vector.ByCoordinates(0, 0, 0)); }
/// <summary> /// Depth of multiplanar rebar /// </summary> /// <param name="rebar">Rebar element</param> /// <returns>Multiplanar depth</returns> public static double GetMultiplanarDepth(Revit.Elements.Element rebar) { Autodesk.Revit.DB.Structure.Rebar bar = rebar.InternalElement as Autodesk.Revit.DB.Structure.Rebar; if (bar != null) { var sda = bar.GetShapeDrivenAccessor(); if (sda != null) { return(sda.MultiplanarDepth); } } return(0.0); }
/// <summary> /// Overall height for spirals /// </summary> /// <param name="rebar"></param> /// <returns></returns> public static double GetHeight(Revit.Elements.Element rebar) { Autodesk.Revit.DB.Structure.Rebar bar = rebar.InternalElement as Autodesk.Revit.DB.Structure.Rebar; if (bar != null) { var sda = bar.GetShapeDrivenAccessor(); if (sda != null) { return(sda.Height.FromRvtLength()); } } return(0.0); }
/// <summary> /// Set Solid In View /// </summary> /// <param name="rebar">Single Rebar</param> /// <param name="view">3D View</param> /// <param name="solid">Solid</param> public static void SetSolidInView(Revit.Elements.Element rebar, Revit.Elements.Views.View3D view, bool solid) { Autodesk.Revit.DB.Structure.Rebar bar = rebar.InternalElement as Autodesk.Revit.DB.Structure.Rebar; if (bar != null) { Autodesk.Revit.DB.Document document = DocumentManager.Instance.CurrentDBDocument; TransactionManager.Instance.EnsureInTransaction(document); Autodesk.Revit.DB.View3D viewElement = (Autodesk.Revit.DB.View3D)view.InternalElement; bar.SetSolidInView(viewElement, solid); TransactionManager.Instance.TransactionTaskDone(); } }
/// <summary> /// Set Bar hidden Status /// </summary> /// <param name="rebar">Rebar element</param> /// <param name="view">Revit View</param> /// <param name="barIndex">Bar Index</param> /// <param name="hidden">Hidden Status</param> public static void SetBarHiddenStatus(Revit.Elements.Element rebar, Revit.Elements.Views.View view, int barIndex, bool hidden) { Autodesk.Revit.DB.Structure.Rebar bar = rebar.InternalElement as Autodesk.Revit.DB.Structure.Rebar; if (bar != null) { Autodesk.Revit.DB.Document document = DocumentManager.Instance.CurrentDBDocument; TransactionManager.Instance.EnsureInTransaction(document); Autodesk.Revit.DB.View viewElement = (Autodesk.Revit.DB.View)view.InternalElement; bar.SetBarHiddenStatus(viewElement, barIndex, hidden); TransactionManager.Instance.TransactionTaskDone(); } }
public static DividedPath ByCurveAndDivisions(Revit.Elements.Element element, int divisions) { if (element == null) { throw new ArgumentNullException("element"); } if (divisions < 2) { throw new Exception(Properties.Resources.NumberOfDivisionsMustBeGreaterThan2); } return(new DividedPath(new[] { ElementCurveReference.TryGetCurveReference(element) }, divisions)); }
public static DividedPath ByCurveAndDivisions(Revit.Elements.Element element, int divisions) { if (element == null) { throw new ArgumentNullException("element"); } if (divisions < 2) { throw new Exception("The number of divisions must be greater than 2!"); } return(new DividedPath(new[] { ElementCurveReference.TryGetCurveReference(element) }, divisions)); }
/// <summary> /// Constructs a new EgressResult. /// </summary> internal EgressResult(DynamoElement instance, PathOfTravel pathOfTravel, double maxEgressDistance) { this.Instance = instance; double totalPathLength = 0.0; this.Path = new List <DynamoCurve>(); foreach (Curve curve in pathOfTravel.GetCurves()) { totalPathLength += curve.Length; this.Path.Add(curve.ToProtoType()); } this.IsValid = totalPathLength < maxEgressDistance; }
/// <summary> /// Creates Panel from Revit Element /// </summary> /// <param name="element">Revit Element</param> /// <search>FromRevit, SAM Analytical Panel</search> public static IEnumerable <object> FromRevit(Revit.Elements.Element element) { TransactionManager.Instance.ForceCloseTransaction(); ConvertSettings convertSettings = new ConvertSettings(true, true, true); IEnumerable <SAM.Core.SAMObject> sAMObjects = SAM.Analytical.Revit.Convert.ToSAM(element.InternalElement, convertSettings); if (sAMObjects == null) { return(null); } return(sAMObjects); }
internal WatchViewModel ProcessThing(Element element, string tag, bool showRawData) { var id = element.Id; var node = new WatchViewModel(visualizationManager, element.ToString(preferences.NumberFormat, CultureInfo.InvariantCulture), tag); node.Clicked += () => { if (element.InternalElement.IsValidObject) DocumentManager.Instance.CurrentUIDocument.ShowElements(element.InternalElement); }; node.Link = id.ToString(CultureInfo.InvariantCulture); return node; }
internal WatchViewModel ProcessThing(Element element, string tag, bool showRawData = true) { var id = element.Id; // Do not process element for watch which have been removed // from the Revit database. if (!element.InternalElement.IsValidObject) { return null; } var elementString = element.ToString( dynSettings.Controller.PreferenceSettings.NumberFormat, CultureInfo.InvariantCulture); var node = new WatchViewModel(elementString, tag); node.Clicked += () => DocumentManager.Instance.CurrentUIDocument.ShowElements(element.InternalElement); node.Link = id.ToString(CultureInfo.InvariantCulture); return node; }
public static IEnumerable<Autodesk.Revit.DB.Solid> GetRevitSolids(Element ele) { return ele.InternalGeometry().OfType<Autodesk.Revit.DB.Solid>().ToArray(); }