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

Code not working in 2018 but works in 2012

 I have looked this over and I can't figure out why it is giving me this error.

 

1st time I even seen this kind of error on ilogic.

 

Strange.JPG

 

 

I supplied the part I will warn you don't hit continue it will stick you in a loop and you will have to force close Inventor.

 

Now this is in a library folder it works if the part is in the project workspace but I can't have that they need to be in a library so they cannot modify the part by accident .

 

It works fine in 2012 as a library but not in 2018.

 

Thanks for the help.

 

 

Can you please upload the code as text!?

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 !

Mike.Wohletz
in reply to: jletcher

I have opened the part and made a couple of edits using 2018 and have no issues or errors. 

Dim fileName As String
Dim path As String
path = ThisDoc.WorkspacePath()
fileName = "filename"

ThisDoc.Document.SaveAs(path & "\" & "900C7H" & L_1 & ".ipt" , False)


			

doc = ThisDoc.Document
path_and_name = ThisDoc.PathAndFileName(False) ' without extension


iLogicVb.UpdateWhenDone = True






MessageBox.Show("Your file has been made", "SPACER")
jletcher
in reply to: Mike.Wohletz

Did you put it in a library and mapped in projects?

 

It works if it is in the project folder but not in library..

 

Library.JPG

pball
in reply to: jletcher

Since you said this is in a library folder, it could be related to the "bug fix" in 2018 which removes the ability for the API to modify library parts. In the past the API could edit parts in library folders that could not be edited manually. That issue is discussed along with a hidden bypass for the fix added in 2018.2 in the thread below.

 

https://forums.autodesk.com/t5/inventor-customization/ilogic-error/td-p/7133836

 

Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style
jletcher
in reply to: jletcher

Knock knock anyone here?

 

 Come on Autodesk I need answers.......

 

Client needs to make parts..............

jletcher
in reply to: pball

 OH so the service pack that fails to install is the thing I need to fix this...

 

 

HOW NICE Smiley Mad

 

Really.JPG

Hi,

What went wrong?

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 !

jletcher
in reply to: pball

Loaded both updates and it does not fix my issue..

 

Nope.JPG

 If you are talking about the update I guess I had to load 2018.2 before I load 2018.2.1

 

 

 But neither of the updates fixed my issue..

 

 

 

ChrisMitchell01
in reply to: jletcher

In VBA, you now have to use:


ThisApplication.[_LibraryDocumentModifiable] = True

 

That also works in iLogic.

 

-Chris



Chris Mitchell
PDMS Customer Engagment Team
Autodesk, Inc.

MechMachineMan
in reply to: jletcher

Put this line in it's own rule, run it, then try your code again:

 

ThisApplication.[_LibraryDocumentModifiable] = True

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
jletcher
in reply to: MechMachineMan

No luck...

 

 

 Put it in his own did not work and would not let me exit so I had to task manager close Inventor..

Hi,

 

Did you try

makedirectory for each directory

 

like:

on error resume next

Mkdir "C\Test"

on error resume next

Mdir "C\Test\Directory1"

on error resume next

Mdir "C\Test\Directory1\Directory2"

 

 

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 !

last option could be:

 

this allows you to edit the Content Center part;

 

ThisApplication._LibraryDocumentModifiable = True

 

Don't forget to set it back to false for the Application

 

with:

 

ThisApplication._LibraryDocumentModifiable = false

 

Completed Code:

 

Dim fileName As String
Dim path As String
path = ThisDoc.WorkspacePath()
fileName = "filename"

ThisApplication._LibraryDocumentModifiable = True

ThisDoc.Document.SaveAs(path & "\" & "900C7H" & L_1 & ".ipt" , False)
		

doc = ThisDoc.Document
path_and_name = ThisDoc.PathAndFileName(False) ' without extension


iLogicVb.UpdateWhenDone = True

MessageBox.Show("Your file has been made", "SPACER")

ThisApplication._LibraryDocumentModifiable = false

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 !

Not sure what you mean by make directory for each directory..

 

 I need it to go into the project path..

you need to create the directory step by step (Per directory) when not existing yet.

 

for example:

 

you nee directory which is not existing:

like:

C\Test\Directory1\Directory2

 

then you need to do it like

 

on error resume next

Mkdir "C\Test"

on error resume next

Mdir "C\Test\Directory1"

on error resume next

Mdir "C\Test\Directory1\Directory2"

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 !

jletcher
in reply to: MechMachineMan

OK that code works but needs to be the 1st rule in the list

 

 

Rule.JPG

Hi,

 

Don't forget to set the value to False again!!!

 

To prevent you from problems as written in my post.

 

Good to here that it has been solved.

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 !