public static Elements.Floor[] FloorsFromRevitFloor(ADSK.Document doc, ADSK.Floor revitFloor) { var profiles = GetProfilesOfTopFacesOfFloor(doc, revitFloor); var thickness = revitFloor.LookupParameter("Thickness")?.AsDouble(); var floors = new List <Elements.Floor>(); foreach (var profile in profiles) { var zMove = profile.Perimeter.Vertices.Max(v => v.Z); var transform = new ElemGeom.Transform(0, 0, -zMove); var zeroedProfile = transform.OfProfile(profile); transform.Invert(); var floorThickness = thickness.HasValue ? Elements.Units.FeetToMeters(thickness.Value) : Elements.Units.FeetToMeters(1); // Revit floors are extrusions down, and currently Hypar floors are extrusions up, so we also must move by the floor thickness transform.Move(new Vector3(0, 0, -floorThickness)); var floor = new Elements.Floor(zeroedProfile, floorThickness, transform); floors.Add(floor); } return(floors.ToArray()); }
private IEnumerator CreateFacade(Model model) { var facade = new Model(); var floors = model.ElementsOfType <Floor>().ToList(); var f1 = floors[0]; var f2 = floors[floors.Count - 1]; var height = f2.Elevation - f1.Elevation; var f2f = floors[1].Elevation - f1.Elevation; var et = new Elements.Geometry.Transform(new Elements.Geometry.Vector3(0, 0, f1.Elevation)); var perim = f1.Profile.Perimeter.Offset(0.001)[0]; var mass = new Mass(new Profile(perim), height + f2f / 3); gridCount = 0; foreach (var f in perim.Segments()) { var top = new Line(new Elements.Geometry.Vector3(f.Start.X, f.Start.Y, f.Start.Z + height), new Elements.Geometry.Vector3(f.End.X, f.End.Y, f.End.Z + height)); var g = new Elements.Grid(f, top, 4, f2f / 3); var cells = g.Cells(); gridCount += cells.Length; for (var i = 0; i < cells.GetLength(0); i++) { var count = -1; for (var j = 0; j < cells.GetLength(1); j++) { var c = cells[i, j]; var m = BuiltInMaterials.Glass; count++; if (count == 0 || count == 2) { m = BuiltInMaterials.Default; } if (count == 2) { count = -1; } var p1 = new Panel(c.Reverse().ToArray().Shrink(0.025), m); facade.AddElement(p1); } } yield return(null); } foreach (var go in next) { go.SendMessage("UpdateModel", facade); } yield return(facade.ToGameObjects(this.gameObject)); }
public static UnityEngine.Vector3[] ToUnityVertices(this double[] arr, Elements.Geometry.Transform t) { var verts = new UnityEngine.Vector3[arr.Length / 3]; var index = 0; for (var i = 0; i < arr.Length / 3; i += 3) { var vt = t != null?t.OfVector(new Vector3(arr[i], arr[i + 1], arr[i + 2])) : new Vector3(arr[i], arr[i + 1], arr[i + 2]); var v = vt.ToUnityVector3(); verts[index] = v; index++; } return(verts); }
public static Frame ToFrame(this Elements.Geometry.Transform transform, Application app) { return(new Frame(transform.Origin.ToXYZ(app), transform.XAxis.ToXYZ(app).Normalize(), transform.YAxis.ToXYZ(app).Normalize(), transform.ZAxis.ToXYZ(app).Normalize())); }