Windows 10 64 bit zoom current selection with .Net API is not working

Windows 10 64 bit zoom current selection with .Net API is not working

DHANANJAYKRPANDEYUZB9X
Contributor Contributor
998 Views
1 Reply
Message 1 of 2

Windows 10 64 bit zoom current selection with .Net API is not working

DHANANJAYKRPANDEYUZB9X
Contributor
Contributor

Hi Friends , 

I am trying to zoom on current selection in .NET application using Navisworks API , I used (

"https://adndevblog.typepad.com/aec/2012/05/how-to-zoom-in-current-view-on-current-selection-with-net..."

) this solution in plugin and it's working with windows 7 but not working with windows 10 

I want to use com api in .NET viewer control and select item and zoom it. 

Please help me resolve this issue.

0 Likes
Accepted solutions (1)
999 Views
1 Reply
Reply (1)
Message 2 of 2

DHANANJAYKRPANDEYUZB9X
Contributor
Contributor
Accepted solution

Friends I found solution,

In Stand alone application where Navisworks api viewer control 

Use below code to view model and zoom in current selection 

I used usercontrol for viewer.

private ViewControl viewControl;

 public partial class UcViewer : UserControl
    {
        private ViewControl viewControl;
        private DocumentControl documentControl;
        public UcViewer()
        {
            InitializeComponent();
            this.viewControl = new ViewControl();
            this.documentControl = new DocumentControl();
            this.viewControl.Dock = DockStyle.Fill;
            this.viewControl.DocumentControl = this.documentControl;
            this.viewControl.Location = new Point(0, 24);
            this.viewControl.Name = "viewControl";
            this.viewControl.Size = new Size(745, 496);
            this.viewControl.TabIndex = 1;
            this.viewControl.Text = "viewControl";
            this.Controls.Add(this.viewControl);
            documentControl.SetAsMainDocument();
        }
        //If the user has selected a valid location, then tell DocumentControl to open the file
        //As DocumentCtrl is linked to ViewControl //
        public void LoadDocument(string StrFileName)
        {
            try
            {
                documentControl.Document.TryOpenFile(StrFileName);
               
            }
            catch (Exception)
            {
                throw;
            }
        }
    }

 

//miModelItemColloection = Selected item [User can send one or multiple item]

public static void ZoomModelItem(ModelItemCollection miModelItemColloection)
        {
            try
            {
                // highlight the items
                Application.ActiveDocument.CurrentSelection.CopyFrom(miModelItemColloection);
                /*******************/
                //None mandatory code 
                //Just set view point 
                Document doc = Application.ActiveDocument;
                Viewpoint viewPointCopy = doc.CurrentViewpoint.CreateCopy();
                // point at adjusts the camera angle, you could also manually adjust this angle
                viewPointCopy.PointAt(miModelItemColloection.BoundingBox().Center);
                doc.CurrentViewpoint.CopyFrom(viewPointCopy);
                   /*******************/
                ComApi.InwOpState10 state = ComApiBridge.ComApiBridge.State;
                ComApi.InwOpSelection selection = ComApiBridge.ComApiBridge.ToInwOpSelection(miModelItemColloection);
                // Com API is used to zoom in on the model items, will only zoom does not adjust camera angle
                state.ZoomInCurViewOnSel(selection);
 

            }
            catch (Exception)
            {
                throw;
            }

        }
0 Likes