private static Autodesk.Revit.DB.Floor CreateFloor(IEnumerable<Value> edges, FloorType floorType, Autodesk.Revit.DB.Level level) { var ca = new CurveArray(); edges.ToList().ForEach(x => ca.Append((Curve) ((Value.Container) x).Item)); var floor = dynRevitSettings.Doc.Document.Create.NewFloor(ca, floorType, level, false); return floor; }
public VesselTile() { this.flags = (uint)FLAGS.NONE; this.wallMask = 0; this.wallNode = false; this.floor0 = FloorType.None; this.floor1 = FloorType.None; }
public VesselTile(WallTypeMask wallMask, bool wallNode, FloorType floor0, FloorType floor1, uint flags) { this.flags = flags; this.wallMask = (byte)wallMask; this.wallNode = wallNode; this.floor0 = floor0; this.floor1 = floor1; }
/// <summary> /// Called when the control has to load itself. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private async void OnLoaded(object sender, RoutedEventArgs e) { // Return here if the scene is already initialized if (CtrlView3D.Scene.CountObjects > 0) { return; } // Configure camera Camera3DBase camera = CtrlView3D.Camera as Camera3DBase; camera.Position = new Vector3(4f, 4f, 4f); camera.Target = new Vector3(0f, 0f, 0f); camera.UpdateCamera(); // Build default scene await CtrlView3D.Scene.ManipulateSceneAsync((manipulator) => { SceneLayer bgLayer = manipulator.AddLayer("BACKGROUND"); manipulator.SetLayerOrderID(bgLayer, 0); manipulator.SetLayerOrderID(Scene.DEFAULT_LAYER_NAME, 1); // Define background object var resBackgroundTexture = manipulator.AddTexture(new Uri( "/SeeingSharp.RKKinectLounge;component/Assets/Textures/Background.png", UriKind.Relative)); manipulator.Add(new TexturePainter(resBackgroundTexture), bgLayer.Name); // Define floor FloorType floorType = new FloorType(new Vector2(3f, 3f), 0.1f); floorType.SetTilemap(40, 40); floorType.DefaultFloorMaterial = manipulator.AddSimpleColoredMaterial(new Uri( "/SeeingSharp.RKKinectLounge;component/Assets/Textures/Floor.png", UriKind.Relative)); var resGeometry = manipulator.AddResource<GeometryResource>( () => new GeometryResource(floorType)); GenericObject floorObject = manipulator.AddGeneric(resGeometry); floorObject.IsPickingTestVisible = false; // Create pallet geometry resource PalletType pType = new PalletType(); pType.ContentColor = Color4.Transparent; var resPalletGeometry = manipulator.AddResource<GeometryResource>( () => new GeometryResource(pType)); // Create pallet object GenericObject palletObject = manipulator.AddGeneric(resPalletGeometry); palletObject.Color = Color4.GreenColor; palletObject.EnableShaderGeneratedBorder(); palletObject.BuildAnimationSequence() .RotateEulerAnglesTo(new Vector3(0f, EngineMath.RAD_180DEG, 0f), TimeSpan.FromSeconds(2.0)) .WaitFinished() .RotateEulerAnglesTo(new Vector3(0f, EngineMath.RAD_360DEG, 0f), TimeSpan.FromSeconds(2.0)) .WaitFinished() .CallAction(() => palletObject.RotationEuler = Vector3.Zero) .ApplyAndRewind(); }); }
/// <summary> /// Creates the Tower by stacking a series of Story instances from the Tower Elevation. /// </summary> /// <param name="floors">Desired quantity of stacked Stories to form the Tower. If greater than zero, overrides and resets the current Floors property.</param> /// <param name="storyHeight">Desired typical Story height of the Tower. If greater than zero, overrides and resets the current StoryHeight property.</param> /// <param name="basement">Whether to consider the lowest floor a basement.</param> /// <returns> /// True if the Tower is successfully stacked. /// </returns> public bool Stack() { if (Perimeter == null || storyHeight <= 0.0 || (Floors <= 0.0 && TargetArea <= 0.0)) { return(false); } if (TargetArea > 0.0) { Floors = (int)Math.Ceiling(TargetArea / Perimeter.Area()); } Stories.Clear(); var elevation = Elevation; var slabType = new FloorType(new Guid().ToString(), 0.1); for (int i = 0; i < Floors; i++) { if (elevation + storyHeight > HeightLimit) { break; } var story = new Story() { Color = color, Elevation = elevation, Height = storyHeight, Perimeter = perimeter, SlabType = slabType }; Stories.Add(story); elevation += storyHeight; } if (Stories.Count == 0) { return(false); } return(true); }
private void CreateFloorInRooms() { FloorType floorType; IList <Element> rooms; floorType = GetFloorTypeInProject(); Floor sourr; Floor sourr2; GetRoomInProject(out rooms); for (int i = 0; i < rooms.Count; i++) { CurveArray roomsCurves = new CurveArray(); var r1 = (Room)rooms[i]; SpatialElementBoundaryOptions bo = new SpatialElementBoundaryOptions(); IList <IList <BoundarySegment> > segments2 = r1.GetBoundarySegments(bo); CurveArray temp = new CurveArray(); if (null != segments2) { IList <BoundarySegment> segmentList = segments2[0]; foreach (BoundarySegment boundarySegment in segmentList) { Curve c = boundarySegment.GetCurve(); temp.Append(c); } SortCurves(temp); sourr = _doc.Create.NewFloor(temp, floorType, r1.Level, false); } } }
public void Setup(int row, int col, FloorType setFloorType) { SetID(row,col); floorType = setFloorType; switch(floorType) { case FloorType.NULL: Image.gameObject.SetActive(false); break; case FloorType.BLACK: Image.color = Color.grey; break; case FloorType.WHITE: Image.color = Color.white; break; case FloorType.RED: Image.color = Color.red; break; case FloorType.BLUE: Image.color = Color.blue; break; case FloorType.YELLOW: Image.color = Color.yellow; break; case FloorType.GREEN: Image.color = Color.green; break; case FloorType.ORANGE: Image.color = new Color(1,153f/255,0,1); break; case FloorType.PURPLE: Image.color = Color.magenta; break; } }
/// <summary> /// Convert an IfcSlab to a Floor. /// </summary> /// <param name="slab">An IfcSlab.</param> public static Floor ToFloor(this IfcSlab slab) { var transform = new Transform(); transform.Concatenate(slab.ObjectPlacement.ToTransform()); // Check if the slab is contained in a building storey foreach (var cis in slab.ContainedInStructure) { transform.Concatenate(cis.RelatingStructure.ObjectPlacement.ToTransform()); } var repItems = slab.Representation.Representations.SelectMany(r => r.Items); if (!repItems.Any()) { throw new Exception("The provided IfcSlab does not have any representations."); } var solid = slab.RepresentationsOfType <IfcExtrudedAreaSolid>().FirstOrDefault(); if (solid == null) { return(null); // throw new Exception("No IfcExtrudedAreaSolid could be found in the provided IfcSlab."); } var floorType = new FloorType($"{Guid.NewGuid().ToString()}_floor_type", (IfcLengthMeasure)solid.Depth); var outline = (Polygon)solid.SweptArea.ToICurve(); var solidTransform = solid.Position.ToTransform(); var floor = new Floor(new Profile(outline), solidTransform, solid.ExtrudedDirection.ToVector3(), floorType, 0, BuiltInMaterials.Default, transform); floor.Name = slab.Name; return(floor); }
public Floor(FloorType type, Direction direction) { this.type = type; this.direction = direction; }
/// <summary> /// The movement component of the game's regular updates. /// Handles calculations for the character's movement and moving animations. /// </summary> private void UpdateMove() { Vector3 move = lateralVelocity; int i = 0; while (i < standingOn.Count) { GameObject tile = standingOn[i]; if (!tile.activeSelf) { standingOn.RemoveAt(i); } else { i++; } } //Debug.Log(standingOn); if (standingOn.Count == 0) { //Debug.Log("Not Grounded"); standing = FloorType.None; isGrounded = false; } else { isGrounded = true; } //if (Input.GetKeyDown(KeyCode.Space) && isGrounded) //{ // yVelocity = jumpSpeed; // isGrounded = false; // animFrame = 0; //} bool[] d = { false, false, false, false }; Vector3 lateralMovement = new Vector3(); if (Input.GetAxisRaw("Vertical") > 0) { lateralMovement.z = Speed; d[0] = true; } else if (Input.GetAxisRaw("Vertical") < 0) { lateralMovement.z = -Speed; d[1] = true; } if (Input.GetAxisRaw("Horizontal") > 0) { lateralMovement.x = Speed; d[2] = true; } else if (Input.GetAxisRaw("Horizontal") < 0) { lateralMovement.x = -Speed; d[3] = true; } switch (standing) { case FloorType.Ice: lateralVelocity += (lateralMovement.normalized * iceFriction); lateralVelocity.x = Mathf.Clamp(lateralVelocity.x, -Speed * 1.5f, Speed * 1.5f); lateralVelocity.z = Mathf.Clamp(lateralVelocity.z, -Speed * 1.5f, Speed * 1.5f); break; case FloorType.Sticky: lateralVelocity = lateralMovement / 2; break; default: lateralVelocity = lateralMovement; break; } move = lateralVelocity; // Handles the sprite if (d[0] && !d[2] && !d[3]) { facing = 2; } else if (d[1] && !d[2] && !d[3]) { facing = 0; } else if (!d[0] && !d[1] && d[2]) { facing = 1; } else if (!d[0] && !d[1] && d[3]) { facing = 3; } if (!isGrounded) { animTimer -= Time.fixedDeltaTime; if (animTimer <= 0) { animFrame++; animFrame %= 3; resetAnimTimer(); } sprite.sprite = jumpSprites[facing * 3 + animFrame]; } else { if (d[0] || d[1] || d[2] || d[3]) { if (standing == FloorType.Sticky) { animTimer -= Time.fixedDeltaTime / 2; } else { animTimer -= Time.fixedDeltaTime; } if (animTimer <= 0) { animFrame++; resetAnimTimer(); } } else { if (facing == 1 || facing == 3) { animFrame = 0; } } animFrame %= 2; sprite.sprite = moveSprites[facing * 2 + animFrame]; } //UpdateSprite(); //Transform swordParent = GetComponentsInChildren<Transform>(); move.y = yVelocity; if (!isGrounded) { yVelocity -= gravityStrength * Time.fixedDeltaTime; if (yVelocity < terminalVelocity) { yVelocity = terminalVelocity; } } //Debug.Log("yVelocity " + yVelocity); rb.position += move; //isGrounded = false; }
private static Autodesk.Revit.DB.Floor CreateFloor(IEnumerable <Value> edges, FloorType floorType, Autodesk.Revit.DB.Level level) { var ca = new CurveArray(); edges.ToList().ForEach(x => ca.Append((Curve)((Value.Container)x).Item)); var floor = dynRevitSettings.Doc.Document.Create.NewFloor(ca, floorType, level, false); return(floor); }
public void AddFloor(FloorType floor) { _floors.Add(floor); }
private Floor CreateNewFloor(Room room, List <CurveArray> curveArrayList, FloorType floorType) { Floor newFloor = null; try { using (var trans = new Transaction(m_doc)) { trans.Start("Create Floor"); try { if (null != floorType && ElementId.InvalidElementId != room.LevelId) { var roomLevel = m_doc.GetElement(room.LevelId) as Level; newFloor = m_doc.Create.NewFloor(curveArrayList[0], floorType, roomLevel, false); } else { newFloor = m_doc.Create.NewFloor(curveArrayList[0], false); } trans.Commit(); } catch (Exception ex) { trans.RollBack(); MessageBox.Show("Cannot create floor from a room.\nRoom ElementId:" + room.Id.IntegerValue + "\n\n" + ex.Message, "Create Floor", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } using (var trans = new Transaction(m_doc)) { trans.Start("Create Openings"); try { if (null != newFloor && curveArrayList.Count > 1) { for (var i = 1; i < curveArrayList.Count; i++) { var opening = m_doc.Create.NewOpening(newFloor, curveArrayList[i], false); } } trans.Commit(); } catch (Exception ex) { trans.RollBack(); MessageBox.Show("Cannot create openings.\nRoom ElementId:" + room.Id.IntegerValue + "\n\n" + ex.Message, "Create Openings", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } using (var trans = new Transaction(m_doc)) { trans.Start("Move Floors"); try { if (null != newFloor) { var location = newFloor.Location; var thickness = GetFloorThickness(newFloor); var translationVec = new XYZ(0, 0, thickness); var moved = location.Move(translationVec); } trans.Commit(); } catch (Exception ex) { trans.RollBack(); MessageBox.Show("Cannot move floors.\nRoom ElementId:" + room.Id.IntegerValue + "\n\n" + ex.Message, "Move Floors", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } catch (Exception ex) { var message = ex.Message; } return(newFloor); }
public FloorDescBuilder(FloorType floorType) { _floorType = floorType; }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { #region Get access to the current document and aplication. UIApplication uiapp = commandData.Application; UIDocument uidoc = commandData.Application.ActiveUIDocument; Autodesk.Revit.ApplicationServices.Application app = commandData.Application.Application; Autodesk.Revit.DB.Document doc = commandData.Application.ActiveUIDocument.Document; #endregion // Try to create a project parameter. try { Category walls = doc.Settings.Categories.get_Item(BuiltInCategory.OST_Walls); Category floors = doc.Settings.Categories.get_Item(BuiltInCategory.OST_Floors); Category ceilings = doc.Settings.Categories.get_Item(BuiltInCategory.OST_Ceilings); Category roofs = doc.Settings.Categories.get_Item(BuiltInCategory.OST_Roofs); CategorySet catSet = new CategorySet(); catSet.Insert(walls); catSet.Insert(floors); catSet.Insert(ceilings); catSet.Insert(roofs); using (Transaction t = new Transaction(doc, "Add project parameter")) { t.Start(); CreateProjectParam(app, "LinkedTag", ParameterType.Integer, false, catSet, BuiltInParameterGroup.INVALID, true); if (t.Commit() == TransactionStatus.Committed) { } else { t.RollBack(); } } } catch (Exception ex) { TaskDialog.Show("Error", ex.Message); } if (Schema.Lookup(new Guid("2B195204-1C04-4538-8881-AD22FA697B41")) == null) { BuildNewSchema(doc); } // Retrieving a specific family from the database. try { // Create a new FilteredElementCollector FilteredElementCollector collector = new FilteredElementCollector(doc); // Define and apply one or more filters to it. ElementCategoryFilter categoryFilter = new ElementCategoryFilter(BuiltInCategory.OST_GenericAnnotation); ParameterValueProvider pvp_1 = new ParameterValueProvider(new ElementId(BuiltInParameter.ALL_MODEL_FAMILY_NAME)); ParameterValueProvider pvp_2 = new ParameterValueProvider(new ElementId(BuiltInParameter.ALL_MODEL_TYPE_NAME)); FilterStringEquals equals = new FilterStringEquals(); string familyName = "Z-M2-MultilayerMaterialTag-LOD1"; string typeName = "2.5mm"; FilterRule fRule_1 = new FilterStringRule(pvp_1, equals, familyName, false); FilterRule fRule_2 = new FilterStringRule(pvp_2, equals, typeName, false); IList <FilterRule> fRules = new List <FilterRule> { fRule_1, fRule_2 }; ElementParameterFilter filters = new ElementParameterFilter(fRules); // Collect the familySymbol's id ICollection <ElementId> id = collector.WherePasses(categoryFilter).WherePasses(filters).ToElementIds(); if (id.Count == 0) { message = "No FamilyType has been detected."; return(Result.Failed); } AnnotationSymbolType materialTag = doc.GetElement(id.First()) as AnnotationSymbolType; if (CreateWorkPlane(doc) != true) { return(Result.Failed); } // Prompt the user to select select the element to be tagged. Reference pickedRef = null; pickedRef = uidoc.Selection.PickObject(ObjectType.Element, new MultilayerStrFilter(), "Please select a multilayer element."); Element selectedElm = doc.GetElement(pickedRef.ElementId); XYZ point = uidoc.Selection.PickPoint("Please pick a point to place the family"); StringBuilder strBld = new StringBuilder(); int rows; int shelfLength; switch (selectedElm.Category.Name) { case "Walls": Wall wl = selectedElm as Wall; WallType wlType = wl.WallType; CompoundStructure cmpStr_wl = wlType.GetCompoundStructure(); strBld = LayersAsString(cmpStr_wl, doc, out shelfLength); rows = wlType.GetCompoundStructure().LayerCount; break; case "Floors": Floor fl = selectedElm as Floor; FloorType flType = fl.FloorType; CompoundStructure cmpStr_fl = flType.GetCompoundStructure(); strBld = LayersAsString(cmpStr_fl, doc, out shelfLength); rows = flType.GetCompoundStructure().LayerCount; break; case "Ceilings": Ceiling cl = selectedElm as Ceiling; CeilingType clType = doc.GetElement(cl.GetTypeId()) as CeilingType; CompoundStructure cmpStr_cl = clType.GetCompoundStructure(); strBld = LayersAsString(cmpStr_cl, doc, out shelfLength); rows = clType.GetCompoundStructure().LayerCount; break; case "Roofs": RoofBase rf = selectedElm as RoofBase; RoofType rfType = rf.RoofType; CompoundStructure cmpStr_rf = rfType.GetCompoundStructure(); strBld = LayersAsString(cmpStr_rf, doc, out shelfLength); rows = rfType.GetCompoundStructure().LayerCount; break; default: TaskDialog.Show("Warning!", "This category is not supported."); return(Result.Failed); } using (Transaction trn_1 = new Transaction(doc, "Materials Mark")) { FamilyInstance createdElm = null; if (trn_1.Start() == TransactionStatus.Started) { createdElm = doc.Create.NewFamilyInstance(point, materialTag, doc.ActiveView); selectedElm.LookupParameter("LinkedTag").Set(createdElm.Id.IntegerValue); if (trn_1.Commit() == TransactionStatus.Committed) { Transaction trn_2 = new Transaction(doc, "Set parameters"); try { trn_2.Start(); createdElm.LookupParameter("multilineText").Set(strBld.ToString()); createdElm.LookupParameter("# of Rows").Set(rows); createdElm.LookupParameter("Shelf Length").Set(ToFt(shelfLength)); XYZ vec; if (selectedElm.Category.Name != "Walls") { vec = new XYZ(0, 0, createdElm.LookupParameter("Arrow Length").AsDouble() * doc.ActiveView.Scale); createdElm.LookupParameter("Down Arrow Direction").Set(1); } else { vec = new XYZ(-createdElm.LookupParameter("Arrow Length").AsDouble() * doc.ActiveView.Scale, 0, 0); createdElm.LookupParameter("Down Arrow Direction").Set(0); } ElementTransformUtils.MoveElement(doc, createdElm.Id, vec); trn_2.Commit(); AddElementToSchema(Schema.Lookup(new Guid("2B195204-1C04-4538-8881-AD22FA697B41")), createdElm, selectedElm.Id); } finally { if (trn_2 != null) { trn_2.Dispose(); } } } else { trn_1.RollBack(); return(Result.Failed); } } else { trn_1.RollBack(); return(Result.Failed); } return(Result.Succeeded); } } catch (Exception ex) { message = ex.Message; return(Result.Failed); } }
public Floor(Pos2D pos, FloorType floorType) : base(pos) { FloorType = floorType; }
// Constructor public Floor(Cell cell, FloorType floorType) : base(cell) { this.type = floorType; }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { string paramNameGroupConstr = "INGD_Группа конструкции"; string floorNumberParamName = "INGD_Номер этажа"; int floorTextPosition = 0; Module.assembly = System.Reflection.Assembly.GetExecutingAssembly().Location; Print(Module.assembly, KPLN_Loader.Preferences.MessageType.Regular); string markParamName = "INGD_Марка"; string widthParamName = "INGD_Ширина"; string lengthParamName = "INGD_Длина"; string heigthParamName = "INGD_Высота"; Dictionary <string, string> marksBase = new Dictionary <string, string>(); string txtFile = SettingsUtils.CheckOrCreateSettings(); Print(txtFile, KPLN_Loader.Preferences.MessageType.Regular); if (!System.IO.File.Exists(txtFile)) { message = "Не найден файл " + txtFile; return(Result.Failed); } string[] data = System.IO.File.ReadAllLines(txtFile); foreach (string s in data) { string[] line = s.Split(';'); marksBase.Add(line[0], line[1]); } Document doc = commandData.Application.ActiveUIDocument.Document; List <Element> allElems = new List <Element>(); List <Wall> walls = new FilteredElementCollector(doc) .OfClass(typeof(Wall)) .Cast <Wall>() .ToList(); List <Floor> floors = new FilteredElementCollector(doc) .OfClass(typeof(Floor)) .Cast <Floor>() .ToList(); allElems.AddRange(walls); allElems.AddRange(floors); allElems.AddRange(new FilteredElementCollector(doc).OfClass(typeof(Autodesk.Revit.DB.Architecture.Stairs))); allElems.AddRange(new FilteredElementCollector(doc).OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_StructuralColumns)); allElems.AddRange(new FilteredElementCollector(doc).OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_StructuralFraming)); allElems.AddRange(new FilteredElementCollector(doc).OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_StructuralFoundation)); allElems.AddRange(new FilteredElementCollector(doc).OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_Floors)); allElems.AddRange(new FilteredElementCollector(doc).OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_Walls)); List <FamilyInstance> genericModels = new FilteredElementCollector(doc) .OfClass(typeof(FamilyInstance)) .OfCategory(BuiltInCategory.OST_GenericModel) .Cast <FamilyInstance>() .Where(i => !i.Symbol.FamilyName.StartsWith("22")) .ToList(); allElems.AddRange(genericModels); List <FamilyInstance> windows = new FilteredElementCollector(doc) .OfClass(typeof(FamilyInstance)) .Cast <FamilyInstance>() .Where(i => i.Symbol.FamilyName.StartsWith("23")) .ToList(); allElems.AddRange(windows); List <RoofBase> roofs = new FilteredElementCollector(doc) .OfClass(typeof(RoofBase)) .Cast <RoofBase>() .ToList(); int count = 0; using (Transaction t = new Transaction(doc)) { t.Start("INGD Параметризация"); foreach (Element elem in allElems) { Parameter markParam = elem.get_Parameter(BuiltInParameter.ALL_MODEL_MARK); if (markParam == null) { continue; } if (markParam.HasValue) { string mark = markParam.AsString(); Parameter ingdMarkParam = elem.LookupParameter(markParamName); if (ingdMarkParam != null) { ingdMarkParam.Set(mark); } string[] splitmark = mark.Split('-'); if (splitmark.Length > 1) { string markPrefix = splitmark[0]; if (!marksBase.ContainsKey(markPrefix)) { message = "Недопустимый префикс марки " + markPrefix + " у элемента id " + elem.Id.IntegerValue.ToString(); return(Result.Failed); } string group = marksBase[markPrefix]; Parameter groupParam = elem.LookupParameter(paramNameGroupConstr); if (groupParam != null) { groupParam.Set(group); } } } //заполняю номер этажа Level baseLevel = LevelUtils.GetLevelOfElement(elem, doc); if (baseLevel != null) { string floorNumber = LevelUtils.GetFloorNumberByLevel(baseLevel, floorTextPosition, ' '); Parameter ingdFloor = elem.LookupParameter(floorNumberParamName); if (ingdFloor == null) { continue; } ingdFloor.Set(floorNumber); } count++; } foreach (RoofBase roof in roofs) { string group = "Бетонная подготовка"; Parameter groupParam = roof.LookupParameter(paramNameGroupConstr); if (groupParam != null) { groupParam.Set(group); } } foreach (Wall w in walls) { Level baseLevel = doc.GetElement(w.LevelId) as Level; string floorNumber = LevelUtils.GetFloorNumberByLevel(baseLevel, floorTextPosition, ' '); Parameter ingdFloor = w.LookupParameter(floorNumberParamName); if (ingdFloor == null) { continue; } ingdFloor.Set(floorNumber); double width = w.Width; Parameter ingdWidth = w.LookupParameter(widthParamName); if (ingdWidth == null) { continue; } ingdWidth.Set(width); double length = w.get_Parameter(BuiltInParameter.CURVE_ELEM_LENGTH).AsDouble(); Parameter ingdLength = w.LookupParameter(lengthParamName); if (ingdLength == null) { continue; } ingdLength.Set(length); List <Solid> solids = GeometryUtils.GetSolidsFromElement(w); XYZ[] maxminZ = GeometryUtils.GetMaxMinHeightPoints(solids); double heigth = maxminZ[0].Z - maxminZ[1].Z; Parameter ingdHeigth = w.LookupParameter(heigthParamName); if (ingdHeigth == null) { continue; } ingdHeigth.Set(heigth); } foreach (Floor f in floors) { Level baseLevel = doc.GetElement(f.LevelId) as Level; string floorNumber = LevelUtils.GetFloorNumberByLevel(baseLevel, floorTextPosition, ' '); Parameter ingdFloor = f.LookupParameter(floorNumberParamName); if (ingdFloor == null) { continue; } ingdFloor.Set(floorNumber); FloorType ft = f.FloorType; double heigth = ft.get_Parameter(BuiltInParameter.FLOOR_ATTR_DEFAULT_THICKNESS_PARAM).AsDouble(); Parameter ingdHeigth = f.LookupParameter(heigthParamName); if (ingdHeigth == null) { continue; } ingdHeigth.Set(heigth); } t.Commit(); } TaskDialog.Show("Отчет", "Обработано элементов: " + count.ToString()); return(Result.Succeeded); }
public bool CanEnterFloor(FloorType floor) { return(this.AccessibleFloors .Any(f => f == floor)); }
public void makeType(RoomType newRoomType) { DoorFrame thisframe = DoorFrame.none; DoorLock thislock = DoorLock.open; if(newRoomType == RoomType.boss) { type = RoomType.boss; floor = FloorType.boss; thisframe = DoorFrame.bones; thislock = DoorLock.combat; } if (newRoomType == RoomType.hidden) { type = RoomType.hidden; floor = FloorType.secret; thisframe = DoorFrame.none; thislock = DoorLock.bomb; } if (newRoomType == RoomType.normal) { type = RoomType.normal; floor = FloorType.normal; thisframe = DoorFrame.wood; } if (newRoomType == RoomType.shop) { type = RoomType.shop; floor = FloorType.normal; thisframe = DoorFrame.wood; thislock = DoorLock.key; } if (newRoomType == RoomType.treasure) { type = RoomType.treasure; floor = FloorType.normal; thisframe = DoorFrame.gold; thislock = DoorLock.open; } if (adjacentNorth) { frameNorth = thisframe; lockNorth = thislock; } if (adjacentSouth) { frameSouth = thisframe; lockSouth = thislock; } if (adjacentEast) { frameEast = thisframe; lockEast = thislock; } if (adjacentWest) { frameWest = thisframe; lockWest = thislock; } }
/// <summary> /// MouseDown event handler - gets position for map editing /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MouseDownHandler( object sender, MouseEventArgs e ) { if( Core.hero == null | Core.grid == null ) return; // get Core.grid[] floortile int x = e.X / Core.tileSize + Core.hero.x - Core.displayDistX; int y = e.Y / Core.tileSize + Core.hero.y - Core.displayDistY; if( x>0 && y>0 && x<Core.grid.GetLength(0)-1 && y<Core.grid.GetLength(1)-1 ) { if( e.Button == MouseButtons.Left ) { if( rdoWalls.Checked ) { Core.grid[x, y].type = (Core.grid[x, y].type==FloorType.Wall ? FloorType.Floor : FloorType.Wall); } else if( rdoDoors.Checked ) { Core.grid[x, y].type = (Core.grid[x, y].type==FloorType.DoorClosed ? FloorType.Wall : FloorType.DoorClosed); } else { Core.grid[x, y].type = (Core.grid[x, y].type==FloorType.Floor ? FloorType.Trap : FloorType.Floor); } floorPainting = Core.grid[x, y].type; } else if( e.Button == MouseButtons.Right ) { Core.grid[x, y].type = FloorType.Floor; } Refresh(); } }
public void AddFloor(FloorType floorType) { _floorTypes.Add(floorType); }
/// <summary> /// This method is called after the scene was created. /// Be carefull: This method run's in 3D-Engines update thread. /// </summary> /// <param name="manipulator">The manipulator.</param> private void OnBodyScene_Initialize(SceneManipulator manipulator) { SceneLayer bgLayer = manipulator.AddLayer("BACKGROUND"); manipulator.SetLayerOrderID(bgLayer, 0); manipulator.SetLayerOrderID(Scene.DEFAULT_LAYER_NAME, 1); ResourceLink sourceWallTexture = new Uri( "/SeeingSharp.ModelViewer;component/Resources/Textures/Background.png", UriKind.Relative); var resBackgroundTexture = manipulator.AddTexture(sourceWallTexture); manipulator.Add(new TexturePainter(resBackgroundTexture), bgLayer.Name); FloorType floorType = new FloorType(new Vector2(3f, 3f), 0.1f); floorType.SetTilemap(40, 40); floorType.DefaultFloorMaterial = manipulator.AddSimpleColoredMaterial(new Uri( "/SeeingSharp.ModelViewer;component/Resources/Textures/Floor.png", UriKind.Relative)); var resGeometry = manipulator.AddResource<GeometryResource>(() => new GeometryResource(floorType)); GenericObject floorObject = manipulator.AddGeneric(resGeometry); floorObject.IsPickingTestVisible = false; }
/// <summary> /// Constructor /// </summary> /// <param name="t"></param> /// <param name="xV"></param> /// <param name="yV"></param> public FloorTile(int xV, int yV, FloorType t) { type = t; x = xV; y = yV; }
public void SetCompartmentFloor(FloorType type, Compartment c) { Vec2i start = ChunkIToTileI(aabb.bl); Vec2i end = ChunkIToTileI(aabb.tr); for (int i = start.y; i < end.y; i++) { for (int j = start.x; j < end.x; j++) { Vec2i tileI = new Vec2i(j, i); VesselTile tile; if ((tile = TryGetTile(tileI)) != null) { bool modified = false; if (tile.c0 != null && tile.c0.Instance == c) { tile.floor0 = type; modified = true; } if (tile.c1 != null && tile.c1.Instance == c) { tile.floor1 = type; modified |= true; } if (modified) { AddModifiedChunk((ServerVC)chunks.Get(TileToChunkI(tileI))); } } } } }
/// <summary> /// get all the required information of selected elements and store them in a data table /// </summary> /// <param name="selectedElements"> /// all selected elements in Revit main program /// </param> /// <returns> /// a data table which store all the required information /// </returns> private DataTable StoreInformationInDataTable(ElementSet selectedElements) { DataTable informationTable = CreatDataTable(); foreach (Element element in selectedElements) { // Get AnalyticalElement analyticalModel = null; Document document = element.Document; AnalyticalToPhysicalAssociationManager assocManager = AnalyticalToPhysicalAssociationManager.GetAnalyticalToPhysicalAssociationManager(document); if (assocManager != null) { ElementId associatedElementId = assocManager.GetAssociatedElementId(element.Id); if (associatedElementId != ElementId.InvalidElementId) { Element associatedElement = document.GetElement(associatedElementId); if (associatedElement != null && associatedElement is AnalyticalElement) { analyticalModel = associatedElement as AnalyticalElement; } } } if (null == analyticalModel) // skip no AnalyticalModel element { continue; } DataRow newRow = informationTable.NewRow(); string idValue = element.Id.ToString(); // store element Id value string typeName = ""; // store element type name string[] supportInformation = GetSupportInformation(analyticalModel); // store support information // get element type information switch (element.GetType().Name) { case "WallFoundation": WallFoundation wallFound = element as WallFoundation; ElementType wallFootSymbol = m_revit.Application.ActiveUIDocument.Document.GetElement(wallFound.GetTypeId()) as ElementType;// get element Type typeName = wallFootSymbol.Category.Name + ": " + wallFootSymbol.Name; break; case "FamilyInstance": FamilyInstance familyInstance = element as FamilyInstance; FamilySymbol symbol = m_revit.Application.ActiveUIDocument.Document.GetElement(familyInstance.GetTypeId()) as FamilySymbol; typeName = symbol.Family.Name + ": " + symbol.Name; break; case "Floor": Floor slab = element as Floor; FloorType slabType = m_revit.Application.ActiveUIDocument.Document.GetElement(slab.GetTypeId()) as FloorType; // get element type typeName = slabType.Category.Name + ": " + slabType.Name; break; case "Wall": Wall wall = element as Wall; WallType wallType = m_revit.Application.ActiveUIDocument.Document.GetElement(wall.GetTypeId()) as WallType; // get element type typeName = wallType.Kind.ToString() + ": " + wallType.Name; break; default: break; } // set the relative information of current element into the table. newRow["Id"] = idValue; newRow["Element Type"] = typeName; newRow["Support Type"] = supportInformation[0]; newRow["Remark"] = supportInformation[1]; informationTable.Rows.Add(newRow); } return(informationTable); }
public Floor CreateFloor(FloorType floorType) { return CreateFloor(floorType.ToString()); }
private FloorType CreateFloorType(Room room, string typeName) { FloorType newFloorType = null; using (var trans = new Transaction(m_doc)) { trans.Start("Create Floor Type"); try { if (string.IsNullOrEmpty(typeName)) { typeName = "Floor Finish"; if (!room.Document.IsLinked) { var param = room.get_Parameter(BuiltInParameter.ROOM_FINISH_FLOOR); param.Set(typeName); } } var collector = new FilteredElementCollector(m_doc); var classFilter = new ElementClassFilter(typeof(FloorType)); collector.WherePasses(classFilter); var floorTypes = collector.Cast <FloorType>().ToList <FloorType>(); var query = from floorType in floorTypes where floorType.Name == typeName select floorType; var existingFloorTypes = query.Cast <FloorType>().ToList(); if (existingFloorTypes.Count > 0) { newFloorType = existingFloorTypes[0]; } else { if (floorTypes.Count > 0) { foreach (var floorType in floorTypes) { if (floorType.IsFoundationSlab) { continue; } newFloorType = floorType.Duplicate(typeName) as FloorType; break; } } if (null != newFloorType) { var compoundStructure = newFloorType.GetCompoundStructure(); var layerThickness = 0.020833; var layerIndex = compoundStructure.GetFirstCoreLayerIndex(); compoundStructure.SetLayerFunction(layerIndex, MaterialFunctionAssignment.Finish1); compoundStructure.SetLayerWidth(layerIndex, layerThickness); for (var i = compoundStructure.LayerCount - 1; i > -1; i--) { if (i == layerIndex) { continue; } else { compoundStructure.DeleteLayer(i); } } compoundStructure.StructuralMaterialIndex = 0; //only single layer is remained newFloorType.SetCompoundStructure(compoundStructure); } } trans.Commit(); } catch (Exception ex) { MessageBox.Show("Cannot create a floor type.\n" + ex.Message, "Create Floor Type", MessageBoxButtons.OK, MessageBoxIcon.Warning); trans.RollBack(); } } return(newFloorType); }
public static bool AddFloorToBuilding(int buildingId, FloorType _type, int Id) { switch (_type) { case FloorType.House: #region House var house = db_Houses.GetHouse(Id); if (house != null) { if (currentBuildings[buildingId] == null) { return(false); } currentBuildings[buildingId].Floors.Add(new Models.Floor { FloorNumber = currentBuildings[buildingId].Floors.Count > 0 ? currentBuildings[buildingId].Floors.LastOrDefault().FloorNumber + 1 : 1, Type = _type, TypedObjectId = house.HouseId }); house.EntrancePosition = currentBuildings[buildingId].Position; house.EntranceDimension = currentBuildings[buildingId].Dimension; house.IsInBuilding = true; SaveChanges(); return(db_Houses.UpdateHouse(house)); } else { return(false); } #endregion case FloorType.Business: var business = db_Businesses.GetById(Id); if (business != null) { if (currentBuildings[buildingId] == null) { return(false); } currentBuildings[buildingId].Floors.Add(new Floor { FloorNumber = currentBuildings[buildingId].Floors.Count > 0 ? currentBuildings[buildingId].Floors.LastOrDefault().FloorNumber + 1 : 1, Type = _type, TypedObjectId = business.BusinessId }); business.BuildingId = buildingId; db_Businesses.SaveChanges(); db_Buildings.SaveChanges(); } else { return(false); } break; case FloorType.Warehouse: break; default: break; } return(false); }
public Elevator(int capacity) { _semaphore = new Semaphore(capacity, capacity); CurrentFloor = FloorType.GroundFloor; }
public Room(VecInt2 doorPos, FloorType type, int targetSize) { this.doorPos = doorPos; this.type = type; this.targetSize = targetSize; }
Stream(ArrayList data, FloorType floorType) { data.Add(new Snoop.Data.ClassSeparator(typeof(FloorType))); data.Add(new Snoop.Data.Bool("Is foundation slab", floorType.IsFoundationSlab)); }
public FloorsCFBRRequest(UIApplication uiApp, String text) { MainUI uiForm = BARevitTools.Application.thisApp.newMainUi; UIDocument uidoc = uiApp.ActiveUIDocument; FloorType selectedFloorType = null; //Get the name of the floor type selected in the MainUI string selectedFloorTypeName = uiForm.floorsCFBRSelectFloorTypeComboBox.Text.ToString(); //Create lists to use locally from the rooms selected from the MainUI, the collection of floor types, and to store newly created floors. List <Room> roomElements = uiForm.floorsCFBRRoomsList; List <FloorType> floorTypes = RVTGetElementsByCollection.DocumentFloorTypes(uiApp); List <Floor> newFloors = new List <Floor>(); //First, make sure the user is running the tool from a plan view if (uidoc.ActiveView.GetType().ToString() != "Autodesk.Revit.DB.ViewPlan") { MessageBox.Show("Please run from a plan view"); } else { //If they are int a plan view, start a transaction Transaction t1 = new Transaction(uidoc.Document, "CreateFloorsByRoom"); t1.Start(); //Cycle through the floor types in the project until the one with a name matching the one selected in the MainUI is found foreach (FloorType floorType in floorTypes) { if (floorType.Name.ToString() == selectedFloorTypeName) { selectedFloorType = floorType; break; } else { continue; } } try { //Generate new GeometryOptions to allow evaluation of room volumes that may not be visible. Options geomOptions = new Options(); geomOptions.IncludeNonVisibleObjects = true; //For each room that was selected with the MainUI... foreach (Room room in roomElements) { //Create a new iterable list for the CurveLoops reprsenting the edges of the room boundary IList <CurveLoop> faceCurveLoops = null; //Get the level associated with the room for floor creation Level roomLevel = room.Level; //Get the geometry of the room GeometryElement roomGeomElements = room.get_Geometry(geomOptions); Solid roomSolid = null; //Cycle through the geometry associated with the room until the solid form is found foreach (GeometryObject geom in roomGeomElements) { if (geom.GetType().ToString() == "Autodesk.Revit.DB.Solid") { roomSolid = geom as Solid; break; } } //If the solid form of the room was found, continue if (roomSolid != null) { //Get the faces of the solid FaceArray solidFaces = roomSolid.Faces; foreach (PlanarFace solidFace in solidFaces) { //Check the direction of the face normal XYZ faceNormal = solidFace.FaceNormal; //If the face normal faced down, it is a bottom face. Because the room cannot be split into multiple portions, //and a split level room is unlikely, it is safe to select the first downward face. if (faceNormal.Z == -1) { //Get the edges of the face as curve loops faceCurveLoops = solidFace.GetEdgesAsCurveLoops(); break; } } } //If the face's curve loops were retrieved, continue if (faceCurveLoops.Count != 0) { try { //Make a new CurveArray from the loops CurveArray curveArray = new CurveArray(); foreach (CurveLoop cloop in faceCurveLoops) { CurveLoopIterator cLoopIter = cloop.GetCurveLoopIterator(); while (cLoopIter.MoveNext()) { curveArray.Append(cLoopIter.Current); } } //The new floow will require the CurveArray, FloorType, Level, and boolean for making it structural (false for this tool's purpose) Floor newFloor = uidoc.Document.Create.NewFloor(curveArray, selectedFloorType, roomLevel, false); //After making the floor, add it to the list of new floors created newFloors.Add(newFloor); } catch { //If the room had more than one edge loop, such as another room was enveloped by the selected room, the operation will fail because the API only allows one loop MessageBox.Show(string.Format("Floor could not be made for {0}, which is likely due to the room having more than one boundary loop. The Revit API only allows for one contiuous loop.", room.Number.ToString())); } } } t1.Commit(); //Provide some feedback to the MainUI uiForm.floorsCFBRDoneLabel.Visible = true; uiForm.floorsCFBRRoomsList = new List <Room>(); } catch { t1.RollBack(); } //If the user wanted to offset the floors by their thickness, this will offset the newly made and collected floors if (uiForm.floorsCFBROffsetFinishFloorCheckBox.Checked) { Transaction t2 = new Transaction(uidoc.Document, "ElevateFloors"); t2.Start(); try { //Cycle through the list of new floors foreach (Floor floor in newFloors) { //Make a new set of geometry options Options geomOptions = new Options(); geomOptions.IncludeNonVisibleObjects = true; //Get the floor geometry and the bounding box of the geometry GeometryElement floorGeometry = floor.get_Geometry(geomOptions); BoundingBoxXYZ floorBBox = floorGeometry.GetBoundingBox(); //Use the minimum and maximum Z coordinates from the bounding box to determine the floor thickness because that's not natively supported in the Revit API double bBoxMinZ = floorBBox.Min.Z; double bBoxMaxZ = floorBBox.Max.Z; double floorThickness = bBoxMaxZ - bBoxMinZ; //Move the floor up with a translation in the Z axis by the thickness value XYZ translation = new XYZ(0, 0, floorThickness); ElementTransformUtils.MoveElement(uidoc.Document, floor.Id, translation); } t2.Commit(); } catch { t2.RollBack(); } } } }
public Floor(FloorType type) { this.type = type; }
/// <summary> /// 創建樓板 /// </summary> /// <param name="targetLevel"></param> /// <param name="NewBeamGroup"></param> /// <param name="floor_type"></param> private void CreateFloor(Level targetLevel, List <List <LINE> > NewBeamGroup, FloorType floor_type) { List <CurveArray> floorCurves = new List <CurveArray>(); foreach (List <LINE> Beams in NewBeamGroup) { try { List <LINE> newBeam_ = AdjustCreatedFloorEdge(Beams); List <LINE> newBeam_2 = AdjustCreatedFloorEdge(newBeam_); List <LINE> newBeam_3 = new List <LINE>(); foreach (LINE item in newBeam_2) { if (item.GetLength() > 0.01) { newBeam_3.Add(item); } } List <LINE> newBeam = new List <LINE>(); newBeam_3.Add(newBeam_3[0]); for (int i = 0; i < newBeam_3.Count - 1; i++) { if (IsSamePoint(newBeam_3[i].GetStartPoint(), newBeam_3[i + 1].GetStartPoint()) && IsSamePoint(newBeam_3[i].GetEndPoint(), newBeam_3[i + 1].GetEndPoint())) { } else if (IsSamePoint(newBeam_3[i].GetStartPoint(), newBeam_3[i + 1].GetEndPoint()) && IsSamePoint(newBeam_3[i].GetEndPoint(), newBeam_3[i + 1].GetStartPoint())) { } else { newBeam.Add(newBeam_3[i]); } } // SaveTmp(new List<List<LINE>> { newBeam }); CurveArray curveArray = new CurveArray(); //floorCurves.Add(curveArray); foreach (LINE beam in newBeam) { curveArray.Append(Line.CreateBound(beam.GetStartPoint(), beam.GetEndPoint())); } using (Transaction trans = new Transaction(this.revitDoc)) { FailureHandlingOptions failureHandlingOptions = trans.GetFailureHandlingOptions(); FailureHandler failureHandler = new FailureHandler(); failureHandlingOptions.SetFailuresPreprocessor(failureHandler); failureHandlingOptions.SetClearAfterRollback(false); trans.SetFailureHandlingOptions(failureHandlingOptions); trans.Start("Create Floors"); this.revitDoc.Create.NewFloor(curveArray, floor_type, targetLevel, false); trans.Commit(); } } catch (Exception) { } } }
public void Init(FloorType floorType) { FloorType = floorType; }
void FloorFinish(UIDocument UIDoc, Transaction tx) { Document _doc = UIDoc.Document; tx.Start(Tools.LangResMan.GetString("floorFinishes_transactionName", Tools.Cult)); //Load the selection form FloorsFinishesControl userControl = new FloorsFinishesControl(UIDoc); userControl.InitializeComponent(); if (userControl.ShowDialog() == true) { //Select floor types FloorType flType = userControl.SelectedFloorType; //Select Rooms in model IEnumerable <Room> ModelRooms = userControl.SelectedRooms; foreach (Room tempRoom in ModelRooms) { if (tempRoom != null) { if (tempRoom.UnboundedHeight != 0) { //Get all finish properties double height; if (userControl.RoomParameter == null) { height = userControl.FloorHeight; } else { Parameter tempRoomParam = tempRoom.get_Parameter(userControl.RoomParameter.Definition); height = tempRoomParam.AsDouble(); } string name = tempRoom.Name; SpatialElementBoundaryOptions opt = new SpatialElementBoundaryOptions(); IList <IList <Autodesk.Revit.DB.BoundarySegment> > boundarySegments = tempRoom.GetBoundarySegments(opt); CurveArray crvArray = new CurveArray(); if (boundarySegments.Count != 0) { foreach (Autodesk.Revit.DB.BoundarySegment boundSeg in boundarySegments.First()) { crvArray.Append(boundSeg.GetCurve()); } //Retrive room info Level rmLevel = _doc.GetElement(tempRoom.LevelId) as Level; Parameter param = tempRoom.get_Parameter(BuiltInParameter.ROOM_HEIGHT); double rmHeight = param.AsDouble(); if (crvArray.Size != 0) { System.Threading.Thread.Sleep(1000); Floor floor = _doc.Create.NewFloor(crvArray, flType, rmLevel, false); //Change some param on the floor param = floor.get_Parameter(BuiltInParameter.FLOOR_HEIGHTABOVELEVEL_PARAM); param.Set(height); } } } } } tx.Commit(); } else { tx.RollBack(); } }
public void checkFooting() { standing = FloorType.None; isGrounded = false; }
public void Init(FloorType type) { FloorName = type.ToString(); Image.sprite = sprites.FirstOrDefault(x => x.FloorType == type).Sprite; }
public static bool IsDoor(FloorType type) { return(type == FloorType.DoorLeft || type == FloorType.DoorRight || type == FloorType.DoorUp || type == FloorType.DoorDown); }
public Floor(int _size, FloorType _floorType) { size = _size; floorType = _floorType; rooms = new List<Room>(); }
public BlueprintNode(FloorType type, int sizeMin, int sizeMax, int edgeLenghtMin) { this.type = type; this.sizeMin = sizeMin; this.sizeMax = sizeMax; this.edgeLenghtMin = edgeLenghtMin; }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIDocument uidoc = commandData.Application.ActiveUIDocument; Autodesk.Revit.DB.Document doc = uidoc.Document; Transaction trans = new Transaction(doc); trans.Start("交易開始"); //訂定土體範圍 List <XYZ> topxyz = new List <XYZ>(); XYZ t1 = new XYZ(-200, -200, 0); XYZ t2 = new XYZ(200, -200, 0); XYZ t3 = new XYZ(200, 200, 0); XYZ t4 = new XYZ(-200, 200, 0); topxyz.Add(t1 * 1000 / 304.8); topxyz.Add(t2 * 1000 / 304.8); topxyz.Add(t3 * 1000 / 304.8); topxyz.Add(t4 * 1000 / 304.8); TopographySurface.Create(doc, topxyz); //開挖深度所需參數 FilteredElementCollector collector = new FilteredElementCollector(doc); collector.OfClass(typeof(BuildingPadType)); BuildingPadType bdtp = collector.FirstElement() as BuildingPadType; csv_read csv = new csv_read(); csv.Main(); //開挖各階之深度輸入 List <double> height = new List <double>(); foreach (var data in csv.excaLevel) { height.Add(data.Item2 * -1); } //建立開挖階數 Level[] levlist = new Level[height.Count()]; for (int i = 0; i != height.Count(); i++) { levlist[i] = Level.Create(doc, height[i] * 1000 / 304.8); levlist[i].Name = "開挖階數" + (i + 1).ToString(); } double wallLength = csv.Wall_length; Level DW_level = Level.Create(doc, wallLength * -1 * 1000 / 304.8); //建立回築樓層 Level[] re_levlist = new Level[csv.back.Count()]; for (int i = 0; i != csv.back.Count(); i++) { re_levlist[i] = Level.Create(doc, (csv.back[i].Item2 * -1 + csv.back[i].Item3 / (2)) * 1000 / 304.8); re_levlist[i].Name = (csv.back[i].Item1).ToString(); } Level[] all_level_list = new Level[levlist.Count() + re_levlist.Count()]; all_level_list = levlist.Concat(re_levlist).ToArray(); //訂定開挖範圍 IList <CurveLoop> profileloops = new List <CurveLoop>(); IList <Curve> wall_profileloops = new List <Curve>(); //須回到原點 XYZ[] points = new XYZ[csv.excaRange.Count()]; for (int i = 0; i != csv.excaRange.Count(); i++) { points[i] = new XYZ(csv.excaRange[i].Item1, csv.excaRange[i].Item2, 0) * 1000 / 304.8; } CurveLoop profileloop = new CurveLoop(); for (int i = 0; i < points.Count() - 1; i++) { Line line = Line.CreateBound(points[i], points[i + 1]); wall_profileloops.Add(line); profileloop.Append(line); } profileloops.Add(profileloop); Level levdeep = null; //建立開挖深度 ICollection <Level> level_familyinstance = new FilteredElementCollector(doc).OfClass(typeof(Level)).Cast <Level>().ToList(); foreach (Level lev in level_familyinstance) { if (lev.Name == levlist[levlist.Count() - 1].Name) { BuildingPad b = BuildingPad.Create(doc, bdtp.Id, lev.Id, profileloops); levdeep = lev; } } //建立連續壁 IList <Curve> inner_wall_curves = new List <Curve>(); double wall_W = csv.Wall_width * 1000; //連續壁厚度 List <Wall> inner_wall = new List <Wall>(); ICollection <WallType> walltype_familyinstance = new FilteredElementCollector(doc).OfClass(typeof(WallType)).Cast <WallType>().ToList(); foreach (WallType walltype in walltype_familyinstance) { if (walltype.Name == "連續壁") { for (int i = 0; i < points.Count <XYZ>() - 1; i++) { Curve c = wall_profileloops[i].CreateOffset(wall_W / 2 / 304.8, new XYZ(0, 0, -1)); //偏移連續壁厚度1/2的距離,做為建置參考線 Wall w = Wall.Create(doc, c, walltype.Id, DW_level.Id, wallLength * 1000 / 304.8, 0, false, false); w.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS).Set("連續壁"); inner_wall.Add(w); } } } trans.Commit(); //取得連續壁內座標點 XYZ[] innerwall_points = new XYZ[points.Count <XYZ>()]; XYZ[] for_check_innerwall_points = new XYZ[points.Count <XYZ>()]; //計算支撐中間樁之擺放界線 for (int i = 0; i < (inner_wall.Count <Wall>()); i++) { //inner XYZ wall_curve_point = (inner_wall[i].Location as LocationCurve).Curve.Tessellate()[0]; wall_curve_point = new XYZ(wall_curve_point.X, wall_curve_point.Y, 0); innerwall_points[i] = points[i] - (points[i] - wall_curve_point) * 2; for_check_innerwall_points[i] = points[i] - (points[i] - wall_curve_point) * 1.4; //計算支撐中間樁之擺放界線 } innerwall_points[points.Count <XYZ>() - 1] = innerwall_points[0]; for_check_innerwall_points[points.Count <XYZ>() - 1] = for_check_innerwall_points[0]; //取得側牆profile IList <CurveLoop> bdtpCurve = new List <CurveLoop>(); IList <Curve> side_wall_profileloops = new List <Curve>(); CurveLoop bdtploop = new CurveLoop(); for (int i = 0; i < innerwall_points.Count() - 1; i++) { Line line = Line.CreateBound(innerwall_points[i], innerwall_points[i + 1]); side_wall_profileloops.Add(line); bdtploop.Append(line); } //trans.commit(); trans.Start("inner_buildingpad"); // /* bdtpCurve.Add(bdtploop); //建立開挖深度 ICollection <Level> level_family = new FilteredElementCollector(doc).OfClass(typeof(Level)).Cast <Level>().ToList(); foreach (Level lev in level_family) { if (lev.Name == levlist[levlist.Count() - 1].Name) { BuildingPad b = BuildingPad.Create(doc, bdtp.Id, lev.Id, bdtpCurve); //b.get_Parameter(BuiltInParameter.) //b.LookupParameter("厚度").SetValueString("1"); levdeep = lev; } } // */ trans.Commit(); trans.Start("side_wall"); //建立側牆 List <Wall> side_wall = new List <Wall>(); foreach (WallType walltype in walltype_familyinstance) { if (walltype.Name == "側牆") { for (int i = 0; i < csv.sidewall.Count; i++) { double floor_width = csv.back[i].Item3 * 1000 / 304.8; //set the width to a new value double floor_deep = -csv.back[i].Item2 * 1000 / 304.8; double floor_bottom = (floor_deep + floor_width / 2); //側牆底部高程點(考慮厚度做offset後-往上半個厚度) double floor_top = (csv.back[i + 1].Item2 + csv.back[i + 1].Item3 / 2) * 1000 / 304.8; //側牆頂部高程點(考慮厚度做offset後-往下半個厚度) for (int j = 0; j < points.Count <XYZ>() - 1; j++) { Curve side_c = side_wall_profileloops[j].CreateOffset((csv.sidewall[i].Item2 * 1000 / 2) / 304.8, new XYZ(0, 0, -1)); //此步驟為偏移擋土牆厚度1/2距離,作為建置參考線 Wall side_w = Wall.Create(doc, side_c, walltype.Id, re_levlist[i].Id, (floor_bottom * (-1) - floor_top), 0, false, false); side_w.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS).Set(csv.sidewall[i].Item1 + "側牆"); side_wall.Add(side_w); } } } } trans.Commit(); //取得側牆牆點座標 CurveArray profileloops_array = new CurveArray(); XYZ[] sidewall_points = new XYZ[points.Count <XYZ>()]; for (int i = 0; i < (inner_wall.Count <Wall>()); i++) { //side XYZ side_wall_curve_point = (side_wall[i].Location as LocationCurve).Curve.Tessellate()[0]; side_wall_curve_point = new XYZ(side_wall_curve_point.X, side_wall_curve_point.Y, 0); sidewall_points[i] = innerwall_points[i] - (innerwall_points[i] - side_wall_curve_point) * 2; } sidewall_points[points.Count <XYZ>() - 1] = sidewall_points[0]; //建立底板範圍 for (int i = 0; i < points.Count() - 1; i++) { Line line = Line.CreateBound(innerwall_points[i], innerwall_points[i + 1]); profileloops_array.Append(line); } trans.Start("建立底板"); //建立底板類型及實作元件 ICollection <FloorType> family = new FilteredElementCollector(doc).OfClass(typeof(FloorType)).Cast <FloorType>().ToList(); FloorType floor_type = family.Where(x => x.Name == "通用 300mm").First(); int base_control = 0; foreach (Tuple <string, double, double, double> base_tuple in csv.back) { FloorType newFamSym = null; try { newFamSym = floor_type.Duplicate(base_tuple.Item1) as FloorType; } catch { newFamSym = family.Where(x => x.Name == base_tuple.Item1).First(); } double floor_width = base_tuple.Item3 * 1000 / 304.8; //set the width to a new value double floor_deep = base_tuple.Item2 * -1 * 1000 / 304.8; double floor_offset = (floor_deep + floor_width / 2) * 304.8; newFamSym.GetCompoundStructure().GetLayers()[0].Width = floor_width; CompoundStructure ly = newFamSym.GetCompoundStructure(); ly.SetLayerWidth(0, floor_width); newFamSym.SetCompoundStructure(ly); Floor floor = doc.Create.NewFloor(profileloops_array, newFamSym as FloorType, re_levlist[base_control], false); floor.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS).Set(base_tuple.Item1); floor.get_Parameter(BuiltInParameter.FLOOR_HEIGHTABOVELEVEL_PARAM).SetValueString("0"); base_control += 1; } trans.Commit(); //取得所有XY數值 List <double> Xs = new List <double>(); List <double> Ys = new List <double>(); double[] slope = new double[inner_wall.Count <Wall>()]; double[] bias = new double[inner_wall.Count <Wall>()]; for (int i = 0; i < (innerwall_points.Count <XYZ>()); i++) { Xs.Add(innerwall_points[i].X); Ys.Add(innerwall_points[i].Y); if (i < slope.Count()) { if (innerwall_points[i + 1].X - innerwall_points[i].X == 0) { slope[i] = 20172018; bias[i] = innerwall_points[i + 1].X; } else { slope[i] = (innerwall_points[i + 1].Y - innerwall_points[i].Y) / (innerwall_points[i + 1].X - innerwall_points[i].X); if (slope[i] == 0 || Math.Abs(slope[i]) < 0.0000001) { bias[i] = innerwall_points[i + 1].Y; } else { bias[i] = innerwall_points[i + 1].Y - slope[i] * innerwall_points[i + 1].X; } } } } Transaction trans_2 = new Transaction(doc); trans_2.Start("交易開始"); //開始建立中間樁 double columns_dis = csv.centralCol[0].Item1 * 1000 / 304.8; //中間樁間距 ICollection <FamilySymbol> columns_familyinstance = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Cast <FamilySymbol>().ToList(); foreach (FamilySymbol column_type in columns_familyinstance) { if (column_type.Name == "中間樁") { for (int j = 0; j < (Math.Abs(Ys.Max() - Ys.Min()) / columns_dis - 1); j++) { for (int i = 0; i < (Math.Abs(Xs.Max() - Xs.Min()) / columns_dis - 1); j++) { XYZ column_location = new XYZ(Xs.Min() + (i + 1) * columns_dis, Ys.Min() + (j + 1) * columns_dis, 0); if (IsInPolygon(column_location, innerwall_points) == true) { //TaskDialog.Show("asd", "asd"); FamilyInstance column_instance = doc.Create.NewFamilyInstance(column_location, column_type, levdeep, Autodesk.Revit.DB.Structure.StructuralType.Column); column_instance.get_Parameter(BuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM).SetValueString("0"); //中間樁長度 column_instance.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS).Set("中間樁"); } } } } } //迴圈起始點 for (int lev = 0; lev != csv.supLevel.Count(); lev++) { //建立圍囹 //開始建立圍囹 ICollection <FamilySymbol> beam_familyinstance = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Cast <FamilySymbol>().ToList(); foreach (FamilySymbol beam_type in beam_familyinstance) { if (beam_type.Name == "H100x100") { double beam_H = double.Parse(beam_type.LookupParameter("H").AsValueString()); double beam_B = double.Parse(beam_type.LookupParameter("B").AsValueString()); for (int i = 0; i < innerwall_points.Count <XYZ>() - 1; i++) { Curve c = null; if (i == points.Count <XYZ>()) { try { int.Parse(csv.supLevel[lev].Item1.ToString()); c = Line.CreateBound(innerwall_points[i], innerwall_points[0]).CreateOffset((beam_H) / 304.8, new XYZ(0, 0, -1)); } catch { c = Line.CreateBound(sidewall_points[i], sidewall_points[0]).CreateOffset((beam_H) / 304.8, new XYZ(0, 0, -1)); } } else { try { int.Parse(csv.supLevel[lev].Item1.ToString()); c = Line.CreateBound(innerwall_points[i], innerwall_points[i + 1]).CreateOffset((beam_H) / 304.8, new XYZ(0, 0, -1)); } catch { c = Line.CreateBound(sidewall_points[i], sidewall_points[i + 1]).CreateOffset((beam_H) / 304.8, new XYZ(0, 0, -1)); } } FamilyInstance beam = doc.Create.NewFamilyInstance(c, beam_type, levlist[0], Autodesk.Revit.DB.Structure.StructuralType.Beam); beam.LookupParameter("斷面旋轉").SetValueString("90"); StructuralFramingUtils.DisallowJoinAtEnd(beam, 0); StructuralFramingUtils.DisallowJoinAtEnd(beam, 1); beam.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS).Set((csv.supLevel[lev].Item1).ToString() + "-圍囹"); //判斷圍囹之垂直深度,斜率零為負,反之為正 if ((i % 2 == 0)) { beam.get_Parameter(BuiltInParameter.Y_OFFSET_VALUE).SetValueString((csv.supLevel[lev].Item2 * 1000 - beam_B / 2).ToString()); //2000為支撐階數深度,表1中 } else { beam.get_Parameter(BuiltInParameter.Y_OFFSET_VALUE).SetValueString((csv.supLevel[lev].Item2 * 1000 + beam_B / 2).ToString()); } } } } //開始建立支撐 //建立支撐 XYZ frame_startpoint = null; XYZ frame_endpoint = null; ICollection <FamilySymbol> frame_familyinstance = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Cast <FamilySymbol>().ToList(); foreach (FamilySymbol frame_type in frame_familyinstance) { if (frame_type.Name == "H100x100") { double frame_H = double.Parse(frame_type.LookupParameter("H").AsValueString()); //X向支撐 for (int j = 0; j < Math.Abs(Ys.Max() - Ys.Min()) / columns_dis - 1; j++) { for (int i = 0; i < Math.Abs(Xs.Max() - Xs.Min()) / columns_dis - 1; i++) { XYZ frame_location = new XYZ(Xs.Min() + (i + 1) * columns_dis, Ys.Min() + (j + 1) * columns_dis, 0); frame_startpoint = intersection(frame_location, for_check_innerwall_points, slope, bias, true)[0]; if (IsInPolygon(frame_location, innerwall_points) == true) { try { frame_endpoint = intersection(frame_location, for_check_innerwall_points, slope, bias, true)[1]; Line line = Line.CreateBound(frame_startpoint, frame_endpoint); FamilyInstance frame_instance = doc.Create.NewFamilyInstance(line, frame_type, levdeep, Autodesk.Revit.DB.Structure.StructuralType.Beam); frame_instance.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS).Set((csv.supLevel[lev].Item1).ToString() + "-支撐"); //處理偏移與延伸問題 frame_instance.get_Parameter(BuiltInParameter.Z_OFFSET_VALUE).SetValueString((csv.supLevel[lev].Item2 * -1000).ToString()); frame_instance.get_Parameter(BuiltInParameter.Y_OFFSET_VALUE).SetValueString((-frame_H).ToString()); try { int.Parse(csv.supLevel[lev].Item1.ToString()); frame_instance.get_Parameter(BuiltInParameter.START_EXTENSION).SetValueString((-frame_H).ToString()); frame_instance.get_Parameter(BuiltInParameter.END_EXTENSION).SetValueString((-frame_H).ToString()); } catch { frame_instance.get_Parameter(BuiltInParameter.START_EXTENSION).SetValueString((-frame_H - csv.sidewall[0].Item2 * 1000).ToString()); frame_instance.get_Parameter(BuiltInParameter.END_EXTENSION).SetValueString((-frame_H - csv.sidewall[0].Item2 * 1000).ToString()); } //取消接合 StructuralFramingUtils.DisallowJoinAtEnd(frame_instance, 0); StructuralFramingUtils.DisallowJoinAtEnd(frame_instance, 1); //若為雙向支撐,則鏡射支撐 if (csv.supLevel[lev].Item3 == 2) { ElementTransformUtils.MirrorElement(doc, frame_instance.Id, Plane.CreateByNormalAndOrigin(XYZ.BasisY, frame_startpoint)); } break; } catch { } } } } //Y向支撐 for (int i = 0; i < (Math.Abs(Xs.Max() - Xs.Min()) / columns_dis - 1); i++) { for (int j = 0; j < (Math.Abs(Ys.Max() - Ys.Min()) / columns_dis - 1); j++) { XYZ frame_location = new XYZ(Xs.Min() + (i + 1) * columns_dis, Ys.Min() + (1 + j) * columns_dis, 0); frame_startpoint = intersection(frame_location, for_check_innerwall_points, slope, bias, false)[0]; if (IsInPolygon(frame_location, innerwall_points) == true) { try { frame_endpoint = intersection(frame_location, for_check_innerwall_points, slope, bias, false)[1]; Line line = Line.CreateBound(frame_startpoint, frame_endpoint); FamilyInstance frame_instance = doc.Create.NewFamilyInstance(line, frame_type, levdeep, Autodesk.Revit.DB.Structure.StructuralType.Beam); frame_instance.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS).Set((csv.supLevel[lev].Item1).ToString() + "-支撐"); //處理偏移與延伸問題 frame_instance.get_Parameter(BuiltInParameter.Z_OFFSET_VALUE).SetValueString((csv.supLevel[lev].Item2 * -1000 + frame_H).ToString());//2000為支撐階數深度,表1中 frame_instance.get_Parameter(BuiltInParameter.Y_OFFSET_VALUE).SetValueString((-frame_H).ToString()); try { int.Parse(csv.supLevel[lev].Item1.ToString()); frame_instance.get_Parameter(BuiltInParameter.START_EXTENSION).SetValueString((-frame_H).ToString()); frame_instance.get_Parameter(BuiltInParameter.END_EXTENSION).SetValueString((-frame_H).ToString()); } catch { frame_instance.get_Parameter(BuiltInParameter.START_EXTENSION).SetValueString((-frame_H - csv.sidewall[0].Item2 * 1000).ToString()); frame_instance.get_Parameter(BuiltInParameter.END_EXTENSION).SetValueString((-frame_H - csv.sidewall[0].Item2 * 1000).ToString()); } //取消接合 StructuralFramingUtils.DisallowJoinAtEnd(frame_instance, 0); StructuralFramingUtils.DisallowJoinAtEnd(frame_instance, 1); //若為雙向支撐,則鏡射支撐 if (csv.supLevel[lev].Item3 == 2) { ElementTransformUtils.MirrorElement(doc, frame_instance.Id, Plane.CreateByNormalAndOrigin(XYZ.BasisX, frame_startpoint)); } break; } catch { } } } } } } //建立斜撐 ICollection <FamilySymbol> slopframe_symbol = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Cast <FamilySymbol>().ToList(); foreach (FamilySymbol slopframe_type in slopframe_symbol) { if (slopframe_type.Name == "斜撐") { //X向斜撐 for (int j = 0; j < (Math.Abs(Ys.Max() - Ys.Min()) / columns_dis - 1); j++) { for (int i = 0; i < (Math.Abs(Xs.Max() - Xs.Min()) / columns_dis - 1); i++) { XYZ frame_location = new XYZ(Xs.Min() + (i + 1) * columns_dis, Ys.Min() + (j + 1) * columns_dis, 0); frame_startpoint = intersection(frame_location, for_check_innerwall_points, slope, bias, true)[0]; if (IsInPolygon(frame_location, innerwall_points) == true) { frame_endpoint = intersection(frame_location, for_check_innerwall_points, slope, bias, true)[1]; FamilyInstance slopframe_1 = doc.Create.NewFamilyInstance(frame_startpoint, slopframe_type, all_level_list[lev], Autodesk.Revit.DB.Structure.StructuralType.Beam); FamilyInstance slopframe_2 = doc.Create.NewFamilyInstance(frame_endpoint, slopframe_type, all_level_list[lev], Autodesk.Revit.DB.Structure.StructuralType.Beam); slopframe_1.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS).Set((csv.supLevel[lev].Item1).ToString() + "-斜撐"); slopframe_2.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS).Set((csv.supLevel[lev].Item1).ToString() + "-斜撐"); slopframe_1.get_Parameter(BuiltInParameter.INSTANCE_FREE_HOST_OFFSET_PARAM).Set(Math.Abs(all_level_list[lev].Elevation - csv.supLevel[lev].Item2 * -1000 / 304.8 + slopframe_1.LookupParameter("支撐厚度").AsDouble() / 2)); slopframe_2.get_Parameter(BuiltInParameter.INSTANCE_FREE_HOST_OFFSET_PARAM).Set(Math.Abs(all_level_list[lev].Elevation - csv.supLevel[lev].Item2 * -1000 / 304.8 + slopframe_1.LookupParameter("支撐厚度").AsDouble() / 2)); int o; if (int.TryParse(csv.supLevel[lev].Item1, out o) == false)//305為圍囹寬度,應該要查表而非指定。 { slopframe_1.LookupParameter("圍囹寬度").SetValueString((305 + csv.sidewall[0].Item2 * 1000).ToString()); slopframe_2.LookupParameter("圍囹寬度").SetValueString((305 + csv.sidewall[0].Item2 * 1000).ToString()); } else { slopframe_1.LookupParameter("圍囹寬度").SetValueString((305).ToString()); slopframe_2.LookupParameter("圍囹寬度").SetValueString((305).ToString()); } //旋轉斜撐元件 Line rotate_line_s = Line.CreateBound(frame_startpoint, frame_startpoint + new XYZ(0, 0, 1)); Line rotate_line_e = Line.CreateBound(frame_endpoint, frame_endpoint + new XYZ(0, 0, 1)); slopframe_1.Location.Rotate(rotate_line_s, 1.5 * Math.PI); slopframe_2.Location.Rotate(rotate_line_e, 0.5 * Math.PI); //鏡射斜撐元件 if (csv.supLevel[lev].Item3 == 2)//雙排 { ElementTransformUtils.MirrorElement(doc, slopframe_1.Id, Plane.CreateByNormalAndOrigin(XYZ.BasisY, frame_startpoint)); ElementTransformUtils.MirrorElement(doc, slopframe_2.Id, Plane.CreateByNormalAndOrigin(XYZ.BasisY, frame_endpoint)); } else//單排 { ElementTransformUtils.MirrorElement(doc, slopframe_1.Id, Plane.CreateByNormalAndOrigin(XYZ.BasisY, frame_startpoint.Add(new XYZ(0, -(slopframe_1.LookupParameter("支撐厚度").AsDouble() / 2 + slopframe_1.LookupParameter("中間樁直徑").AsDouble() / 2), 0)))); ElementTransformUtils.MirrorElement(doc, slopframe_2.Id, Plane.CreateByNormalAndOrigin(XYZ.BasisY, frame_endpoint)); slopframe_2.Location.Move((new XYZ(0, -(slopframe_1.LookupParameter("支撐厚度").AsDouble() + slopframe_1.LookupParameter("中間樁直徑").AsDouble()), 0))); } break; } } } //Y向斜撐 for (int i = 0; i < (Math.Abs(Xs.Max() - Xs.Min()) / columns_dis - 1); i++) { for (int j = 0; j < (Math.Abs(Ys.Max() - Ys.Min()) / columns_dis - 1); j++) { XYZ frame_location = new XYZ(Xs.Min() + (i + 1) * columns_dis, Ys.Min() + (1 + j) * columns_dis, 0); frame_startpoint = intersection(frame_location, for_check_innerwall_points, slope, bias, false)[0]; if (IsInPolygon(frame_location, innerwall_points) == true) { frame_endpoint = intersection(frame_location, for_check_innerwall_points, slope, bias, false)[1]; FamilyInstance slopframe_1 = doc.Create.NewFamilyInstance(frame_startpoint, slopframe_type, all_level_list[lev], Autodesk.Revit.DB.Structure.StructuralType.Beam); FamilyInstance slopframe_2 = doc.Create.NewFamilyInstance(frame_endpoint, slopframe_type, all_level_list[lev], Autodesk.Revit.DB.Structure.StructuralType.Beam); slopframe_1.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS).Set((csv.supLevel[lev].Item1).ToString() + "-斜撐"); slopframe_2.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS).Set((csv.supLevel[lev].Item1).ToString() + "-斜撐"); slopframe_1.get_Parameter(BuiltInParameter.INSTANCE_FREE_HOST_OFFSET_PARAM).Set(Math.Abs(all_level_list[lev].Elevation - csv.supLevel[lev].Item2 * -1000 / 304.8 - slopframe_1.LookupParameter("支撐厚度").AsDouble() / 2)); slopframe_2.get_Parameter(BuiltInParameter.INSTANCE_FREE_HOST_OFFSET_PARAM).Set(Math.Abs(all_level_list[lev].Elevation - csv.supLevel[lev].Item2 * -1000 / 304.8 - slopframe_2.LookupParameter("支撐厚度").AsDouble() / 2)); int o; if (int.TryParse(csv.supLevel[lev].Item1, out o) == false)//305為圍囹寬度,應該要查表而非指定。 { slopframe_1.LookupParameter("圍囹寬度").SetValueString((305 + csv.sidewall[0].Item2 * 1000).ToString()); slopframe_2.LookupParameter("圍囹寬度").SetValueString((305 + csv.sidewall[0].Item2 * 1000).ToString()); } else { slopframe_1.LookupParameter("圍囹寬度").SetValueString((305).ToString()); slopframe_2.LookupParameter("圍囹寬度").SetValueString((305).ToString()); } //旋轉斜撐元件 Line rotate_line = Line.CreateBound(frame_endpoint, frame_endpoint + new XYZ(0, 0, 1)); slopframe_2.Location.Rotate(rotate_line, Math.PI); //鏡射斜撐元件 if (csv.supLevel[lev].Item3 == 2)//雙排 { ElementTransformUtils.MirrorElement(doc, slopframe_1.Id, Plane.CreateByNormalAndOrigin(XYZ.BasisX, frame_startpoint)); ElementTransformUtils.MirrorElement(doc, slopframe_2.Id, Plane.CreateByNormalAndOrigin(XYZ.BasisX, frame_endpoint)); } else//單排 { ElementTransformUtils.MirrorElement(doc, slopframe_1.Id, Plane.CreateByNormalAndOrigin(XYZ.BasisX, frame_startpoint.Add(new XYZ(slopframe_1.LookupParameter("支撐厚度").AsDouble() / 2 + slopframe_1.LookupParameter("中間樁直徑").AsDouble() / 2, 0, 0)))); ElementTransformUtils.MirrorElement(doc, slopframe_2.Id, Plane.CreateByNormalAndOrigin(XYZ.BasisX, frame_endpoint)); slopframe_2.Location.Move((new XYZ((slopframe_1.LookupParameter("支撐厚度").AsDouble() + slopframe_1.LookupParameter("中間樁直徑").AsDouble()), 0, 0))); } break; } } } } } } trans_2.Commit(); return(Result.Succeeded); }
private void Stream(ArrayList data, FloorType floorType) { data.Add(new Snoop.Data.ClassSeparator(typeof(FloorType))); data.Add(new Snoop.Data.Bool("Is foundation slab", floorType.IsFoundationSlab)); }
internal DefinedFloors() { Mud = new FloorType(0, "floor.gras", 30, 0); Stone = new FloorType(1, "floor.stone", 30, 0); Water = new FloorType(2, "floor.water", 60, 10); }
public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication app = commandData.Application; UIDocument uidoc = app.ActiveUIDocument; Document doc = uidoc.Document; // Find all wall types and their system families (or kinds): WallType newWallType = null; string msg = "All wall types and families in the model:"; string content = string.Empty; FilteredElementCollector wallTypes = new FilteredElementCollector(doc) .OfClass(typeof(WallType)); foreach (WallType wt in wallTypes) { content += "\nType=" + wt.Name + " Family=" + wt.Kind.ToString(); newWallType = wt; } content += "\n\nStored WallType " + newWallType.Name + " (Id=" + newWallType.Id.IntegerValue.ToString() + ") for later use."; LabUtils.InfoMsg(msg, content); // Find all floor types: FloorType newFloorType = null; msg = "All floor types in the model:"; content = string.Empty; //foreach( FloorType ft in doc.FloorTypes ) // 2014 FilteredElementCollector floorTypes // 2015 = new FilteredElementCollector(doc) .OfClass(typeof(FloorType)); foreach (FloorType ft in floorTypes) // 2015 { content += "\nType=" + ft.Name + ", Id=" + ft.Id.IntegerValue.ToString(); // In 9.0, the "Foundation Slab" system family from "Structural // Foundations" category ALSO contains FloorType class instances. // Be careful to exclude those as choices for standard floor types. Parameter p = ft.get_Parameter(BuiltInParameter.SYMBOL_FAMILY_NAME_PARAM); string famName = null == p ? "?" : p.AsString(); Category cat = ft.Category; content += ", Family=" + famName + ", Category=" + cat.Name; // store for the new floor type only if it has the proper Floors category: if (cat.Id.Equals((int)BuiltInCategory.OST_Floors)) { newFloorType = ft; } } content += (null == newFloorType) ? "\n\nNo floor type found." : "\n\nStored FloorType " + newFloorType.Name + " (Id=" + newFloorType.Id.IntegerValue.ToString() + ") for later use"; LabUtils.InfoMsg(msg, content); // Change the type for selected walls and floors: using (Transaction t = new Transaction(doc)) { t.Start("Change Type of Walls and Floors"); msg = "{0} {1}: Id={2}" + "\r\n changed from old type={3}; Id={4}" + " to new type={5}; Id={6}."; //ElementSet sel = uidoc.Selection.Elements; // 2014 ICollection <ElementId> ids = uidoc.Selection.GetElementIds(); // 2015 int iWall = 0; int iFloor = 0; foreach (ElementId id in ids) { Element e = doc.GetElement(id); if (e is Wall) { ++iWall; Wall wall = e as Wall; WallType oldWallType = wall.WallType; // change wall type and report the old/new values wall.WallType = newWallType; LabUtils.InfoMsg(string.Format(msg, "Wall", iWall, wall.Id.IntegerValue, oldWallType.Name, oldWallType.Id.IntegerValue, wall.WallType.Name, wall.WallType.Id.IntegerValue)); } else if (null != newFloorType && e is Floor) { ++iFloor; Floor f = e as Floor; FloorType oldFloorType = f.FloorType; f.FloorType = newFloorType; LabUtils.InfoMsg(string.Format(msg, "Floor", iFloor, f.Id.IntegerValue, oldFloorType.Name, oldFloorType.Id.IntegerValue, f.FloorType.Name, f.FloorType.Id.IntegerValue)); } } t.Commit(); } return(Result.Succeeded); }
private void GenerateFloor(ref Building building, FloorScheme scheme, Transform floorParent, Vector3 position, Quaternion rotation, int floorIndex, FloorType type) { if (!building.Floors.TryGetValue(floorIndex, out Floor floor)) { floor = Object.Instantiate(BuildingsDatabase.floorPrefab, position, floorParent.rotation); floor.gameObject.name = $"Floor_{floorIndex}"; building.Floors.Add(floorIndex, floor); } floor.Type = type; floor.transform.SetParent(floorParent); GameObject prefab = null; // add the right side: switch (floor.Type) { case FloorType.GroundFloor: prefab = scheme.SideDoor; break; case FloorType.Roof: prefab = scheme.SideWallR; break; default: prefab = scheme.SideWindowR; break; } var segment = GameObject.Instantiate(prefab, position, rotation, floor.transform) as GameObject; floor.segments.Add(segment); var nonStairsSegmentIndex = 0; // add floor middle segments: for (int i = 0; i < building.Config.floorSegmentsCount; i++) { if (type != FloorType.Roof && i == building.Config.stairsSegmentIndex) { prefab = scheme.Stairs; } else { prefab = scheme.EmptyWall; nonStairsSegmentIndex = i; } segment = GameObject.Instantiate(prefab, position, rotation, floor.transform) as GameObject; var doorPortal = segment.GetComponentInChildren <DoorPortal>(); if (doorPortal != null) { doorPortal.floorIndex = floorIndex; // setup index below: var indexBelow = floorIndex - 1; indexBelow = (indexBelow < 0) ? DoorPortal.MinIndex : indexBelow; doorPortal.floorIndexBelow = indexBelow; // setup index above: var indexAbove = floorIndex + 1; indexAbove = (indexAbove < building.Floors.Count) ? DoorPortal.MaxIndex : indexAbove; doorPortal.floorIndexAbove = indexAbove; doorPortal.building = building; building.Stairs.Add(floorIndex, doorPortal); } floor.segments.Add(segment); position += new Vector3(scheme.segmentWidth, 0f, 0f); } // add empty wall OR window on the left side: switch (floor.Type) { case FloorType.Roof: prefab = scheme.SideWallL; break; case FloorType.MiddleFloor: prefab = scheme.SideWindowL; break; default: prefab = scheme.GetRandomSideWall(rightSide: false); break; } segment = GameObject.Instantiate(prefab, position, rotation, floor.transform) as GameObject; floor.segments.Add(segment); // set walls color: SetWallsColor(floor.segments[nonStairsSegmentIndex], building.Config.wallsColor); // generate ItemCatcher game object: if (type != FloorType.Roof) { var floorWidth = Vector3.Distance(floor.segments[0].transform.position, floor.segments[floor.segments.Count - 2].transform.position); var widthRatio = building.isBuildingIn ? 0.9f : 1.2f; var realFloorSize = new Vector3((floorWidth + scheme.segmentWidth) * widthRatio, scheme.segmentHeight * 0.8f); var center = new Vector3(floor.transform.position.x + floorWidth * 0.5f, position.y + scheme.segmentHeight * 0.5f); var itemCatcher = new GameObject("ItemCatcher").AddComponent <ItemCatcher>(); itemCatcher.gameObject.transform.SetParent(floor.gameObject.transform); itemCatcher.Setup(center, realFloorSize, floor); } }
public void ByName_NullArgument() { Assert.Throws(typeof(ArgumentNullException), () => FloorType.ByName(null)); }
/// <summary> /// Constructor, default to Wall /// </summary> /// <param name="xV"></param> /// <param name="yV"></param> public FloorTile(int xV, int yV) { type=FloorType.Wall; x = xV; y = yV; }