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: 

Create a new assembly file with Apprentice

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
planglais75
1131 Views, 5 Replies

Create a new assembly file with Apprentice

Hi,

 

I use VB.NET and Apprentice to create a new assembly file from a template.

 

Is it possible to add part file to assembly?

 

This code works good without apprentice (and some changes) but the ComponentDefinition.Occurrences.Add method give me an NotImplementedException with Apprentice

 

 

Private _ApprenticeServerComp As New Inventor.ApprenticeServerComponent
Private _ApprenticeDoc As Inventor.ApprenticeServerDocument
Private _TemplateAssemblyFile As String = "C:\Users\Public\Documents\Autodesk\Inventor 2011\Templates\Standard.iam"
  
Private Sub butApprenticeCreateDoc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
 Handles butApprenticeCreateDoc.Click
  Dim filename As String = "C:\apprenticeDoc.iam"
        'Delete old file
 If IO.File.Exists(filename) Then IO.File.Delete(filename)
        'Copy template
        IO.File.Copy(Me._TemplateAssemblyFile, filename)
        'Open assembly file
        Me._ApprenticeDoc = Me._ApprenticeServerComp.Open(filename)
End Sub
Private Sub butApprenticeAddPart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
 Handles butApprenticeAddPart.Click
 'Select a part file
        Dim fileDialog As New Windows.Forms.OpenFileDialog
        fileDialog.ShowDialog(Me)
 'Add part file to assembly file
 if fileDialog.FileName <> "" Then
         Dim matrix As Matrix = Me._ApprenticeServerComp.TransientGeometry.CreateMatrix
         Me._ApprenticeDoc.ComponentDefinition.Occurrences.Add(fileDialog.FileName, matrix)
         matrix = Nothing
 End If
End Sub

 

 

 

Thanks for help.

 

Pascal

5 REPLIES 5
Message 2 of 6
Gruff
in reply to: planglais75

Unless something has changed dramatically with 2012, Apprentice will not do what you want to do.

 

Apprentice has the ability to manipulate a very small sub set of the full Inventor API.

Adding parts to assemblies is not one of them.

 

Apprentice is limited to simple things like Printing Drawings, Manipulating iProperties or repointing existing assembly references to new locations.  Not sure there is much beyond that.

Message 3 of 6
planglais75
in reply to: Gruff

Hi Gruff,

 

Thanks for the answer.

 

 

Pascal

Message 4 of 6
planglais75
in reply to: Gruff

Hi Gruff, 

 

Is it possible to create an assembly file without opening Inventor?

 

 

Pascal

Message 5 of 6
Gruff
in reply to: planglais75

Not to my knowledge.

 

Typically if I want to maniplate inventor parts I write an application in Inventor VBA or as an Inventor Addin dll.

 

You can automate Inventor from VB.NET but it is:  a) Slow and b) you are removed from environment.  That is you have not control over or even know if a user changes something or shuts down inventor. 

 

If you are familiar wth automation in VB.NET you know you must also deal with Marshalling and manual garbage collection.

Message 6 of 6
planglais75
in reply to: Gruff

Thanks again.

 

 

Pascal

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

Post to forums  

Autodesk Design & Make Report