public View ViewToSpeckle(DB.View revitView) { switch (revitView.ViewType) { case ViewType.FloorPlan: break; case ViewType.CeilingPlan: break; case ViewType.Elevation: break; case ViewType.Section: break; case ViewType.ThreeD: break; default: break; } var speckleView = new View(); if (revitView is DB.View3D rv3d) { // some views have null origin, not sure why, but for now we just ignore them and don't bother the user if (rv3d.Origin == null) { return(null); } // get orientation var forward = rv3d.GetSavedOrientation().ForwardDirection; // this is unit vector var up = rv3d.GetSavedOrientation().UpDirection; // this is unit vector // get target var target = PointToSpeckle(CalculateTarget(rv3d, forward)); speckleView = new View3D { origin = PointToSpeckle(rv3d.Origin), forwardDirection = VectorToSpeckle(forward, Speckle.Core.Kits.Units.None), upDirection = VectorToSpeckle(up, Speckle.Core.Kits.Units.None), target = target, isOrthogonal = !rv3d.IsPerspective, boundingBox = BoxToSpeckle(rv3d.CropBox), name = revitView.Name }; // set props AttachViewParams(speckleView, rv3d); } GetAllRevitParamsAndIds(speckleView, revitView); //Report.Log($"Converted View {revitView.ViewType} {revitView.Id}"); return(speckleView); }
private void AttachViewParams(View speckleView, DB.View view) { // display speckleView["display"] = view.DisplayStyle.ToString(); // crop speckleView["cropped"] = view.CropBoxActive.ToString(); }
public View ViewToSpeckle(DB.View revitView) { switch (revitView.ViewType) { case ViewType.FloorPlan: break; case ViewType.CeilingPlan: break; case ViewType.Elevation: break; case ViewType.Section: break; case ViewType.ThreeD: break; default: break; } var speckleView = new View(); if (revitView is DB.View3D rv3d) { //some views have null origin, not sure why, but for now we just ignore them and don't bother the user if (rv3d.Origin == null) { return(null); } speckleView = new View3D { origin = PointToSpeckle(rv3d.Origin), forwardDirection = VectorToSpeckle(rv3d.ViewDirection), upDirection = VectorToSpeckle(rv3d.UpDirection), isOrthogonal = !rv3d.IsPerspective }; } speckleView.name = revitView.Name; GetAllRevitParamsAndIds(speckleView, revitView); return(speckleView); }
public View ViewToSpeckle(DB.View revitView) { switch (revitView.ViewType) { case ViewType.FloorPlan: break; case ViewType.CeilingPlan: break; case ViewType.Elevation: break; case ViewType.Section: break; case ViewType.ThreeD: break; default: break; } var speckleView = new View(); if (revitView is DB.View3D rv3d) { // some views have null origin, not sure why, but for now we just ignore them and don't bother the user if (rv3d.Origin == null) { return(null); } // get orientation var forward = rv3d.GetSavedOrientation().ForwardDirection; // this is unit vector var up = rv3d.GetSavedOrientation().UpDirection; // this is unit vector /* not accurate, will result in distorted camera axes if sent to rhino NOTE!! TRY USING THIS FOR ISO ONLY * // get target * var target = PointToSpeckle(CalculateTarget(rv3d, forward)); */ speckleView = new View3D { origin = PointToSpeckle(rv3d.Origin), forwardDirection = new Geometry.Vector(forward.X, forward.Y, forward.Z, "none"), upDirection = new Geometry.Vector(up.X, up.Y, up.Z, "none"), //target = target, isOrthogonal = !rv3d.IsPerspective, boundingBox = BoxToSpeckle(rv3d.CropBox) }; // set props AttachViewParams(speckleView, rv3d); } speckleView.name = revitView.Name; GetAllRevitParamsAndIds(speckleView, revitView); return(speckleView); }