Message 1 of 11
implementing Apprentice ClientView in c#
Not applicable
05-16-2012
12:30 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to implement the Apprentice ClientView example in the Inventor API help file. The code is given in Basic and I am using C# and I'm running into some problems. I think the issue is in the Form1_Load procedure in the line that sets the oClientView variable. I wasn't sure how to convert this to C#. Note that the original Basic code is in comments below the C# code. When I run the program the oClientView.Camera object throws an exception.
public partial class Form1 : Form
{
ApprenticeServerComponent oSvr = new ApprenticeServerComponent();
ApprenticeServerDocument oAppDoc;
ClientView oClientView;
public Form1()
{
InitializeComponent();
}
private void pictureBox1_Click(object sender, EventArgs e)
{
Camera oCamera = oClientView.Camera;
oCamera.ViewOrientationType = ViewOrientationTypeEnum.kIsoBottomLeftViewOrientation;
oCamera.Perspective = true;
oCamera.Apply();
this.Refresh();
//Dim oCamera As Camera
//Set oCamera = oClientView.Camera
//oCamera.ViewOrientationType = kIsoBottomLeftViewOrientation
//oCamera.Perspective = True
//oCamera.Apply
//Me.Refresh
}
private void Form1_Load(object sender, EventArgs e)
{
string fileName = @"C:\Vault Workspace\Designs\Main\Blades\SB4000\Parts SBCT - 001-040.idw";
ApprenticeServerComponent oSvr = new ApprenticeServerComponent();
oAppDoc = oSvr.Open(fileName);
oClientView = oAppDoc.ClientViews.Add(pictureBox1.Handle.ToInt32());
//Dim filename As String
//filename = "C:\Autodesk\Inventor 10\Tutorial Files\analyze-2.iam"
//Set oSvr = New ApprenticeServerComponent
//Set oAppDoc = oSvr.Open(filename)
//Set oClientView = oAppDoc.ClientViews.Add(Picture1.hWnd)
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
oClientView.Update(false);
}
