Create a new assembly file with Apprentice

Create a new assembly file with Apprentice

Anonymous
Not applicable
1,284 Views
5 Replies
Message 1 of 6

Create a new assembly file with Apprentice

Anonymous
Not applicable

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

0 Likes
Accepted solutions (1)
1,285 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Accepted solution

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.

0 Likes
Message 3 of 6

Anonymous
Not applicable

Hi Gruff,

 

Thanks for the answer.

 

 

Pascal

0 Likes
Message 4 of 6

Anonymous
Not applicable

Hi Gruff, 

 

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

 

 

Pascal

0 Likes
Message 5 of 6

Anonymous
Not applicable

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.

0 Likes
Message 6 of 6

Anonymous
Not applicable

Thanks again.

 

 

Pascal

0 Likes