Community
Vault Customization
Share your knowledge, ask questions, and explore popular Vault API, Data Standard, and VBA topics related to programming, creating add-ins, or working with the Vault API.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Upgrade to 2025 ilogic

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
johan.degreef
350 Views, 3 Replies

Upgrade to 2025 ilogic

johan.degreef
Advisor
Advisor

Since our upgrade to 2025, this macro won't run anymore. Can anyone hep me to find what needs to be modified? Many Thanks

 

Screenshot_5.jpg

 

 

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 = "C:\$WorkingFolder\Documents\Standards\PTN_PART_LIBRARY\"

Dim oFilenames() As String
oFilenames = System.IO.Directory.GetFiles(oLibrary_Folder, _
"*.*", SearchOption.AllDirectories)

For Each oFilename As String In oFilenames
            Dim oFileNameNoExt As String = System.IO.Path.GetFileNameWithoutExtension(oFilename)
            If oFileNameNoExt.Contains(Six_Digit) AndAlso oFileNameNoExt.Length = 11 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

'path from current file
Dim oActiveAssemblyfolder As String = ThisDoc.Path & "\"




'find the postion of the last backslash in the path
Dim FNamePos As Integer = InStrRev(sFilename, "\", -1)
'get the file name with the file extension
Dim oName As String = Right(sFilename, Len(sFilename) -FNamePos)
'get the file name (without extension)
Dim ShortName As String = Left(oName, Len(oName) -4)
'get extension
Dim oExt As String = Right(oName, 4)


Dim oNewName As String = ShortName & "_" & System.DateTime.Now.ToString("yyyyMdHHmmss")

Dim oPathandName As String = oActiveAssemblyfolder & oNewName & oExt

oDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value = ShortName
'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)

ThisApplication.CommandManager.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent, oPathandName)
ThisApplication.CommandManager.ControlDefinitions.Item("AssemblyPlaceComponentCmd").Execute


'oOcc.Grounded = False
'ThisDoc.Document.SelectSet.Select(oOcc)

']

'MessageBox.Show("New file created: " & vbLf & oPathandName, "iLogic")

 

 

Inventor 2025, Vault Professional 2025, Autocad Plant 3D 2025
0 Likes

Upgrade to 2025 ilogic

Since our upgrade to 2025, this macro won't run anymore. Can anyone hep me to find what needs to be modified? Many Thanks

 

Screenshot_5.jpg

 

 

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 = "C:\$WorkingFolder\Documents\Standards\PTN_PART_LIBRARY\"

Dim oFilenames() As String
oFilenames = System.IO.Directory.GetFiles(oLibrary_Folder, _
"*.*", SearchOption.AllDirectories)

For Each oFilename As String In oFilenames
            Dim oFileNameNoExt As String = System.IO.Path.GetFileNameWithoutExtension(oFilename)
            If oFileNameNoExt.Contains(Six_Digit) AndAlso oFileNameNoExt.Length = 11 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

'path from current file
Dim oActiveAssemblyfolder As String = ThisDoc.Path & "\"




'find the postion of the last backslash in the path
Dim FNamePos As Integer = InStrRev(sFilename, "\", -1)
'get the file name with the file extension
Dim oName As String = Right(sFilename, Len(sFilename) -FNamePos)
'get the file name (without extension)
Dim ShortName As String = Left(oName, Len(oName) -4)
'get extension
Dim oExt As String = Right(oName, 4)


Dim oNewName As String = ShortName & "_" & System.DateTime.Now.ToString("yyyyMdHHmmss")

Dim oPathandName As String = oActiveAssemblyfolder & oNewName & oExt

oDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value = ShortName
'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)

ThisApplication.CommandManager.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent, oPathandName)
ThisApplication.CommandManager.ControlDefinitions.Item("AssemblyPlaceComponentCmd").Execute


'oOcc.Grounded = False
'ThisDoc.Document.SelectSet.Select(oOcc)

']

'MessageBox.Show("New file created: " & vbLf & oPathandName, "iLogic")

 

 

Inventor 2025, Vault Professional 2025, Autocad Plant 3D 2025
3 REPLIES 3
Message 2 of 4

Markus.Koechl
Autodesk
Autodesk

Hi @johan.degreef, This looks like a post targeting Inventor Customization. Anyway, in Inventor 2025, you need to declare all variables with types. This change relates to the move of the Inventor API to the .NET Core platform. This move also impacts Vault and I published detailed information in our Vault Blog: Autodesk Vault 2025 SDK - Breaking News - Under the Hood - All things PDM and PLM



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes

Hi @johan.degreef, This looks like a post targeting Inventor Customization. Anyway, in Inventor 2025, you need to declare all variables with types. This change relates to the move of the Inventor API to the .NET Core platform. This move also impacts Vault and I published detailed information in our Vault Blog: Autodesk Vault 2025 SDK - Breaking News - Under the Hood - All things PDM and PLM



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
Message 3 of 4

johan.degreef
Advisor
Advisor

That I have overlooked and installed 2025. 😞

I am no programmer, so I hope it will be an easy fix (???)

Inventor 2025, Vault Professional 2025, Autocad Plant 3D 2025
0 Likes

That I have overlooked and installed 2025. 😞

I am no programmer, so I hope it will be an easy fix (???)

Inventor 2025, Vault Professional 2025, Autocad Plant 3D 2025
Message 4 of 4

Markus.Koechl
Autodesk
Autodesk
Accepted solution

The fix is on your side; I did not check your full code but quickly saw that "Six_Digit" or "oLibrary_Folder are not declared as String. But again - please consult the Inventor forum for more details on iLogic 2025 coding.



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes

The fix is on your side; I did not check your full code but quickly saw that "Six_Digit" or "oLibrary_Folder are not declared as String. But again - please consult the Inventor forum for more details on iLogic 2025 coding.



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe

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

Post to forums  

Autodesk Design & Make Report