Inventor 2022.2 crash on RunExternalRule

Inventor 2022.2 crash on RunExternalRule

jdasilvaS39UQ
Advocate Advocate
1,314 Views
18 Replies
Message 1 of 19

Inventor 2022.2 crash on RunExternalRule

jdasilvaS39UQ
Advocate
Advocate

Hi,

 

We have a VBA macro button that launches a user form, then on that user form we have a button to run an external ilogic rule that updates our drawing author and date.

After updating to Inventor 2022.2 today, we ran into an issue where if we open a drawing and the first thing we do is hit that button, it crashes Inventor without any warning or error message. If we do anything else such as save or if I open the vba editor first, it works without issue. It also only happens on certain drawing documents.

 

Here is the code we are using below, the specific line it crashes on is: Call iLogicAuto.RunExternalRule(oDoc, fname & ".txt")

 

Sub RuniLogicExt(ByVal RuleName As String)

   Dim oPath As String
   oPath = "[File path on our server here]"
   
   Dim iLogicAuto As Object
   Dim oDoc As Document
   Set oDoc = ThisApplication.ActiveDocument
   If oDoc Is Nothing Then
      MsgBox "Missing Inventor Document"
      Exit Sub
   End If
   Set iLogicAuto = GetiLogicAddin(ThisApplication)
   If (iLogicAuto Is Nothing) Then
   MsgBox "iLogicAuto Is Nothing"
   Exit Sub
   End If
    
'Determine if file is .txt or .ilogicvb

    Set fs = CreateObject("Scripting.FileSystemObject")
    
   Dim fname As String
   fname = oPath & RuleName
   
   If fs.FileExists(fname & ".txt") Then
    Call iLogicAuto.RunExternalRule(oDoc, fname & ".txt")
   ElseIf fs.FileExists(fname & ".iLogicVb") Then
    Call iLogicAuto.RunExternalRule(oDoc, fname & ".iLogicVb")
    Else
    MsgBox ("iLogic rule doesn't exist.")
   End If

   

End Sub

Function GetiLogicAddin(oApplication As Inventor.Application) As Object
   Dim addIns As ApplicationAddIns
   Set addIns = oApplication.ApplicationAddIns
   Dim addIn As ApplicationAddIn
   On Error GoTo NotFound
   Set addIn = oApplication.ApplicationAddIns.ItemById("{3bdd8d79-2179-4b11-8a5a-257b1c0263ac}")
   If (addIn Is Nothing) Then Exit Function
   addIn.Activate
   Set GetiLogicAddin = addIn.Automation
   Exit Function
NotFound:
End Function

 

 

1,315 Views
18 Replies
Replies (18)
Message 2 of 19

WCrihfield
Mentor
Mentor

Just curious...I see that the variable "RuleName" is defined in the definition line of the main Sub routine as an input variable, but if this is the entire VBA macro, then where is RuleName getting its Value set?  Are you using some other rule or macro to run this macro, then supplying that value in that other code?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 19

jdasilvaS39UQ
Advocate
Advocate

Yes, the name of the rule is being set on another macro. We have a button on a user form that runs this:

Private Sub btnUpdateTitleBlock_Click()
Me.Hide
CommonFunctions.RuniLogicExt ("UpdateDrawnByAndDate")
End Sub
0 Likes
Message 4 of 19

MjDeck
Autodesk
Autodesk

@jdasilvaS39UQ , can you post the external rule? If you can, please post it as an attachment.


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 5 of 19

jdasilvaS39UQ
Advocate
Advocate

Here is our rule. It basically copies the title block from our standard.idw template to the active document.

0 Likes
Message 6 of 19

WCrihfield
Mentor
Mentor

When you fill-in the value of the oPath variable, do you include the directory separator character at the end?  If not, then when you set the value of the variable 'fname' using oPath & RuleName, it won't turn out right.  There will need to be that directory separator character between oPath and RuleName, if there is not already one.  Also, you might be able to get rid of that 'oPath' variable altogether if you have your iLogic Configuration settings fully set-up correctly.  [Tools tab > Options panel > iLogic Configuration (might need to expand that panel to see it). 

WCrihfield_0-1637693441778.pngWCrihfield_1-1637693554693.png

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 7 of 19

jdasilvaS39UQ
Advocate
Advocate

Hi,

 

Yes, the final "\" is included in the file path. The problem I am running into is if I open a document and run this macro as the first thing I do, Inventor crashes, without even giving any error message/crash message. If I save the document or do other commands before running the macro, it executes as expected.

 

For now I have uninstalled the latest update to revert back to 2022.1.1 and it is working without any issues.

0 Likes
Message 8 of 19

MjDeck
Autodesk
Autodesk

Does the crash also happen when you run the rule from the iLogic browser? Or does it only happen when you run it from VBA?

As a test, can you try commenting out all the BalloonTip code in the rule?


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 9 of 19

jdasilvaS39UQ
Advocate
Advocate

It also crashes when running through the iLogic browser, without VBA.

Also crashes with the balloon tip code commented out, so I started commenting out other lines and I narrowed it down to the line that copies a title block from our template to the current drawing:

oNewBlock = oSourceBlock.CopyTo(oDoc, True)

 

Other things to note:

- Doesn't crash when I open a drawing through file explorer, only when opening through Inventor

0 Likes
Message 10 of 19

CattabianiI
Collaborator
Collaborator

Hi @MjDeck @jdasilvaS39UQ ,

I have the same issue: Inventor crashes while copying title block via api. I noticed that if I remove two embedded images the title block has the copy works fine. 

0 Likes
Message 11 of 19

CattabianiI
Collaborator
Collaborator

On my side sometimes Inventor crashes (in the same way with no crash report) just editing the title block, moving the image and trying to save the title block.
If it's meaningful: the image is an embedded link; I've no experience on this part of Inventor what I'm just saying is that the links command is enabled and the image is there. 
I confirm there are no issue with Inv 2022.1.1. 
@MjDeck @johnsonshiue let me know if you need a dataset to reproduce the issue.
and @jdasilvaS39UQ let us know if there is an image or a link on your title block too.

0 Likes
Message 12 of 19

MjDeck
Autodesk
Autodesk

@jdasilvaS39UQ and @CattabianiI , I was able to reproduce the problem when the source drawing contains a title block with an image. I logged it as internal issue INVGEN-58368.
To make sure we're fully covering the problem, please do upload a dataset.


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 13 of 19

jdasilvaS39UQ
Advocate
Advocate

Our title block does have an embedded image. What do you mean by upload a dataset?

@MjDeck @CattabianiI 

0 Likes
Message 14 of 19

MjDeck
Autodesk
Autodesk

@jdasilvaS39UQ , if you can upload a drawing that demonstrates the problem, it would help to ensure that we can fix it. I don't think we need a model. Just the drawing file that contains a title block with an embedded image.


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 15 of 19

jdasilvaS39UQ
Advocate
Advocate

Here you go

Message 16 of 19

thomas.johansson
Participant
Participant

Hi.

I have the same problem in C#.

Inventor crashes when I tries to use "CopyTo(<drawingdocument>, true)". This code has worked fine until now. So it has to be an Inventor bug in 2022

0 Likes
Message 17 of 19

donaldleigh
Advocate
Advocate

Evening all

 

I also was having inventor crash when updating drawings with 2002.2. I have reverted back to the original release. Is there any time frame when the issue will be resolved?

 

Donald 

0 Likes
Message 18 of 19

thomas.johansson
Participant
Participant

Hi all.

The problem seems to been fixed in Inventor 2022.2.2.

 

//Thomas

0 Likes
Message 19 of 19

jdasilvaS39UQ
Advocate
Advocate

Thank you! I just updated and looks like it has been fixed