public static Transform AsTransform(DB.Transform transform) { var value = new Transform { M00 = transform.BasisX.X, M10 = transform.BasisX.Y, M20 = transform.BasisX.Z, M30 = 0.0, M01 = transform.BasisY.X, M11 = transform.BasisY.Y, M21 = transform.BasisY.Z, M31 = 0.0, M02 = transform.BasisZ.X, M12 = transform.BasisZ.Y, M22 = transform.BasisZ.Z, M32 = 0.0, M03 = transform.Origin.X, M13 = transform.Origin.Y, M23 = transform.Origin.Z, M33 = 1.0 }; return(value); }
static public Rhino.Geometry.Transform ToRhino(this Autodesk.Revit.DB.Transform transform) { var value = new Rhino.Geometry.Transform { M00 = transform.BasisX.X, M10 = transform.BasisX.Y, M20 = transform.BasisX.Z, M30 = 0.0, M01 = transform.BasisY.X, M11 = transform.BasisY.Y, M21 = transform.BasisY.Z, M31 = 0.0, M02 = transform.BasisZ.X, M12 = transform.BasisZ.Y, M22 = transform.BasisZ.Z, M32 = 0.0, M03 = transform.Origin.X, M13 = transform.Origin.Y, M23 = transform.Origin.Z, M33 = 1.0 }; return(value); }
static RevSurface FromRevolvedSurface(DB.XYZ origin, DB.XYZ xDir, DB.XYZ yDir, DB.XYZ zDir, DB.Curve curve, DB.BoundingBoxUV bboxUV, double relativeTolerance) { var atol = relativeTolerance * Revit.AngleTolerance; var ctol = relativeTolerance * Revit.ShortCurveTolerance; var uu = new Interval(bboxUV.Min.U - atol, bboxUV.Max.U + atol); var plane = new Plane ( AsPoint3d(origin), AsVector3d(xDir), AsVector3d(yDir) ); var axisDir = AsVector3d(zDir); using (var ECStoWCS = new DB.Transform(DB.Transform.Identity) { Origin = origin, BasisX = xDir.Normalize(), BasisY = yDir.Normalize(), BasisZ = zDir.Normalize() }) { var c = ToRhino(curve.CreateTransformed(ECStoWCS)); c = ctol == 0.0 ? c : c.Extend(CurveEnd.Both, ctol, CurveExtensionStyle.Smooth); var axis = new Line(plane.Origin, plane.Normal); return(RevSurface.Create(c, axis, uu.Min, uu.Max)); } }
private Arc CreateArc(XYZ PointStart, XYZ PointEnd, double radius, bool largeSagitta) { XYZ midPointChord = 0.5 * (PointStart + PointEnd); XYZ v = null; if (!(bool)this.GetArcRotationAntiClockWise()) { v = PointEnd - PointStart; } else { v = PointStart - PointEnd; } double d = 0.5 * v.GetLength(); // half chord length // Small and large circle sagitta: // http://www.mathopenref.com/sagitta.html double s = largeSagitta ? radius + Math.Sqrt(radius * radius - d * d) // sagitta large : radius - Math.Sqrt(radius * radius - d * d); // sagitta small var PX = Transform.CreateRotation(XYZ.BasisZ, 0.5 * Math.PI); var PX2 = v.Normalize(); var PX3 = v.Normalize().Multiply(s); XYZ midPointArc = midPointChord + Transform.CreateRotation(XYZ.BasisZ, 0.5 * Math.PI).OfVector(v.Normalize().Multiply(s)); return(Arc.Create(PointEnd, PointStart, midPointArc)); }
public LinkedInstanceProperties(RevitLinkInstance instance) { m_instance = instance; instanceId = instance.Id.IntegerValue; linkedDocument = instance.GetLinkDocument(); documentTitle = linkedDocument.Title; transformValue = instance.GetTotalTransform(); }
/// <summary> /// Set the internal Element, ElementId, and UniqueId /// </summary> /// <param name="space"></param> private void InternalSetSpace(DB.Mechanical.Space space) { InternalSpace = space; InternalElementId = space.Id; InternalUniqueId = space.UniqueId; InternalBoundarySegments = GetBoundarySegment(); InternalTransform = GetTransform(); }
/// <summary> /// Set the internal Element, ElementId, and UniqueId /// </summary> /// <param name="room"></param> private void InternalSetRoom(DB.Architecture.Room room) { InternalRoom = room; InternalElementId = room.Id; InternalUniqueId = room.UniqueId; InternalBoundarySegments = GetBoundarySegment(); InternalTransform = GetTransform(); }
public LinkedInstanceData(RevitLinkInstance instance) { m_instance = instance; instanceId = instance.Id.IntegerValue; #if RELEASE2013 linkedDocument = instance.Document; #elif RELEASE2014 || RELEASE2015 || RELEASE2016 linkedDocument = instance.GetLinkDocument(); #endif documentTitle = linkedDocument.Title; transformValue = instance.GetTotalTransform(); }
public LinkedInstanceProperties(RevitLinkInstance instance) { m_instance = instance; instanceId = instance.Id.IntegerValue; linkedDocument = instance.GetLinkDocument(); if (null != linkedDocument) { if (!string.IsNullOrEmpty(linkedDocument.Title)) { documentTitle = linkedDocument.Title; } } if (null != instance.GetTotalTransform()) { transformValue = instance.GetTotalTransform(); } }
public Autodesk.Revit.DB.FamilyInstance CreateFromDTO(Document doc, JObject source) { Common.Models.FamilyInstance famI = source.ToObject <Common.Models.FamilyInstance>(); Autodesk.Revit.DB.XYZ newOrigin = new Autodesk.Revit.DB.XYZ(famI.Transform.Origin.X, famI.Transform.Origin.Y, famI.Transform.Origin.Z); Autodesk.Revit.DB.FamilySymbol fam = doc.GetElement(new ElementId(Int32.Parse(famI.FamilyId))) as Autodesk.Revit.DB.FamilySymbol; if (fam == null) { throw new Exception($"Failed to find family with id {famI.FamilyId}"); } Autodesk.Revit.DB.FamilyInstance newFamily; if (famI.HostId != null) { ElementId hostId = new ElementId(Int32.Parse(famI.HostId)); newFamily = doc.Create.NewFamilyInstance( newOrigin, fam, doc.GetElement(hostId), StructuralType.NonStructural ); } else { newFamily = doc.Create.NewFamilyInstance( newOrigin, fam, StructuralType.NonStructural ); } Autodesk.Revit.DB.Transform trans = newFamily.GetTransform(); double rotation = Math.Atan2(famI.Transform.BasisX.Y, famI.Transform.BasisX.X); Autodesk.Revit.DB.XYZ a1 = newOrigin; Autodesk.Revit.DB.XYZ a2 = new Autodesk.Revit.DB.XYZ(a1.X, a1.Y, a1.Z + 10); Line axis = Line.CreateBound(a1, a2); newFamily.Location.Rotate(axis, rotation); return(newFamily); }
static RevSurface FromRevolvedSurface(DB.XYZ origin, DB.XYZ xDir, DB.XYZ yDir, DB.XYZ zDir, DB.Curve curve, DB.BoundingBoxUV bboxUV) { var ctol = Revit.ShortCurveTolerance; var atol = Revit.AngleTolerance; var uu = new Interval(bboxUV.Min.U - atol, bboxUV.Max.U + atol); var o = origin.ToRhino(); var z = (Vector3d)zDir.Normalize().ToRhino(); var axis = new Line(o, o + z); using (var ECStoWCS = new DB.Transform(DB.Transform.Identity) { Origin = origin, BasisX = xDir.Normalize(), BasisY = yDir.Normalize(), BasisZ = zDir.Normalize() }) { var c = curve.CreateTransformed(ECStoWCS).ToRhino().Extend(CurveEnd.Both, ctol, CurveExtensionStyle.Smooth); return(RevSurface.Create(c, axis, uu.Min, uu.Max)); } }
public void MapFromDTO(JObject sourceJSON, Autodesk.Revit.DB.FamilyInstance dest) { Autodesk.Revit.DB.Transform trans = dest.GetTransform(); Common.Models.FamilyInstance source = sourceJSON.ToObject <Common.Models.FamilyInstance>(); Autodesk.Revit.DB.XYZ newOrigin = new Autodesk.Revit.DB.XYZ(source.Transform.Origin.X, source.Transform.Origin.Y, source.Transform.Origin.Z); double oldAngle = Math.Atan2(trans.BasisX.Y, trans.BasisX.X); double newAngle = Math.Atan2(source.Transform.BasisX.Y, source.Transform.BasisX.X); Autodesk.Revit.DB.XYZ translation = newOrigin - trans.Origin; double rotation = newAngle - oldAngle; Autodesk.Revit.DB.XYZ a1 = trans.Origin; Autodesk.Revit.DB.XYZ a2 = new Autodesk.Revit.DB.XYZ(a1.X, a1.Y, a1.Z + 10); Line axis = Line.CreateBound(a1, a2); dest.Location.Rotate(axis, rotation); dest.Location.Move(translation); }
/// <summary> /// Description of ShadowCalculatorUtils. /// NOTE: this is derived from Scott Connover's great class "Geometry API in Revit" from DevCamp 2012, source files accesed 6-8-12 from here /// https://projectpoint.buzzsaw.com/_bz_rest/Web/Home/Index?folder=44#/_bz_rest/Web/Item/Items?folder=152&count=50&start=0&ownership=Homehttps://projectpoint.buzzsaw.com/_bz_rest/Web/Home/Index?folder=44#/_bz_rest/Web/Item/Items?folder=152&count=50&start=0&ownership=Home /// </summary> public static XYZ GetSunDirection(SunAndShadowSettings sunSettings) { //SunAndShadowSettings sunSettings = view.SunAndShadowSettings; XYZ initialDirection = XYZ.BasisY; //double altitude = sunSettings.Altitude; double altitude = sunSettings.GetFrameAltitude(sunSettings.ActiveFrame); Autodesk.Revit.DB.Transform altitudeRotation = Autodesk.Revit.DB.Transform.get_Rotation(XYZ.Zero, XYZ.BasisX, altitude); XYZ altitudeDirection = altitudeRotation.OfVector(initialDirection); //double azimuth = sunSettings.Azimuth; double azimuth = sunSettings.GetFrameAzimuth(sunSettings.ActiveFrame); double actualAzimuth = 2 * Math.PI - azimuth; Autodesk.Revit.DB.Transform azimuthRotation = Autodesk.Revit.DB.Transform.get_Rotation(XYZ.Zero, XYZ.BasisZ, actualAzimuth); XYZ sunDirection = azimuthRotation.OfVector(altitudeDirection); XYZ scaledSunVector = sunDirection.Multiply(100); return(scaledSunVector); }
public static Arc CreateArcFromCircCurve(XYZ PointStart, XYZ PointEnd, double radius, bool largeSagitta) { PointStart = new XYZ(PointStart.X, PointStart.Z, 0); PointEnd = new XYZ(PointEnd.X, PointEnd.Z, 0); XYZ midPointChord = 0.5 * (PointStart + PointEnd); XYZ v = null; //if (!(bool)this.GetArcRotationAntiClockWise()) //{ // v = PointEnd - PointStart; //} //else //{ v = PointStart - PointEnd; //} //} double d = 0.5 * v.GetLength(); // half chord length // Small and large circle sagitta: // http://www.mathopenref.com/sagitta.html double s = largeSagitta ? radius + Math.Sqrt(radius * radius - d * d) // sagitta large : radius - Math.Sqrt(radius * radius - d * d); // sagitta small var PX = Transform.CreateRotation(XYZ.BasisZ, 0.5 * Math.PI); var PX2 = v.Normalize(); var PX3 = v.Normalize().Multiply(s); XYZ midPointArc = midPointChord + Transform.CreateRotation(XYZ.BasisZ, 0.5 * Math.PI).OfVector(v.Normalize().Multiply(s)); var PointARcEnd = new XYZ(PointEnd.X, PointEnd.Z, PointEnd.Y); var PointArcStart = new XYZ(PointStart.X, PointStart.Z, PointStart.Y); var PointArcMid = new XYZ(midPointArc.X, midPointArc.Z, midPointArc.Y); return(Arc.Create(PointARcEnd, PointArcStart, PointArcMid)); }
private Autodesk.Revit.DB.NurbSpline CreateaSpiral(Spiral Sp) { var Splength = Sp.length; var spEndRadius = Sp.radiusEnd; var SpStartRad = Sp.radiusStart; var SpType = Sp.spiType; var SpTheta = Sp.theta; var SpTotalx = Sp.totalX; var SpTotaly = Sp.totalY; var spTanLong = Sp.tanLong; var spTanShort = Sp.tanShort; var Rot = Sp.rot; var startPoint = ExtractPoint(Sp.Items[0]); var EndPoint = ExtractPoint(Sp.Items[2]); var PiPoint = ExtractPoint(Sp.Items[1]); double Radius = default(double); bool StraightPartAtStart = false; if (double.IsInfinity(SpStartRad)) { Radius = spEndRadius; } else { Radius = SpStartRad; StraightPartAtStart = true; } var A = Math.Sqrt(Radius * Splength); var tao = Math.Pow(A, 2) / (2 * Math.Pow(Radius, 2)); // double SubDivisions = Math.Round((Splength / ObjectPlacement.Stationincrement)); //Change double SubDivisions = Math.Round((Splength * 20)); var step = tao / SubDivisions; List <XYZ> ControlPoints = new List <XYZ>(); for (double i = 0.0; i < tao; i = i + step) { var x = A * Math.Sqrt(2 * i) * (1 - (Math.Pow(i, 2) / 10) + (Math.Pow(i, 4) / 216)); var y = A * Math.Sqrt(2 * i) * ((i / 3) - (Math.Pow(i, 3) / 42) + (Math.Pow(i, 5) / 1320)); //var Point = new XYZ(x, y, 0); if (Rot == clockwise.ccw) { var Point = new XYZ(y, x, 0) + EndPoint; ControlPoints.Add(Point); } else { var Point = new XYZ(y, x, 0) + startPoint; ControlPoints.Add(Point); } } var V1 = (ControlPoints.Last() - ControlPoints.First()).Normalize(); var V2 = (EndPoint - startPoint).Normalize(); var Angle = V2.AngleTo(V1); Angle = ((Math.PI / 2) - Angle); List <double> Weights = Enumerable.Repeat(1.0, ControlPoints.Count).ToList(); var P = NurbSpline.CreateCurve(ControlPoints, Weights); NurbSpline RotatedCurve = null; if (Rot != clockwise.ccw) { var TransForm = Transform.CreateRotationAtPoint(XYZ.BasisZ, (Angle - Math.PI / 2), startPoint); RotatedCurve = (NurbSpline)P.CreateTransformed(TransForm); } else { var TransForm = Transform.CreateRotationAtPoint(XYZ.BasisZ, (Angle + Math.PI / 2), EndPoint); RotatedCurve = (NurbSpline)P.CreateTransformed(TransForm); var PointsReversed = RotatedCurve.CtrlPoints.Reverse(); RotatedCurve = (NurbSpline)NurbSpline.CreateCurve(PointsReversed.ToList(), Weights); } RevitSegmentElement = RotatedCurve; return(RotatedCurve); }
public static Transform ToRhino(this DB.Transform transform) => RawDecoder.ToRhino(transform);
public override Value Evaluate(FSharpList <Value> args) { if (_reference.ElementReferenceType != ElementReferenceType.REFERENCE_TYPE_SURFACE && _reference.ElementReferenceType != ElementReferenceType.REFERENCE_TYPE_LINEAR) { ElementId refElementId = _reference.ElementId; Element refElement = dynRevitSettings.Doc.Document.GetElement(refElementId); if (refElement is ReferencePoint) { ReferencePoint rp = refElement as ReferencePoint; XYZ rpXYZ = rp.Position; return(Value.NewContainer(rpXYZ)); } GeometryObject thisObjectPoint = SelectedElement.GetGeometryObjectFromReference(_reference); if (!(thisObjectPoint is Autodesk.Revit.DB.Point)) { throw new Exception("Could not use face or edge which is not part of the model"); } var thisPoint = thisObjectPoint as Autodesk.Revit.DB.Point; XYZ pointXYZ = thisPoint.Coord; return(Value.NewContainer(pointXYZ)); } GeometryObject thisObject = SelectedElement.GetGeometryObjectFromReference(_reference); Autodesk.Revit.DB.Transform thisTrf = null; if (_init && (old_refXyz == null || !_reference.Equals(old_refXyz))) { _init = false; } { GeometryObject geomObj = SelectedElement.get_Geometry(new Options()); var geomElement = geomObj as GeometryElement; // ugly code to detect if transform for geometry object is needed or not // filed request to provide this info via API, but meanwhile ... foreach (GeometryObject geob in geomElement) { if (!(geob is GeometryInstance)) { continue; } var ginsta = geob as GeometryInstance; GeometryElement gSymbolElement = ginsta.GetSymbolGeometry(); var geometryElements = new List <GeometryElement> { gSymbolElement }; bool found = false; for (; geometryElements.Count > 0 && !found;) { GeometryElement thisGeometryElement = geometryElements[0]; geometryElements.Remove(thisGeometryElement); foreach (GeometryObject geobSym in thisGeometryElement) { if (geobSym is GeometryElement) { geometryElements.Add(geobSym as GeometryElement); continue; } if ((thisObject is Curve) && (geobSym is Curve) && (thisObject == geobSym)) { found = true; break; } if (thisObject is Curve) { continue; } if ((thisObject is Autodesk.Revit.DB.Face) && (geobSym is Autodesk.Revit.DB.Face) && (thisObject == geobSym)) { found = true; break; } if ((thisObject is Edge) && (geobSym is Autodesk.Revit.DB.Face)) { var edge = thisObject as Edge; //use GetFace after r2013 support is dropped if (geobSym == edge.get_Face(0) || geobSym == edge.get_Face(1)) { found = true; break; } } if (!(geobSym is Solid)) { continue; } FaceArray solidFaces = ((Solid)geobSym).Faces; int numFaces = solidFaces.Size; for (int index = 0; index < numFaces && !found; index++) { Autodesk.Revit.DB.Face faceAt = solidFaces.get_Item(index); if ((thisObject is Autodesk.Revit.DB.Face) && (thisObject == faceAt)) { found = true; break; } if (thisObject is Edge) { var edge = thisObject as Edge; //use GetFace after r2013 support is dropped if (faceAt == edge.get_Face(0) || faceAt == edge.get_Face(1)) { found = true; break; } } } } } if (found) { thisTrf = ginsta.Transform; break; } } if (thisObject == null) { throw new Exception("could not resolve reference for XYZ on Element"); } } XYZ thisXYZ; if (_reference.ElementReferenceType == ElementReferenceType.REFERENCE_TYPE_SURFACE && thisObject is Autodesk.Revit.DB.Face) { var face = thisObject as Autodesk.Revit.DB.Face; if (!_init) { _param0 = _reference.UVPoint[0]; _param1 = _reference.UVPoint[1]; _init = true; } var uv = new UV(_param0, _param1); thisXYZ = face.Evaluate(uv); if (thisTrf != null) { thisXYZ = thisTrf.OfPoint(thisXYZ); } } else if (_reference.ElementReferenceType == ElementReferenceType.REFERENCE_TYPE_LINEAR) { Curve curve; if (thisObject is Edge) { var edge = (Edge)SelectedElement.GetGeometryObjectFromReference(_reference); curve = edge.AsCurve(); } else { curve = (Curve)SelectedElement.GetGeometryObjectFromReference(_reference); } if (curve != null) { if (_init) { thisXYZ = curve.Evaluate(_param0, true); } else { XYZ curPoint = _reference.GlobalPoint; if (thisTrf != null) { Autodesk.Revit.DB.Transform inverseTrf = thisTrf.Inverse; curPoint = inverseTrf.OfPoint(_reference.GlobalPoint); } IntersectionResult thisResult = curve.Project(curPoint); _param0 = curve.ComputeNormalizedParameter(thisResult.Parameter); _init = true; } thisXYZ = curve.Evaluate(_param0, true); _param1 = -1.0; } else { throw new Exception("could not evaluate point on face or edge of the element"); } if (thisTrf != null) { thisXYZ = thisTrf.OfPoint(thisXYZ); } } else { throw new Exception("could not evaluate point on face or edge of the element"); } old_refXyz = _reference; return(Value.NewContainer(thisXYZ)); }
private void CollectRoomsInfo(List <Room> roomList, Autodesk.Revit.DB.Transform roomTransform) { try { foreach (Room room in roomList) { if (room.Area == 0) { continue; } RoomProperties rp = new RoomProperties(room); rp.GetRoomGeometry(roomTransform); StringBuilder strBuilder = new StringBuilder(); var mass3dFound = from mass in massList where mass.HostType == SourceType.Rooms && mass.HostUniqueId == rp.RoomUniqueId && mass.MassElementType == MassType.MASS3D select mass; if (mass3dFound.Count() > 0) { MassProperties mp = mass3dFound.First(); rp.Linked3dMass = mp; rp.Linked3d = true; rp.UserHeight = mp.MassHeight; strBuilder.AppendLine("Mass 3D Id: " + mp.MassId); if (null != mp.MassSolid) { if (!rp.RoomSolidCentroid.IsAlmostEqualTo(mp.HostSolidCentroid)) { rp.ModifiedHost = true; strBuilder.Append(" (the room has been modified)"); } } } var mass2dFound = from mass in massList where mass.HostType == SourceType.Rooms && mass.HostUniqueId == rp.RoomUniqueId && mass.MassElementType == MassType.MASS2D select mass; if (mass2dFound.Count() > 0) { MassProperties mp = mass2dFound.First(); rp.Linked2dMass = mp; rp.Linked2d = true; strBuilder.AppendLine("Mass 2D Id: " + mp.MassId); if (null != mp.MassSolid) { if (!rp.RoomSolidCentroid.IsAlmostEqualTo(mp.HostSolidCentroid)) { rp.ModifiedHost = true; strBuilder.Append(" (the room has been modified)"); } } } if (strBuilder.Length > 0) { rp.ToolTip = strBuilder.ToString(); } if (!roomDictionary.ContainsKey(rp.RoomUniqueId)) { roomDictionary.Add(rp.RoomUniqueId, rp); } } } catch (Exception ex) { MessageBox.Show("Failed to collect rooms Information.\n" + ex.Message, "Collect Rooms Information", MessageBoxButton.OK, MessageBoxImage.Warning); } }
public static Transform ToTransform(this DB.Transform value) { var rhino = RawDecoder.AsTransform(value); UnitConverter.Scale(ref rhino, UnitConverter.ToRhinoUnits); return(rhino); }
public JObject ConvertToDTO(Autodesk.Revit.DB.FamilyInstance source) { Autodesk.Revit.DB.FamilySymbol fam = source.Symbol; BoundingBoxXYZ bb = source.get_BoundingBox(null); Autodesk.Revit.DB.Transform trans = source.GetTransform(); var info = source.GetOrderedParameters().Where(p => p.Definition.ParameterGroup == BuiltInParameterGroup.PG_GEOMETRY); Dictionary <string, string> infoDict = new Dictionary <string, string>(); foreach (var i in info) { infoDict[i.Definition.Name] = i.AsValueString(); } int geometryHash = JsonConvert.SerializeObject(infoDict).GetHashCode(); LMAStudio.StreamVR.Common.Models.FamilyInstance dest = new LMAStudio.StreamVR.Common.Models.FamilyInstance { Id = source.Id.ToString(), Name = source.Name, HostId = source.Host?.Id.ToString(), FamilyId = fam.Id.ToString(), VariantId = geometryHash.ToString(), SubComponents = source.GetSubComponentIds().Select(e => e.ToString()), SuperComponent = source.SuperComponent?.Id.ToString(), //BoundingBoxMin = new LMAStudio.StreamVR.Common.Models.XYZ //{ // X = bb?.Min.X ?? 0, // Y = bb?.Min.Y ?? 0, // Z = bb?.Min.Z ?? 0, //}, //BoundingBoxMax = new LMAStudio.StreamVR.Common.Models.XYZ //{ // X = bb?.Max.X ?? 0, // Y = bb?.Max.Y ?? 0, // Z = bb?.Max.Z ?? 0, //}, IsFlipped = source.FacingFlipped, FacingOrientation = new LMAStudio.StreamVR.Common.Models.XYZ { X = source.FacingOrientation.X, Y = source.FacingOrientation.Y, Z = source.FacingOrientation.Z, }, IsHandFlipped = source.HandFlipped, HandOrientation = new LMAStudio.StreamVR.Common.Models.XYZ { X = source.HandOrientation.X, Y = source.HandOrientation.Y, Z = source.HandOrientation.Z, }, Transform = new LMAStudio.StreamVR.Common.Models.Transform { Scale = trans.Scale, Origin = new LMAStudio.StreamVR.Common.Models.XYZ { X = trans.Origin.X, Y = trans.Origin.Y, Z = trans.Origin.Z, }, BasisX = new LMAStudio.StreamVR.Common.Models.XYZ { X = trans.BasisX.X, Y = trans.BasisX.Y, Z = trans.BasisX.Z, }, BasisY = new LMAStudio.StreamVR.Common.Models.XYZ { X = trans.BasisY.X, Y = trans.BasisY.Y, Z = trans.BasisY.Z, }, BasisZ = new LMAStudio.StreamVR.Common.Models.XYZ { X = trans.BasisZ.X, Y = trans.BasisZ.Y, Z = trans.BasisZ.Z, }, } }; return(JObject.FromObject(dest)); }
private void CollectFloorsInfo(List <Floor> floorList, Autodesk.Revit.DB.Transform floorTransform) { try { foreach (Floor floor in floorList) { FloorProperties fp = new FloorProperties(floor); fp.GetFloorGeometry(floorTransform); StringBuilder strBuilder = new StringBuilder(); var mass3dFound = from mass in massList where mass.HostType == SourceType.Floors && mass.HostUniqueId == fp.FloorUniqueId && mass.MassElementType == MassType.MASS3D select mass; if (mass3dFound.Count() > 0) { MassProperties mp = mass3dFound.First(); fp.Linked3dMass = mp; fp.Linked3d = true; fp.UserHeight = mp.MassHeight; strBuilder.AppendLine("Mass 3D Id: " + mp.MassId); if (null != mp.MassSolid) { if (!fp.FloorSolidCentroid.IsAlmostEqualTo(mp.HostSolidCentroid)) { fp.ModifiedHost = true; strBuilder.Append(" (the floor has been modified)"); } } } var mass2dFound = from mass in massList where mass.HostType == SourceType.Floors && mass.HostUniqueId == fp.FloorUniqueId && mass.MassElementType == MassType.MASS2D select mass; if (mass2dFound.Count() > 0) { MassProperties mp = mass2dFound.First(); fp.Linked2dMass = mp; fp.Linked2d = true; strBuilder.AppendLine("Mass 2D Id: " + mp.MassId); if (null != mp.MassSolid) { if (!fp.FloorSolidCentroid.IsAlmostEqualTo(mp.HostSolidCentroid)) { fp.ModifiedHost = true; strBuilder.Append(" (the floor has been modified)"); } } } if (strBuilder.Length > 0) { fp.ToolTip = strBuilder.ToString(); } if (!floorDictionary.ContainsKey(fp.FloorUniqueId)) { floorDictionary.Add(fp.FloorUniqueId, fp); } } } catch (Exception ex) { MessageBox.Show("Failed to collect floors Information.\n" + ex.Message, "Collect Floors Information", MessageBoxButton.OK, MessageBoxImage.Warning); } }