Message 1 of 6

Not applicable
03-14-2011
06:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
Solved! Go to Solution.