Well, It might be coincidence, but I renewed our Autodesk licenses this morning, and I had to change my Product Collection into a Design Suite that we still had. But I only need Inventor, so...
A few months back @Anonymous had this code snippet for me, which worked beautifully, but now I get these errors:
Anyone could have a look what might be the problem? I use this rule daily, so it is kind of important to me. Many Thanks!
Imports System.IO GetInput : Six_Digit = InputBox("Enter 6 Digit number", "iLogic", 000000) If Six_Digit = "" Then Return Else If Len(Six_Digit) <> "6" Then MessageBox.Show("Input must be 6 digits", "ilogic") GoTo GetInput End If Dim oDoc As Document Dim sFilename As String 'hard code path oLibrary_Folder = "U:\Johan\PTN_Part_Library\" Dim oFilenames() As String oFilenames = System.IO.Directory.GetFiles(oLibrary_Folder, _ "*.*", SearchOption.AllDirectories) For Each oFilename As String In oFilenames If oFilename.Contains(Six_Digit) Then Dim oOptions As Inventor.NameValueMap oOptions = ThisApplication.TransientObjects.CreateNameValueMap oDoc = ThisApplication.Documents.OpenWithOptions(oFilename, oOptions, False) sFilename = oFilename Exit For End If Next If sFilename = "" Then MessageBox.Show("No matching libary file found.", "iLogic") Return End If iCounter = 0 'path from current file oActiveAssemblyfolder = ThisDoc.Path & "\" 'path from current project file ( *.ipj) oProjectfolder = _ ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath & "\" Dim oProject_Filenames() As String oProject_Filenames = System.IO.Directory.GetFiles(oProjectfolder, _ "*.*", SearchOption.AllDirectories) 'count existing project files For Each oFilename As String In oProject_Filenames If oFilename.Contains(Six_Digit) Then iCounter = iCounter + 1 End If Next 'increment counter iCounter = iCounter + 1 'find the postion of the last backslash in the path FNamePos = InStrRev(sFilename, "\", - 1) 'get the file name with the file extension oName = Right(sFilename, Len(sFilename) - FNamePos) 'get the file name (without extension) ShortName = Left(oName, Len(oName) - 4) 'get extension oExt = Right(oName, 4) If iCounter < 10 Then iCounter = "00" + CStr(iCounter) ElseIf iCounter < 100 Then iCounter = "0" + CStr(iCounter) Else iCounter = CStr(iCounter) End If oNewName = ShortName & "_" & iCounter oPathandName = oActiveAssemblyfolder & oNewName & oExt 'save new document oDoc.SaveAs(oPathandName, True) oDoc.Close '[ Place Component Dim oAsmCompDef As AssemblyComponentDefinition oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition ' Create Matrix Dim oMatrix As Matrix oMatrix = ThisApplication.TransientGeometry.CreateMatrix Call oMatrix.SetTranslation(ThisApplication.TransientGeometry.CreateVector(50, 50, 50), True) 'insert new occurence Dim oOcc As ComponentOccurrence oOcc = oAsmCompDef.Occurrences.Add( _ oPathandName, oMatrix) oOcc.Grounded = False ThisDoc.Document.SelectSet.Select(oOcc) '] 'MessageBox.Show("New file created: " & vbLf & oPathandName, "iLogic")
Hi,
the harcode path may be a problem
use the server name or IP address instea like "Serverxyz" or 10.0.0.x
Regards,
Regards,
Arthur Knoors
Autodesk Affiliations & Links:
Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
Tip:
Put a few Messageboxes to take a look till where the code runs.
Please let me know at what line the code crashes.
Regards,
Regards,
Arthur Knoors
Autodesk Affiliations & Links:
Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
Well it is very wierd. After a rebuild all, it seems to work again... will try the messages boxes next time the issue pops up. Many Thanks
Good to hear that is working again.
Regards,
Arthur Knoors
Autodesk Affiliations & Links:
Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !