Message 1 of 3
Class Not Registered Error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I keep receiving a "Class Not Registered" error every time I try to run this code. I have searched around the forums, but have not been able to find any solutions.
' Initialize Inventor application Dim inventorApp As Inventor.Application inventorApp = ThisApplication ' Check if an assembly document is active If inventorApp.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then MsgBox("Please open an assembly document first.") Exit Sub End If ' Get the active assembly document Dim originalAssembly As AssemblyDocument originalAssembly = inventorApp.ActiveDocument ' Prompt the user for a new file name for the copied assembly Dim newFileName As String newFileName = InputBox("Enter a new file name for the copied assembly:", "Copy Assembly") ' Check if the user canceled the input If newFileName = "" Then Exit Sub End If ' List of components to be reused (replace with your own file names) Dim componentsToReuse As New List(Of String) componentsToReuse.Add("UHDL13.50CollarPhantom.iam") componentsToReuse.Add("907926.ipt") ' Save a copy of the assembly with the new file name originalAssembly.SaveAs(newFileName, True) ' Close the original assembly originalAssembly.Close(True) ' Open the copied assembly Dim copiedAssembly As AssemblyDocument copiedAssembly = inventorApp.Documents.Open(newFileName) ' Iterate through the components in the copied assembly and remove suppressed components For Each component As ComponentOccurrence In copiedAssembly.ComponentDefinition.Occurrences If Component.Suppressed Then Component.Delete2(True) ' Delete the suppressed component End If Next ' Iterate through the components in the copied assembly For Each component As ComponentOccurrence In copiedAssembly.ComponentDefinition.Occurrences Dim componentName As String componentName = Component.Name ' Check if the component should be reused or copied If componentsToReuse.Contains(componentName) Then ' Component should be reused ' You can add code here to update the position or configuration if needed Else ' Component should be copied ' You can add code here to copy the component or replace it with a new version ' For example, you can replace it with a different IPT file using the File.Copy function. End If Next ' Inform the user MsgBox("Assembly copied successfully with a new file name: " & newFileName)
in line 30