Code not working in 2018 but works in 2012

Code not working in 2018 but works in 2012

jletcher
Advisor Advisor
5,705 Views
168 Replies
Message 1 of 169

Code not working in 2018 but works in 2012

jletcher
Advisor
Advisor

 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.

 

 

0 Likes
5,706 Views
168 Replies
Replies (168)
Message 2 of 169

bradeneuropeArthur
Mentor
Mentor
Can you please upload the code as text!?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


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 !


 


EESignature

0 Likes
Message 3 of 169

Mike.Wohletz
Collaborator
Collaborator

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

0 Likes
Message 4 of 169

jletcher
Advisor
Advisor
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")
0 Likes
Message 5 of 169

jletcher
Advisor
Advisor

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

0 Likes
Message 6 of 169

pball
Mentor
Mentor

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
0 Likes
Message 7 of 169

jletcher
Advisor
Advisor

Knock knock anyone here?

 

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

 

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

0 Likes
Message 8 of 169

jletcher
Advisor
Advisor

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

 

 

HOW NICE Smiley Mad

 

Really.JPG

0 Likes
Message 9 of 169

bradeneuropeArthur
Mentor
Mentor

Hi,

What went wrong?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


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 !


 


EESignature

0 Likes
Message 10 of 169

jletcher
Advisor
Advisor

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

 

Nope.JPG

0 Likes
Message 11 of 169

jletcher
Advisor
Advisor

 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..

 

 

 

0 Likes
Message 12 of 169

ChrisMitchell01
Community Manager
Community Manager

In VBA, you now have to use:


ThisApplication.[_LibraryDocumentModifiable] = True

 

That also works in iLogic.

 

-Chris



Chris Mitchell
PDMS Customer Engagment Team
Autodesk, Inc.

0 Likes
Message 13 of 169

MechMachineMan
Advisor
Advisor

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
0 Likes
Message 14 of 169

jletcher
Advisor
Advisor

No luck...

 

 

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

0 Likes
Message 15 of 169

bradeneuropeArthur
Mentor
Mentor

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 & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


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 !


 


EESignature

0 Likes
Message 16 of 169

bradeneuropeArthur
Mentor
Mentor

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 & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


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 !


 


EESignature

Message 17 of 169

jletcher
Advisor
Advisor

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

 

 I need it to go into the project path..

0 Likes
Message 18 of 169

bradeneuropeArthur
Mentor
Mentor

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 & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


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 !


 


EESignature

0 Likes
Message 19 of 169

jletcher
Advisor
Advisor

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

 

 

Rule.JPG

0 Likes
Message 20 of 169

bradeneuropeArthur
Mentor
Mentor

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 & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


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 !


 


EESignature

0 Likes