Invalid Cast Exception Error When Running VB Code

Invalid Cast Exception Error When Running VB Code

Anonymous
Not applicable
647 Views
2 Replies
Message 1 of 3

Invalid Cast Exception Error When Running VB Code

Anonymous
Not applicable

Using VB2010 Express to practice writing code to run things in Inventor 2012.  I am an extreme beginner at this, and I am trying out a simple program that opens up Inventor, and when you click a button, it will open up the filename listed in the subroutine.  I have attached a .jpg of my code.  The program will open Inventor, and open the file, but as soon as the file is finished loading and displays on the screen, it throws the error you see in the .jpg.  Any clues as to what I'm doing wrong?

0 Likes
Accepted solutions (1)
648 Views
2 Replies
Replies (2)
Message 2 of 3

ekinsb
Alumni
Alumni
Accepted solution

You've typed the variable to be a PartDocument but you're opening an assembly.  That's what it's complaining about.  The Open call is succeeding but then when it tries to assign the opened document to your variable it's failing.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 3 of 3

Anonymous
Not applicable

Oh geez, that was staring me right in the face  🙂

 

Huge thanks!!

0 Likes