Inventor crashing (Unhandled Error)

Inventor crashing (Unhandled Error)

Anonymous
Not applicable
1,751 Views
6 Replies
Message 1 of 7

Inventor crashing (Unhandled Error)

Anonymous
Not applicable

I've created a macro that:

 

1) Reads a text file line-by-line (file paths)

2) Opens a drawing document from the text file

3) Modifies the title block

4) Saves the document

5) Reads next line from the text file (back to step 1)

 

All of the functions work perfectly fine separately.

Everything works fine if I put a break point at the beginning and step through the code (F8)

 

If I just run the application as it it is intended to run, Inventor crashes.

It doesn't always crash when processing the same DWG file.

 

The crash report says:"

 

<Exceptions>
				<Exception code="0xC0000005" text="ACCESS_VIOLATION" address="0x00007FFAF8F172CA" extraInfo="module:C:\Program Files\Autodesk\Inventor 2016\Bin\SM.dll      ">
					<AccessViolation type="Read" address="0x0000000000000000" PGStatus="0x00000001" accessing_null_ptr="true"/>
				</Exception>
			</Exceptions>
			<UTxExceptions/>
			<BugAlerts>
				<BugAlertTotal logged="2"/>
				<BugAlert message="API method DrawingDocument.Save caught an unhandled exception.&#xA;Memory may have been left in an inconsistent state."/>
				<BugAlert message="API method caught an unhandled exception.  Memory may have been left in an inconsistent state."/>
			</BugAlerts>

Application seems to run fine if I don't have the inventor window visible.

It is almost like the SAVE DRAWING command crashes if there are some unfinished tasks and having the window open and refreshing the graphics makes the entire process run longer / slower...?

0 Likes
1,752 Views
6 Replies
Replies (6)
Message 2 of 7

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi @Anonymous,

 

Correct me if I am wrong, VBA code opens drawing document, changes title block and saves document. This procedure works fine for individual document. But crashes on working with bulk documents.

 

Can you please provide sample files and VBA code to reproduce issue?

 

Please make sure that files are non confidential.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 7

bradeneuropeArthur
Mentor
Mentor

Use the OpenWithOption with these settings:

 

Public Sub a()

        Dim InvApp As Inventor.Application

        Set InvApp = ThisApplication
InvApp.FileOptions.FileOpenOptions.SkipAllUnresolvedFilesInAssembly = True
InvApp.FileOptions.FileOpenOptions.SkipAllUnresolvedFilesInDrawing = True
InvApp.FileOptions.FileOpenOptions.SkipAllUnresolvedFilesInPart = True


        Dim oNVM As NameValueMap
        Set oNVM = InvApp.TransientObjects.CreateNameValueMap

        Call oNVM.Add("DeferUpdates", True)

        Dim modoc As Document
        Set modoc = InvApp.Documents.OpenWithOptions("FULLFILENAME", oNVM, True) 
End Sub

If you have questions to implement this in your code please let me know.

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 4 of 7

Anonymous
Not applicable

I have done some digging and found a post that seems to address the issue:

Sending an API command while Inventor is busy causes crash; how to fix?

 

The problem seems to occur when exiting and saving the title block editor.

 

Here is that function where I added "Call ThisApplication.UserInterfaceManager.DoEvents"

As you can see I've tried adding just a "Sleep" function which seems to help but is not reliable

 

Private Function ReplaceRSlogoInTitleBlock(tbd As TitleBlockDefinition)
  Dim sk As DrawingSketch
  Dim si As SketchImage
  Dim xCenterPos, yCenterPos As Double
  Dim textStyle As String
  On Error GoTo ErrMsg
  Call tbd.Edit(sk)
  If sk.SketchImages.Count = 1 Then
    Set si = sk.SketchImages(1)
    xCenterPos = si.Position.X + (si.Width / 2)
    yCenterPos = si.Position.Y - (si.Height / 2)
    If (si.Width < 5.7) Then
        textStyle = "RS_LOGO_SH2"
    Else
        textStyle = "RS_LOGO_SH1"
    End If
    Call si.Delete
    Dim oTextBox As TextBox
    Dim oTG As TransientGeometry
    Set oTG = ThisApplication.TransientGeometry
    Set oTextBox = sk.TextBoxes.AddFitted(oTG.CreatePoint2d(xCenterPos, yCenterPos), "RUGGED SCIENCE", textStyle)
  End If
  'Sleep (2000)
  Call ThisApplication.UserInterfaceManager.DoEvents
  Call tbd.ExitEdit(True)
  Call ThisApplication.UserInterfaceManager.DoEvents
  Exit Function
ErrMsg:
  MsgBox ("REPLACE ERROR")
  Call tbd.ExitEdit(False)
End Function

 

I'll test this on a larger set of files and see if the problem is truly resolved.

 

 

 

 

0 Likes
Message 5 of 7

chandra.shekar.g
Autodesk Support
Autodesk Support

@Anonymous,

 

Call ThisApplication.UserInterfaceManager.DoEvents" and "Sleep" are useful when handling more number of documents.

 

Releasing of closed document object would take some time. So, memory allocated for the same object also takes some time. As number of documents increases, memory allocation also goes bigger. In continuing more consumption of memory, Inventor may lead to crash.

 

Can you please specify the number of drawings that needs drawing title block?

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 6 of 7

Anonymous
Not applicable

We need to process ~2500 drawings. This can be done in batches of 50.

I do close every drawing before opening the next one.

 

Call ThisApplication.UserInterfaceManager.DoEvents" and "Sleep" did help to make the application run a bit more stable but it is still not 100%.

 

Since this operation only needs to be performed once, I'm going to leave it as is and use the log file that the code generates to see where it has crashed (if it crashes) and resume from there.

 

This is certainly not the best case to write code but for the sake of not spending much more time on it, I have to use what I have.

0 Likes
Message 7 of 7

chandra.shekar.g
Autodesk Support
Autodesk Support

@Anonymous,

 

 

Breaking large number of drawings into batches is also nice solution to try.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes