public VISTA_ASSOCIADA GetVISTA_ASSOCIADA(byte[] imagem) { VISTA_ASSOCIADA vista = new VISTA_ASSOCIADA(); vista.IMAGEM = imagem; vista.INTEGER_VALUE = uiDoc.ActiveView.Id.IntegerValue; vista.NUVEM_REVISAO_ID = Convert.ToInt32(dataGridView1.CurrentRow.Cells[nameof(NUVEM_REVISAO.NUVEM_REVISAO_ID)].Value); if (uiDoc.ActiveView is revitDB.ViewPlan) { if ((uiDoc.ActiveView as revitDB.ViewPlan).LevelId != null) { try { revitDB.Level level = uiDoc.GetElement((uiDoc.ActiveView as revitDB.ViewPlan).LevelId) as revitDB.Level; vista.PAVIMENTO = level.Name; vista.ELEVACAO = level.Elevation * 0.3048; } catch { } } } vista.TIPO_DE_VISTA = uiDoc.ActiveView.Name + "- " + uiDoc.ActiveView.ViewType.ToString(); return(vista); }
protected override void SolveInstance(IGH_DataAccess DA) { Rhino.Geometry.Curve axis = null; DA.GetData("Axis", ref axis); WallType wallType = null; if (!DA.GetData("Type", ref wallType) && Params.Input[1].Sources.Count == 0) { wallType = Revit.ActiveDBDocument.GetElement(Revit.ActiveDBDocument.GetDefaultElementTypeId(ElementTypeGroup.WallType)) as WallType; } Autodesk.Revit.DB.Level level = null; DA.GetData("Level", ref level); if (level == null && axis != null) { level = Revit.ActiveDBDocument.FindLevelByElevation(axis.PointAtStart.Z / Revit.ModelUnits); } bool structural = true; DA.GetData("Structural", ref structural); double height = 0.0; if (!DA.GetData("Height", ref height)) { height = LiteralLengthValue(3.0); } DA.DisableGapLogic(); int Iteration = DA.Iteration; Revit.EnqueueAction((doc) => CommitInstance(doc, DA, Iteration, axis, wallType, level, structural, height)); }
private void InitializeListData() { if (null == m_wallTypeList || null == m_levelList) { throw new Exception("necessary data members don't initialize."); } RevitDB.Document document = m_commandData.Application.ActiveUIDocument.Document; RevitDB.FilteredElementCollector filteredElementCollector = new RevitDB.FilteredElementCollector(document); filteredElementCollector.OfClass(typeof(RevitDB.WallType)); m_wallTypeList = filteredElementCollector.Cast <RevitDB.WallType>().ToList <RevitDB.WallType>(); WallTypeComparer comparer = new WallTypeComparer(); m_wallTypeList.Sort(comparer); RevitDB.FilteredElementIterator iter = (new RevitDB.FilteredElementCollector(document)).OfClass(typeof(RevitDB.Level)).GetElementIterator(); iter.Reset(); while (iter.MoveNext()) { RevitDB.Level level = iter.Current as RevitDB.Level; if (null == level) { continue; } m_levelList.Add(level); } }
protected override void SolveInstance(IGH_DataAccess DA) { Rhino.Geometry.Curve boundary = null; DA.GetData("Boundary", ref boundary); Autodesk.Revit.DB.FloorType floorType = null; if (!DA.GetData("Type", ref floorType) && Params.Input[1].Sources.Count == 0) { floorType = Revit.ActiveDBDocument.GetElement(Revit.ActiveDBDocument.GetDefaultElementTypeId(ElementTypeGroup.FloorType)) as FloorType; } Autodesk.Revit.DB.Level level = null; DA.GetData("Level", ref level); if (level == null && boundary != null) { var boundaryBBox = boundary.GetBoundingBox(true); level = Revit.ActiveDBDocument.FindLevelByElevation(boundaryBBox.Min.Z / Revit.ModelUnits); } bool structural = true; DA.GetData("Structural", ref structural); DA.DisableGapLogic(); int Iteration = DA.Iteration; Revit.EnqueueAction((doc) => CommitInstance(doc, DA, Iteration, boundary, floorType, level, structural)); }
public static Level ToSAM(this Autodesk.Revit.DB.Level level, Core.Revit.ConvertSettings convertSettings) { if (level == null) { return(null); } Document document = level.Document; Level result = convertSettings?.GetObject <Level>(level.Id); if (result != null) { return(result); } double elevation = Query.Elevation(level); result = new Level(level.Name, elevation); result.UpdateParameterSets(level, ActiveSetting.Setting.GetValue <Core.TypeMap>(ActiveSetting.Name.ParameterMap)); //result.Add(Core.Revit.Query.ParameterSet(level)); convertSettings?.Add(level.Id, result); return(result); }
protected override void SolveInstance(IGH_DataAccess DA) { Rhino.Geometry.Curve axis = null; DA.GetData("Axis", ref axis); FamilySymbol familySymbol = null; if (!DA.GetData("Type", ref familySymbol) && Params.Input[1].Sources.Count == 0) { familySymbol = Revit.ActiveDBDocument.GetElement(Revit.ActiveDBDocument.GetDefaultFamilyTypeId(new ElementId(BuiltInCategory.OST_StructuralFraming))) as FamilySymbol; } if (familySymbol == null) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, string.Format("Parameter '{0}' There is no default structural framing family loaded.", Params.Input[1].Name)); DA.AbortComponentSolution(); return; } if (!familySymbol.IsActive) { familySymbol.Activate(); } Autodesk.Revit.DB.Level level = null; DA.GetData("Level", ref level); DA.DisableGapLogic(); int Iteration = DA.Iteration; Revit.EnqueueAction((doc) => CommitInstance(doc, DA, Iteration, axis, familySymbol, level)); }
/// <summary> /// Some families eg columns, need offsets to be set in a specific way. This tries to cover that. /// </summary> /// <param name="speckleElement"></param> /// <param name="familyInstance"></param> private void SetOffsets(DB.FamilyInstance familyInstance, RevitColumn speckleRevitColumn) { var topOffsetParam = familyInstance.get_Parameter(BuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM); var baseOffsetParam = familyInstance.get_Parameter(BuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM); var baseLevelParam = familyInstance.get_Parameter(BuiltInParameter.FAMILY_BASE_LEVEL_PARAM); var topLevelParam = familyInstance.get_Parameter(BuiltInParameter.FAMILY_TOP_LEVEL_PARAM); if (topLevelParam == null || baseLevelParam == null || baseOffsetParam == null || topOffsetParam == null) { return; } var baseOffset = ScaleToNative(speckleRevitColumn.baseOffset, speckleRevitColumn.units); var topOffset = ScaleToNative(speckleRevitColumn.topOffset, speckleRevitColumn.units); //these have been set previously DB.Level level = Doc.GetElement(baseLevelParam.AsElementId()) as DB.Level; DB.Level topLevel = Doc.GetElement(topLevelParam.AsElementId()) as DB.Level; //checking if BASE offset needs to be set before or after TOP offset if (topLevel != null && topLevel.Elevation + baseOffset <= level.Elevation) { baseOffsetParam.Set(baseOffset); topOffsetParam.Set(topOffset); } else { topOffsetParam.Set(topOffset); baseOffsetParam.Set(baseOffset); } }
protected override void TrySolveInstance(IGH_DataAccess dataAccess) { bool run = false; if (!dataAccess.GetData(2, ref run) || !run) { return; } ConvertSettings convertSettings = null; dataAccess.GetData(1, ref convertSettings); if (convertSettings == null) { convertSettings = Query.ConvertSettings(); } Level level = null; if (!dataAccess.GetData(0, ref level)) { return; } Document document = RhinoInside.Revit.Revit.ActiveDBDocument; Autodesk.Revit.DB.Level level_Revit = Architectural.Revit.Convert.ToRevit(level, document, convertSettings); dataAccess.SetData(0, level_Revit); }
public static Log Log(this Level level, Document document) { if (level == null || document == null) { return(null); } List <Autodesk.Revit.DB.Level> levels_Revit = new FilteredElementCollector(document).OfClass(typeof(Autodesk.Revit.DB.Level)).Cast <Autodesk.Revit.DB.Level>().ToList(); Log result = new Log(); Core.Revit.Create.Log(level, document); Autodesk.Revit.DB.Level level_Revit = levels_Revit.Find(x => System.Math.Abs(Query.Elevation(x) - level.Elevation) < Tolerance.MacroDistance); if (level_Revit == null) { result.Add("Revit Level with elevation {0} is missing.", LogRecordType.Error, level.Elevation); } else if (!level_Revit.Name.Equals(level.Name)) { result.Add("Revit Level {0} and SAM Level {1} names does not math.", LogRecordType.Warning, level_Revit.Name, level.Name); } return(result); }
/// <summary> /// Create a extrusion roof. /// </summary> private void createExtrusionRoof() { try { if (m_roofsManager.Profile.Size != 0) { Autodesk.Revit.DB.Level level = this.refLevelComboBox.SelectedItem as Autodesk.Revit.DB.Level; Autodesk.Revit.DB.RoofType roofType = this.extrusionRoofTypesComboBox.SelectedItem as Autodesk.Revit.DB.RoofType; Autodesk.Revit.DB.ReferencePlane refPlane = refPanesComboBox.SelectedItem as Autodesk.Revit.DB.ReferencePlane; if (level != null && roofType != null && refPlane != null) { Autodesk.Revit.DB.ExtrusionRoof roof = m_roofsManager.CreateExtrusionRoof(refPlane, level, roofType, m_start, m_end); if (roof == null) { TaskDialog.Show("Revit", "Invalid profile"); } else { this.extrusionRoofsListView.Items.Add(new RoofItem(roof)); this.extrusionRoofsListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); } } } else { TaskDialog.Show("Revit", "You should supply profile to create extrusion roof, click select button to select profile in Revit."); } } catch (Exception ex) { TaskDialog.Show("Revit", ex.Message); } }
protected override void SolveInstance(IGH_DataAccess DA) { Rhino.Geometry.Curve axis = null; DA.GetData("Axis", ref axis); FamilySymbol familySymbol = null; if (!DA.GetData("FamilyType", ref familySymbol) && Params.Input[1].Sources.Count == 0) { familySymbol = Revit.ActiveDBDocument.GetElement(Revit.ActiveDBDocument.GetDefaultFamilyTypeId(new ElementId(BuiltInCategory.OST_StructuralFraming))) as FamilySymbol; } if (!familySymbol.IsActive) { familySymbol.Activate(); } Autodesk.Revit.DB.Level level = null; DA.GetData("Level", ref level); DA.DisableGapLogic(); int Iteration = DA.Iteration; Revit.EnqueueAction((doc) => CommitInstance(doc, DA, Iteration, axis, familySymbol, level)); }
protected override void SolveInstance(IGH_DataAccess DA) { var location = new Rhino.Geometry.Plane(new Rhino.Geometry.Point3d(double.NaN, double.NaN, double.NaN), new Rhino.Geometry.Vector3d(double.NaN, double.NaN, double.NaN)); DA.GetData("Position", ref location); FamilySymbol familySymbol = null; DA.GetData("Type", ref familySymbol); Autodesk.Revit.DB.Level level = null; DA.GetData("Level", ref level); if (level == null) { level = Revit.ActiveDBDocument.FindLevelByElevation(location.Origin.Z / Revit.ModelUnits); } Autodesk.Revit.DB.HostObject host = null; DA.GetData("Host", ref host); DA.DisableGapLogic(); int Iteration = DA.Iteration; Revit.EnqueueAction((doc) => CommitInstance(doc, DA, Iteration, location, familySymbol, host, level)); }
/// <summary> /// Create a new footprint roof. /// </summary> private void createFootPrintRoof() { try { if (m_roofsManager.FootPrint.Size != 0) { Autodesk.Revit.DB.Level level = levelsComboBox.SelectedItem as Autodesk.Revit.DB.Level; Autodesk.Revit.DB.RoofType roofType = roofTypesComboBox.SelectedItem as Autodesk.Revit.DB.RoofType; if (level != null && roofType != null) { Autodesk.Revit.DB.FootPrintRoof roof = m_roofsManager.CreateFootPrintRoof(level, roofType); if (roof == null) { TaskDialog.Show("Revit", "Invalid footprint2"); } else { this.footPrintRoofsListView.Items.Add(new RoofItem(roof)); this.footPrintRoofsListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); } } } else { TaskDialog.Show("Revit", "You should supply footprint to create footprint roof, click select button to select footprint in Revit."); } } catch (Exception ex) { TaskDialog.Show("Revit", ex.Message + " : Footprint must be in closed loops."); } }
/// <summary> /// Create a Level from a user selected Element. /// </summary> /// <param name="level"></param> /// <param name="isRevitOwned"></param> /// <returns></returns> internal static Level FromExisting(Autodesk.Revit.DB.Level level, bool isRevitOwned) { return(new Level(level) { IsRevitOwned = isRevitOwned }); }
protected override void SolveInstance(IGH_DataAccess DA) { var boundaries = new List <Rhino.Geometry.Curve>(); if (!DA.GetDataList("Boundaries", boundaries)) { return; } Autodesk.Revit.DB.BuildingPadType buildingPadType = null; if (!DA.GetData("Type", ref buildingPadType) && Params.Input[1].Sources.Count == 0) { buildingPadType = Revit.ActiveDBDocument.GetElement(Revit.ActiveDBDocument.GetDefaultElementTypeId(ElementTypeGroup.BuildingPadType)) as BuildingPadType; } Autodesk.Revit.DB.Level level = null; DA.GetData("Level", ref level); if (level == null && boundaries.Count != 0) { var boundaryBBox = Rhino.Geometry.BoundingBox.Empty; foreach (var boundary in boundaries.OfType <Rhino.Geometry.Curve>()) { boundaryBBox.Union(boundary.GetBoundingBox(true)); } level = Revit.ActiveDBDocument.FindLevelByElevation(boundaryBBox.Min.Z / Revit.ModelUnits); } DA.DisableGapLogic(); int Iteration = DA.Iteration; Revit.EnqueueAction((doc) => CommitInstance(doc, DA, Iteration, boundaries, buildingPadType, level)); }
private void InitSpace( DB.Level level, DB.UV point) { DB.Document document = DocumentManager.Instance.CurrentDBDocument; // This creates a new wall and deletes the old one TransactionManager.Instance.EnsureInTransaction(document); //Phase 1 - Check to see if the object exists and should be rebound var roomElem = ElementBinder.GetElementFromTrace <DB.Mechanical.Space>(document); if (roomElem == null) { roomElem = document.Create.NewSpace(level, point); } InternalSetSpace(roomElem); TransactionManager.Instance.TransactionTaskDone(); if (roomElem != null) { ElementBinder.CleanupAndSetElementForTrace(document, this.InternalElement); } else { ElementBinder.SetElementForTrace(this.InternalElement); } }
public void SetNecessaryData(RevitDB.XYZ startPoint, RevitDB.XYZ endPoint, RevitDB.Level level, RevitDB.WallType type) { m_startPoint = startPoint; m_endPoint = endPoint; m_createlevel = level; m_createType = type; }
void CommitInstance ( Document doc, IGH_DataAccess DA, int Iteration, Rhino.Geometry.Curve curve, Autodesk.Revit.DB.FamilySymbol familySymbol, Autodesk.Revit.DB.Level level ) { var element = PreviousElement(doc, Iteration); if (!element?.Pinned ?? false) { ReplaceElement(doc, DA, Iteration, element); } else { try { var scaleFactor = 1.0 / Revit.ModelUnits; if (scaleFactor != 1.0) { curve?.Scale(scaleFactor); } if ( curve == null || curve.IsShort(Revit.ShortCurveTolerance) || curve.IsClosed || !curve.TryGetPlane(out var axisPlane, Revit.VertexTolerance) || curve.GetNextDiscontinuity(Rhino.Geometry.Continuity.C1_continuous, curve.Domain.Min, curve.Domain.Max, out double discontinuity) ) { throw new Exception(string.Format("Parameter '{0}' must be a C1 continuous planar non closed curve.", Params.Input[0].Name)); } var axisList = curve.ToHost().ToList(); Debug.Assert(axisList.Count == 1); if (element is FamilyInstance && familySymbol.Id != element.GetTypeId()) { var newElmentId = element.ChangeTypeId(familySymbol.Id); if (newElmentId != ElementId.InvalidElementId) { element = doc.GetElement(newElmentId); } } if (element is FamilyInstance familyInstance && element.Location is LocationCurve locationCurve) { locationCurve.Curve = axisList[0]; } else { element = CopyParametersFrom(doc.Create.NewFamilyInstance(axisList[0], familySymbol, level, Autodesk.Revit.DB.Structure.StructuralType.Beam), element); } ReplaceElement(doc, DA, Iteration, element); }
protected override void SolveInstance(IGH_DataAccess DA) { Rhino.Geometry.Curve axis = null; DA.GetData("Axis", ref axis); WallType wallType = null; if (!DA.GetData("FamilyType", ref wallType) && Params.Input[1].Sources.Count == 0) { wallType = Revit.ActiveDBDocument.GetElement(Revit.ActiveDBDocument.GetDefaultElementTypeId(ElementTypeGroup.WallType)) as WallType; } Autodesk.Revit.DB.Level level = null; DA.GetData("Level", ref level); if (level == null && axis != null) { using (var collector = new FilteredElementCollector(Revit.ActiveDBDocument)) { foreach (var levelN in collector.OfClass(typeof(Level)).ToElements().Cast <Level>().OrderBy(c => c.Elevation)) { if (level == null) { level = levelN; } else if (axis.PointAtStart.Z >= levelN.Elevation) { level = levelN; } } } } bool structural = true; DA.GetData("Structural", ref structural); double height = 0.0; if (!DA.GetData("Height", ref height)) { switch (Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem) { case Rhino.UnitSystem.None: case Rhino.UnitSystem.Inches: case Rhino.UnitSystem.Feet: height = 10.0 * Rhino.RhinoMath.UnitScale(Rhino.UnitSystem.Feet, Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem); break; default: height = 3.0 * Rhino.RhinoMath.UnitScale(Rhino.UnitSystem.Meters, Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem); break; } } DA.DisableGapLogic(); int Iteration = DA.Iteration; Revit.EnqueueAction((doc) => CommitInstance(doc, DA, Iteration, axis, wallType, level, structural, height)); }
void ReconstructLevelByElevation ( DB.Document doc, ref DB.Level element, [ParamType(typeof(Parameters.Elevation))] double elevation, Optional <DB.LevelType> type, Optional <string> name ) { var scaleFactor = 1.0 / Revit.ModelUnits; elevation *= scaleFactor; elevation += doc.GetBasePointLocation(Params.Input <Parameters.Elevation>("Elevation").ElevationBase).Z; SolveOptionalType(ref type, doc, DB.ElementTypeGroup.LevelType, nameof(type)); if (element is DB.Level level) { level.SetHeight(elevation); } else { var newLevel = DB.Level.Create ( doc, elevation ); var parametersMask = name.IsMissing ? new DB.BuiltInParameter[] { DB.BuiltInParameter.ELEM_FAMILY_AND_TYPE_PARAM, DB.BuiltInParameter.ELEM_FAMILY_PARAM, DB.BuiltInParameter.ELEM_TYPE_PARAM } : new DB.BuiltInParameter[] { DB.BuiltInParameter.ELEM_FAMILY_AND_TYPE_PARAM, DB.BuiltInParameter.ELEM_FAMILY_PARAM, DB.BuiltInParameter.ELEM_TYPE_PARAM, DB.BuiltInParameter.DATUM_TEXT }; ReplaceElement(ref element, newLevel, parametersMask); } ChangeElementTypeId(ref element, type.Value.Id); if (name != Optional.Missing && element != null) { try { element.Name = name.Value; } catch (Autodesk.Revit.Exceptions.ArgumentException e) { AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, $"{e.Message.Replace($".{Environment.NewLine}", ". ")}"); } } }
/// <summary> /// Initialize a Wall element /// </summary> /// <param name="curve"></param> /// <param name="wallType"></param> /// <param name="baseLevel"></param> /// <param name="height"></param> /// <param name="offset"></param> /// <param name="flip"></param> /// <param name="isStructural"></param> private void InitWall(Curve curve, Autodesk.Revit.DB.WallType wallType, Autodesk.Revit.DB.Level baseLevel, double height, double offset, bool flip, bool isStructural) { // This creates a new wall and deletes the old one TransactionManager.Instance.EnsureInTransaction(Document); //Phase 1 - Check to see if the object exists and should be rebound var wallElem = ElementBinder.GetElementFromTrace <Autodesk.Revit.DB.Wall>(Document); bool successfullyUsedExistingWall = false; //There was a modelcurve, try and set sketch plane // if you can't, rebuild if (wallElem != null && wallElem.Location is Autodesk.Revit.DB.LocationCurve) { var wallLocation = wallElem.Location as Autodesk.Revit.DB.LocationCurve; if ((wallLocation.Curve is Autodesk.Revit.DB.Line == curve is Autodesk.Revit.DB.Line) || (wallLocation.Curve is Autodesk.Revit.DB.Arc == curve is Autodesk.Revit.DB.Arc) || (wallLocation.Curve is Autodesk.Revit.DB.Ellipse == curve is Autodesk.Revit.DB.Ellipse)) { if (!CurveUtils.CurvesAreSimilar(wallLocation.Curve, curve)) { wallLocation.Curve = curve; } Autodesk.Revit.DB.Parameter baseLevelParameter = wallElem.get_Parameter(Autodesk.Revit.DB.BuiltInParameter.WALL_BASE_CONSTRAINT); Autodesk.Revit.DB.Parameter topOffsetParameter = wallElem.get_Parameter(Autodesk.Revit.DB.BuiltInParameter.WALL_USER_HEIGHT_PARAM); Autodesk.Revit.DB.Parameter wallTypeParameter = wallElem.get_Parameter(Autodesk.Revit.DB.BuiltInParameter.ELEM_TYPE_PARAM); if (baseLevelParameter.AsElementId() != baseLevel.Id) { baseLevelParameter.Set(baseLevel.Id); } if (Math.Abs(topOffsetParameter.AsDouble() - height) > 1.0e-10) { topOffsetParameter.Set(height); } if (wallTypeParameter.AsElementId() != wallType.Id) { wallTypeParameter.Set(wallType.Id); } successfullyUsedExistingWall = true; } } var wall = successfullyUsedExistingWall ? wallElem : Autodesk.Revit.DB.Wall.Create(Document, curve, wallType.Id, baseLevel.Id, height, offset, flip, isStructural); InternalSetWall(wall); TransactionManager.Instance.TransactionTaskDone(); // delete the element stored in trace and add this new one ElementBinder.CleanupAndSetElementForTrace(Document, InternalWall); }
/// <summary> /// Create a Room /// based on a location and a level /// </summary> /// <param name="point">Location point for the room</param> /// <param name="level">Level of the room</param> /// <returns></returns> public static CustomRoom ByPointAndLevel(Point point, Level level) { DB.Level revitLevel = level.InternalElement as DB.Level; DB.XYZ revitPoint = GeometryPrimitiveConverter.ToXyz(point); DB.UV uv = new DB.UV(revitPoint.X, revitPoint.Y); return(new CustomRoom(revitLevel, uv)); }
private void InternalSetLevel(Autodesk.Revit.DB.Level level) { TransactionManager.Instance.EnsureInTransaction(Document); // http://thebuildingcoder.typepad.com/blog/2011/01/family-instance-missing-level-property.html InternalFamilyInstance.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM).Set(level.Id); TransactionManager.Instance.TransactionTaskDone(); }
/// <summary> /// Create a `MEP Space /// based on a location /// </summary> /// <param name="point">Location point for the space</param> /// <returns></returns> public static Space ByPoint(Point point) { DB.XYZ revitPoint = GeometryPrimitiveConverter.ToXyz(point); DB.Level revitLevel = GetNearestLevel(revitPoint); DB.UV uv = new DB.UV(revitPoint.X, revitPoint.Y); return(new Space(revitLevel, uv)); }
public static double Elevation(this Autodesk.Revit.DB.Level level) { if (level == null) { return(double.NaN); } return(UnitUtils.ConvertFromInternalUnits(level.Elevation, DisplayUnitType.DUT_METERS)); }
void CommitInstance ( Document doc, IGH_DataAccess DA, int Iteration, Rhino.Geometry.Curve boundary, Autodesk.Revit.DB.RoofType roofType, Autodesk.Revit.DB.Level level ) { var element = PreviousElement(doc, Iteration); if (!element?.Pinned ?? false) { ReplaceElement(doc, DA, Iteration, element); } else { try { var scaleFactor = 1.0 / Revit.ModelUnits; if (scaleFactor != 1.0) { boundary?.Scale(scaleFactor); } if ( boundary == null || boundary.IsShort(Revit.ShortCurveTolerance) || !boundary.IsClosed || !boundary.TryGetPlane(out var boundaryPlane, Revit.VertexTolerance) || boundaryPlane.ZAxis.IsParallelTo(Rhino.Geometry.Vector3d.ZAxis) == 0 ) { throw new Exception(string.Format("Parameter '{0}' must be an horizontal planar closed curve.", Params.Input[0].Name)); } var curveArray = boundary.ToHost().ToCurveArray(); var footPintToModelCurvesMapping = new ModelCurveArray(); element = CopyParametersFrom(doc.Create.NewFootPrintRoof(curveArray, level, roofType, out footPintToModelCurvesMapping), element); if (element != null) { var boundaryBBox = boundary.GetBoundingBox(true); element.get_Parameter(BuiltInParameter.ROOF_BASE_LEVEL_PARAM).Set(level.Id); element.get_Parameter(BuiltInParameter.ROOF_LEVEL_OFFSET_PARAM).Set(boundaryBBox.Min.Z - level.Elevation); } ReplaceElement(doc, DA, Iteration, element); } catch (Exception e) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.Message); ReplaceElement(doc, DA, Iteration, null); } } }
public static View ViewPlan(this Document document, Autodesk.Revit.DB.Level level, string viewName = null, CurveLoop cropBox = null, ElementId viewTemplateId = null, ViewDetailLevel viewDetailLevel = ViewDetailLevel.Coarse) { View result = null; ViewFamilyType vft = Query.ViewFamilyType(document, ViewFamily.FloorPlan); result = Autodesk.Revit.DB.ViewPlan.Create(document, vft.Id, level.Id); Modify.SetViewDetailLevel(result, viewDetailLevel); if (cropBox != null) { try { ViewCropRegionShapeManager vcrShapeMgr = result.GetCropRegionShapeManager(); result.CropBoxVisible = true; vcrShapeMgr.SetCropShape(cropBox); } catch (Exception) { BH.Engine.Reflection.Compute.RecordWarning("Could not create the Floor Plan with the provided crop box. Check if the crop box is a valid geometry and if the view's designated template accepts it to change."); } } if (viewTemplateId != null) { try { result.ViewTemplateId = viewTemplateId; } catch (Exception) { BH.Engine.Reflection.Compute.RecordWarning("Could not apply the View Template of Id " + viewTemplateId + "'." + ". Please check if it's a valid ElementId."); } } if (!string.IsNullOrEmpty(viewName)) { try { #if (REVIT2018 || REVIT2019) result.ViewName = viewName; #else result.Name = viewName; #endif } catch { BH.Engine.Reflection.Compute.RecordWarning("There is already a view named '" + viewName + "'." + " It has been named '" + result.Name + "' instead."); } } return(result); }
public RevitLevel LevelToSpeckle(DB.Level revitLevel) { var speckleLevel = new RevitLevel(); speckleLevel.elevation = ScaleToSpeckle(revitLevel.Elevation); speckleLevel.name = revitLevel.Name; speckleLevel.createView = true; GetAllRevitParamsAndIds(speckleLevel, revitLevel); return(speckleLevel); }
/// <summary> /// Initialize a CeilingPlanView element /// </summary> private void InitCeilingPlanView(Autodesk.Revit.DB.Level level) { TransactionManager.Instance.EnsureInTransaction(Document); var vd = CreatePlanView(level, ViewFamily.CeilingPlan); InternalSetPlanView(vd); TransactionManager.Instance.TransactionTaskDone(); ElementBinder.CleanupAndSetElementForTrace(Document, this.InternalElement); }
protected static ViewPlan CreatePlanView(Autodesk.Revit.DB.Level level, Autodesk.Revit.DB.ViewFamily planType) { var viewFam = DocumentManager.Instance.ElementsOfType <ViewFamilyType>() .FirstOrDefault(x => x.ViewFamily == planType); if (viewFam == null) { throw new Exception("There is no such ViewFamily in the document"); } return(ViewPlan.Create(Document, viewFam.Id, level.Id));; }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void m_btnOk_Click(object sender, EventArgs e) { Debug.Assert((m_levlv.SelectedItems.Count > 1) == false); if (m_levlv.SelectedItems.Count != 0) m_selectedLevel = (Autodesk.Revit.DB.Level)m_levlv.SelectedItems[0].Tag; else m_selectedLevel = null; }