Moniker Can't Open File 0x800401EA ( Inventor.Application ClientView)

0

i'm trying to run this old example code i found on the internet basically this code is for implementing the Inventor ClientView in Windows Form so i can see the .ipt drawing in my windows form program. the problem i found is when i try to compile the code it shows me:

COMException wan unhandled

An unhandled exception of type 'System.Runtime.InteropServices.COMException' >occurred in mscorlib.dll

Additional information: Moniker cannot open file (Exception from HRESULT: >0x800401EA (MK_E_CANTOPENFILE))

i hope you guys can help me so i can learn the code and continue with my project

thx

Faiz

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Inventor;

namespace ClientView
{
public partial class Form1 : Form
{
    Inventor.ApprenticeServerComponent oSvr = new Inventor.ApprenticeServerComponent();
    Inventor.ApprenticeServerDocument oAppDoc;
    Inventor.ClientView oClientView;
    bool buttonDown = false;
    Inventor.Point2d lastPosition = null;

    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        string fileName = @"C:\Users\Klaxonsdept\Documents\InventorEbeneübung.ipt";
        oAppDoc = oSvr.Open(fileName);
        oClientView = oAppDoc.ClientViews.Add(pictureBox1.Handle.ToInt32());
    }

    private void button1_Click(object sender, EventArgs e)
    {
        Inventor.Camera oCamera = oClientView.Camera;
        oCamera.ViewOrientationType = Inventor.ViewOrientationTypeEnum.kIsoTopRightViewOrientation;
        oCamera.Perspective = true;
        oCamera.Apply();
        oClientView.Update(false);
    }

    private void pictureBox1_Click(object sender, EventArgs e)
    {
    }

    private void Form1_Paint(object sender, PaintEventArgs e)
    {
        oClientView.Update(false);
    }

    private void PictureBox1_MouseDown(object sender, MouseEventArgs e)
    {
        buttonDown = true;
    }

    private void PictureBox1_MouseUp(object sender, MouseEventArgs e)
    {
        buttonDown = false;
        lastPosition = null;
    }

    private void PictureBox1_MouseMove(object sender, MouseEventArgs e)
    {
        if (buttonDown)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                if (lastPosition == null)
                    lastPosition = oSvr.TransientGeometry.CreatePoint2d(e.X, e.Y);
                else
                {
                    Inventor.Camera oCamera = oClientView.Camera;
                    Inventor.Point2d newPoint = oSvr.TransientGeometry.CreatePoint2d(e.X, e.Y);
                    oCamera.ComputeWithMouseInput(lastPosition, newPoint, 0, Inventor.ViewOperationTypeEnum.kRotateViewOperation);
                    oCamera.Apply();
                    oClientView.Update(false);
                    lastPosition = newPoint;
                }
            }
            else if (e.Button == System.Windows.Forms.MouseButtons.Middle)
            {
                if (lastPosition == null)
                    lastPosition = oSvr.TransientGeometry.CreatePoint2d(e.X, e.Y);
                else
                {
                    Inventor.Camera oCamera = oClientView.Camera;
                    Inventor.Point2d newPoint = oSvr.TransientGeometry.CreatePoint2d(e.X, e.Y);
                    oCamera.ComputeWithMouseInput(lastPosition, newPoint, 0, Inventor.ViewOperationTypeEnum.kPanViewOperation);
                    oCamera.Apply();
                    oClientView.Update(false);
                    lastPosition = newPoint;
                }
            }
            else if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                if (lastPosition == null)
                    lastPosition = oSvr.TransientGeometry.CreatePoint2d(e.X, e.Y);
                else
                {
                    Inventor.Camera oCamera = oClientView.Camera;
                    Inventor.Point2d newPoint = oSvr.TransientGeometry.CreatePoint2d(e.X, e.Y);
                    oCamera.ComputeWithMouseInput(lastPosition, newPoint, 0, Inventor.ViewOperationTypeEnum.kZoomViewOperation);
                    oCamera.Apply();
                    oClientView.Update(false);
                    lastPosition = newPoint;
                }
            }
        }
    }

}

}

c#
autodesk-inventor
asked on Stack Overflow Apr 22, 2018 by Faiz Daud

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0