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: 

How can I update drawing via Apprentice using VB.NET 2010?

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
mucip
1695 Views, 6 Replies

How can I update drawing via Apprentice using VB.NET 2010?

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:)

6 REPLIES 6
Message 2 of 7
YuhanZhang
in reply to: mucip

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.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 3 of 7
mucip
in reply to: YuhanZhang

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()

Message 4 of 7
YuhanZhang
in reply to: mucip

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

 

 



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 5 of 7
mucip
in reply to: YuhanZhang

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:)

Message 6 of 7
YuhanZhang
in reply to: 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.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 7 of 7
mucip
in reply to: YuhanZhang

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:)

 

 

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

Post to forums  

Autodesk Design & Make Report