70001252 Ask user to change active viewport in MultiView

Article 70001252
Type HowTo
Product Engine
Version 7
Date Added 1/8/2018
Fixed 7.7014.0.5 (1/8/2018)
Submitted by Wayne Romer

Summary

How can I ask the user to change the active viewport in a MultiView Layout?

Solution

With a single click on a inactive viewport, the user can make it active. By code you can do this using ActiveLayout’s ActiveViewport property (get/set) so you can get which viewport is active also. Check the following ccode:

private void Form1_Load(object sender, EventArgs e)
{ // where doc = vdFramedControl.BaseControl.ActiveDocument
    doc.New();
    doc.Open(@"C:\test\test.vdcl"); // this is a drawing that contains a multiview layout
}

private void button1_Click(object sender, EventArgs e)
{
    bool changed = false;
    while (changed == false) // Loop until the user changes the viewport
    {
        vdViewport current = doc.ActiveLayOut.ActiveViewPort;
        if (current == null) return; // null means that MODEL or PAPERLAYOUT is active,
                                   // and that no viewport is active
        vdFramedControl.BaseControl.SetCustomMousePointer(Cursors.Default); 
        doc.Prompt("\r\nSelect Viewport:");
        object pt = doc.ActionUtility.getUserPoint();
        if (doc.ActiveLayOut.ActiveViewPort!=null && doc.ActiveLayOut.ActiveViewPort != current)
        {
            changed = true;
            vdFramedControl.BaseControl.SetCustomMousePointer(null);
            doc.Prompt("\r\nActive Viewport of Multiview changed");
            doc.Prompt(null);
        }
        else { changed = false; MessageBox.Show("didn't change"); }
    }
}

Send comments on this topic.