@mtrainottiGHXJH, Quick update,
1/ re: proof of concept HACK to track Saved Viewpoints selection via its docking pane:
My wrong. The "Saved ViewPoints" pane is not even registered as a DockPanePlugin.
However this approach can be used for the "Sets" pane to get an ObservableCollection of selected Sets.
I will post an example separately if you are interested.
2/ Now back to the "Saved ViewPoints" issue:
and specifically, when a SavedViewPoint is still selected in "Saved ViewPoints" pane BUT CurrentSavedViewpointChanged event is triggered and d.SavedViewpoints.CurrentSavedViewpoint return null.
Short term, I implemented a "hack" to handle such case by keeping "current" selected Saved VIew Point, and on such event, checking for unchanged Sectioning. Long term, I would like to rewrite our own Saved ViewPoints pane to replace the native one, that I guess is still a MFC or so remnant of old Navisworks
Here is an extract of my class that track changes in Selection Sets and Saved View point, to get you started:
//CRITICAL, clear on d.SavedViewpoints.Reset etc. to avoid keeping an dangling object.
protected SavedViewpoint pSelectedSavedViewPoint;
static private bool IsStillSameViewPoint(Document d, SavedViewpoint previous)
{
if (previous is null || previous.IsDisposed)
return false;
LcOaClipPlaneSet previous_cps = previous.Viewpoint.InternalClipPlanes;
LcOaClipPlaneSet current_cps = d.CurrentViewpoint.Value.InternalClipPlanes;
return current_cps.ValueEquals(previous_cps);
}
protected virtual void OnCurrentSavedViewpointChanged(object sender, EventArgs e)
{
//// on click single item, called twice, null for deselect then null if folder, SavedViewpoint if an actual viewpoint for select
//// on multiple items selected, seems just give the last one clicked not necessary the last one in the tree order?
//// we can't predict if we will get called twice so no choice
var d = sender as Document;
//// if no items selected, si is null
var si = d.SavedViewpoints.CurrentSavedViewpoint;
var svp = si as SavedViewpoint;
if (svp == pSelectedSavedViewPoint)
return;
if (si == null && pSelectedSavedViewPoint != null && IsStillSameViewPoint(d, pSelectedSavedViewPoint))
return;
var old = pSelectedSavedViewPoint;
pSelectedSavedViewPoint = svp;
OnSelectedSavedViewpointChanged(d, new SelecteSavedViewPointChangedEventArgs(old, svp));
}
protected virtual void OnSelectedSavedViewpointChanged(Document d, SelecteSavedViewPointChangedEventArgs e)
{ }
@Navisworks team, please consider reimplementing this "Saved ViewPoints" pane in C#, cleanly as a DockPanePlugin.
I'm so frustrated with the current pane unpredictable drag & drop that works like once at of 4 times I can't imagine how many screens and keyboard have been destroyed just because of this 🤣
So you will make not only developers happybut lots of users I guess.