I'm using Visual Studio Express 2010 and Apprentice to print lots of idw files and sheets to pdf format. But sometimes I saw wrong pictures because of need of update in drawings. How can I update drawign when necessary in VS2010 and Apprentice?
Regards,
Mucip:)
Solved! Go to Solution.
Solved by YuhanZhang. Go to Solution.
Apprentice is a light-weight tool to access Inventor data, which has limitations on writing to Inventor data, only document properties and references can be updated by Apprentice. So for the case if the drawing needs to be updated 'cause of model document change, you need to update it in Inventor.
Dear Rocky ZHAN,
Thanks. I tred to update within VS2010 Express (not using Apprentice) But this time I did not update too?! I must write code in inventor and VBA? I could not get result below code in VS2010 Express... ?!
Dim inventorApp As Inventor.Application
inventorApp = GetObject(, "Inventor.Application")
inventorApp.Documents.Open("c:\atest.idw", True)
Dim oDoc As Inventor.DrawingDocument
oDoc = inventorApp.ActiveDocument
If oDoc.RequiresUpdate Then
MsgBox(Updating...")
oDoc.Update()
End If
oDoc.Save2(True)
oDoc.Close()
Hope below sample code snippet can help:
Dim m_inventorApp As Inventor.Application = Nothing ' Try to get an active instance of Inventor Try m_inventorApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application") Catch ex As Exception End Try ' If not active, create a new Inventor session If m_inventorApp Is Nothing Then Dim inventorAppType As Type = System.Type.GetTypeFromProgID("Inventor.Application") m_inventorApp = System.Activator.CreateInstance(inventorAppType) End If Dim m_doc As Inventor.PartDocument m_doc = m_inventorApp.ActiveDocument If m_doc.RequiresUpdate Then m_doc.Update() m_doc.Save() End If
Hi,
I redesign my code according to yours. But when I run the code inventor opens the idw file and appear message "The drawing reflects their current state. xxx.iam". Is there any way to update drawing within code. I do not want to see this message because I must update 20-50 idw files to update. Otherwise I must wait in front of the computer and waiting for teh assembly update message??...
******
Try
inventorApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")
inventorApp.Documents.Open("c:\test.idw", True)
Catch ex As Exception
Try
Dim inventorAppType As Type = System.Type.GetTypeFromProgID("Inventor.Application")
inventorApp = System.Activator.CreateInstance(inventorAppType)
inventorApp.Visible = True
inventorApp.Documents.Open("c:\test.idw", True)
Catch ex1 As Exception
MsgBox("Inventor could not start!")
Exit Sub
End Try
End Try
Dim oDoc As Inventor.DrawingDocument
oDoc = inventorApp.ActiveDocument
Dim oSheet As Inventor.Sheet
oSheet = oDoc.Sheets(1)
oDoc.Update()
oDoc.Save()
******
Reagrds,
Mucip:)
I am not quite sure about what the dialog means. However you can suppress Inventor dialogs with setting the SilentOperation as below:
inventorApp.SilentOperation = True
You may remember to re-set it to False at last.
Hi,
Yes.. Thanks. This message prevents dialog messages in inventor when I open the idw files...
Buy the way I could not use below code still. Error messages comes:
Dim oDoc As Inventor.DrawingDocument
oDoc = inventorApp.ActiveDocument
Dim oSheet As Inventor.Sheet
oSheet = oDoc.Sheets(1)
If oDoc.RequiresUpdate Then
oDoc.Update()
oDoc.Save()
End If
Error "NotImplementedException was unhandled". And the error message sign "If oDoc.RequiresUpdate Then" line?!...
But if I remove the if-endif block and update and save all files than no problem... I think I will use update and save command without requiresupdate parameter...
Thanks,
Mucip:)