Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Error in iLogic

johan.degreef
Advisor

Error in iLogic

johan.degreef
Advisor
Advisor

All of the sudden this iLogic code gives an error. What i did: I did install Vsual studio to try to learn to code, and therefore I needed to install .net framework 4.8. That is what I have changed. I work on Inventor 2021. I guess it is since then then error pops up.

 

Knipsel.JPG

 

 

 

Imports System.IO
GetInput :

Dim Filename As String = "C:\Autodesk en Templates\PTN_Part_Library\New_PTN_Part_Library.xlsx"



Dim ExcelApp As Object
Dim opened As Boolean
Dim wb As Object
Dim Six_Digit As String

ExcelApp = GetObject(, "Excel.Application")
opened = False

For Each wb In ExcelApp.workbooks
	If UCase(wb.fullname) = UCase(Filename) Then
		opened = True
		Exit For
	End If
Next

If Not opened Then
	GoExcel.Open("C:\Autodesk en Templates\PTN_Part_Library\New_PTN_Part_Library.xlsx")
	'GoExcel.Open("C:\Users\ef\Desktop\New_PTN_Part_Library.xlsx")
End If

Six_Digit = ExcelApp.ActiveCell.Value

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:\Autodesk en Templates\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

 

 

Inventor 2025, Vault Professional 2025, Autocad Plant 3D 2025
0 Likes
Reply
1,408 Views
37 Replies
Replies (37)

bradeneuropeArthur
Mentor
Mentor

Step 1:

please start VBA.

with alt f11

Step 2:

Open a new part

save it on your desktop

then reply that you are ready

 

Regards,

Arthur Knoors

Autodesk Affiliations:

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: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 !

0 Likes

bradeneuropeArthur
Mentor
Mentor

step1

new part

save it to desktop

step 2

start VBA

with alt f11

 

reply ready

Regards,

Arthur Knoors

Autodesk Affiliations:

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: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 !

0 Likes

Ralf_Krieg
Advisor
Advisor

Hello

 

You said, that if you start Inventor as administrator the error disappeared. Can you confirm that Excel is not started elevated? Maybe it is activated in the link options in the compatibility tab.

If I start Excel as Administrator and Inventor as normal user, the error raises. The same behaviour if Inventor is started as administrator and Excel not. The level of UAC seems to make no difference here.


R. Krieg
RKW Solutions
www.rkw-solutions.com

johan.degreef
Advisor
Advisor

Alt+F11 gives this, so I should install it...?

 

Knipsel.JPG

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

johan.degreef
Advisor
Advisor

Installing the VBA part in inventor did not reslove the issue.

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

johan.degreef
Advisor
Advisor

VBA windows open in inventor now when pressing alt+F11, but ilogic code does not run

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

bradeneuropeArthur
Mentor
Mentor

in VBA create a module

and paste this

 

public sub main

Dim ExcelApp As Object


set ExcelApp = GetObject(, "Excel.Application")


end sub

 

Run VBA code

Regards,

Arthur Knoors

Autodesk Affiliations:

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: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 !

0 Likes

johan.degreef
Advisor
Advisor

same error

 

Knipsel.JPG

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

bradeneuropeArthur
Mentor
Mentor

bradeneuropeArthur_0-1619083340284.png

 

Regards,

Arthur Knoors

Autodesk Affiliations:

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: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 !

0 Likes

bradeneuropeArthur
Mentor
Mentor

Johan,

 

Does the DrawingList Tool still work?

Because it uses the same principle!

 

Regards

Regards,

Arthur Knoors

Autodesk Affiliations:

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: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 !

0 Likes

johan.degreef
Advisor
Advisor

@bradeneuropeArthur wrote:

Johan,

 

Does the DrawingList Tool still work?

Because it uses the same principle!

 

Regards


No error: Apprentice server is not installed.

Altough I did check and inventor View 2021 is installed.

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

bradeneuropeArthur
Mentor
Mentor

Something terribly wrong with your system.

what version of excel are you using?

Regards,

Arthur Knoors

Autodesk Affiliations:

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: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 !

0 Likes

johan.degreef
Advisor
Advisor

Excel 2019 MSO 64 bit

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

bradeneuropeArthur
Mentor
Mentor

!

Regards,

Arthur Knoors

Autodesk Affiliations:

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: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 !

0 Likes

bradeneuropeArthur
Mentor
Mentor

try this:

 

 

GetObject(, "Excel.Application.19")

Maybe you have more excel versions installed or at least the references!

 

Regards,

Arthur Knoors

Autodesk Affiliations:

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: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 !

0 Likes

johan.degreef
Advisor
Advisor

.19, no, but I think i am going to reset my laptop and do a reinstall.

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

johan.degreef
Advisor
Advisor

Indeed, a clean install did resolve all problems

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

bradeneuropeArthur
Mentor
Mentor

after the last windows update I have also some issues.

I have resolved them but it was difficult!

Not always good practice to install windows updates!!

Regards,

Arthur Knoors

Autodesk Affiliations:

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: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 !

0 Likes