Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Error accessing Inventor.DrawingDocument files

1 REPLY 1
Reply
Message 1 of 2
dkimbrell
485 Views, 1 Reply

Error accessing Inventor.DrawingDocument files

I am attempting to use Apprentice via Visual Basic (in Visual Studio) to access the Revision Code property for a series of drawings in Inventor 2009.

 

I can open an idw file via Apprentice, but then when I subsequently try to retrieve properties of the file (via its variable AppDwgDoc), I get an error "Object reference not set to an instance of an object".  When I debug for more info, it says that AppDwgDoc is a "System._com" object.  (As a side note, I've even tried to write this code in native VB, not using Apprentice modules, and I get the same error!)

 

Am I missing references, or is this a permissions thing, I tried everything I can think of with regard to these and other theories of what the problem is here.

 

Been on this for 2 days, please help!!

 

Here are the relevant lines of code:

       

---------------------------------------------------------------------------------------

Dim invApprentice As New Inventor.ApprenticeServerComponent    <<<This opens inventor successfully.  I can see it in the task manager after running this line.

Dim AppDwgDoc As Inventor.ApprenticeServerDocument

AppDwgDoc = invApprentice.Open(InventorFilename)  <<<This sets AppDwgDoc to a System._Com object

Debug.Print(AppDwgDoc.FullFileName)  <<<THIS IS WHERE I GET THE ERROR "null reference exception was unhandled:  Object reference is not set to an instance of an object"

 

-------------------------------------------

Here is the detailed debugging error information:

System.NullReferenceException was unhandled   Message=Object reference not set to an instance of an object.   Source=mscorlib   StackTrace:        at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)        at Inventor.ApprenticeServerDocument.get_FullFileName()        at InventorIPropRevDWGUpdate.ApprenticeINV_Date.UpdateProperties(String InventorFilename) in C:\FFR_Testing\ApprenticeSampleModelRevDar\ApprenticeSample.vb:line 58        at InventorIPropRevDWGUpdate.ApprenticeINV_Date.btnProcess_Click(Object sender, EventArgs e) in C:\FFR_Testing\ApprenticeSampleModelRevDar\ApprenticeSample.vb:line 19        at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)        at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)        at System.Windows.Forms.Control.WndProc(Message& m)        at System.Windows.Forms.ButtonBase.WndProc(Message& m)        at System.Windows.Forms.Button.WndProc(Message& m)        at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)        at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)        at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)        at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)        at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)        at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()        at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()        at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)        at InventorIPropRevDWGUpdate.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81        at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)        at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)        at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()        at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)        at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)        at System.Threading.ThreadHelper.ThreadStart()   InnerException:

1 REPLY 1
Message 2 of 2

Do you get this error for any file or for the specific file only?

Are you able to open programmatically this file in Inventor ?


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report