Skip to content

Commit

Permalink
feat(rhino): open comments in 3D view (#1851)
Browse files Browse the repository at this point in the history
* Null check for viewPhase in Rhino

* Implement open comments view to Rhino

* Control existence of views to prevent duplications
  • Loading branch information
oguzhankoral authored Nov 14, 2022
1 parent 07992c7 commit 092b617
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,10 @@ await RevitTask.RunAsync(app =>
if (views.Any())
{
var viewPhase = views.First().get_Parameter(BuiltInParameter.VIEW_PHASE);
perspView.get_Parameter(BuiltInParameter.VIEW_PHASE).Set(viewPhase.AsElementId());
if (viewPhase != null)
{
perspView.get_Parameter(BuiltInParameter.VIEW_PHASE).Set(viewPhase.AsElementId());
}
}

t.Commit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1150,5 +1150,40 @@ public override List<MenuItem> GetCustomStreamMenuItems()

#endregion

public override bool CanOpen3DView => true;

public override async Task Open3DView(List<double> viewCoordinates, string viewName = "")
{
// Create positional objects for camera
Point3d cameraLocation = new Point3d(viewCoordinates[0], viewCoordinates[1], viewCoordinates[2]);
Point3d target = new Point3d(viewCoordinates[3], viewCoordinates[4], viewCoordinates[5]);
Vector3d direction = target - cameraLocation;

if (!Doc.Views.Any(v => v.ActiveViewport.Name == "SpeckleCommentView"))
{
// Get bounds from active view
Rectangle bounds = Doc.Views.ActiveView.ScreenRectangle;
Doc.Views.Add("SpeckleCommentView", DefinedViewportProjection.Perspective, bounds, false);
}

await Task.Run(() =>
{
IEnumerable<RhinoView> views = Doc.Views.Where(v => v.ActiveViewport.Name == "SpeckleCommentView");
if (views.Any())
{
RhinoView speckleCommentView = views.First();
speckleCommentView.ActiveViewport.SetCameraDirection(direction, false);
speckleCommentView.ActiveViewport.SetCameraLocation(cameraLocation, true);
speckleCommentView.Maximized = true;

if (Doc.Views.ActiveView.ActiveViewport.Name != "SpeckleCommentView")
{
Doc.Views.ActiveView = speckleCommentView;
}
}

Doc.Views.Redraw();
});
}
}
}

0 comments on commit 092b617

Please sign in to comment.