Inventor Close when I run the code

Inventor Close when I run the code

mostafamahmoudseddek94
Advocate Advocate
506 Views
6 Replies
Message 1 of 7

Inventor Close when I run the code

mostafamahmoudseddek94
Advocate
Advocate

I am writing a code trying to read the fastener size of the hole feature, the code runs well but after displaying the message, inventor crushed and suddenly close.

recurred this over and over and got the same reaction 

 

you can see the video of what happening here : 

https://autode.sk/2rl8A3X

 

in case you can not see the code  

Sub main()
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument

Dim oHoleF As HoleFeatures
Set oHoleF = oDoc.ComponentDefinition.Features.HoleFeatures

MsgBox (oHoleF.Item(3).ClearanceInfo.FastenerSize)
End Sub

Thanks

0 Likes
507 Views
6 Replies
Replies (6)
Message 2 of 7

HideoYamada
Advisor
Advisor

Hi,

 

I tried your code but a problem doesn't occurred.

Can you upload the model which you tested?

And please tell us what Inventor version are you using.

(I tested with Inventor 2020.1)

 

=====

Freeradical

 Hideo Yamada

 

=====
Freeradical
 Hideo Yamada
https://www.freeradical.jp
0 Likes
Message 3 of 7

mostafamahmoudseddek94
Advocate
Advocate

Hi  Yamada 

Currently, I am using Inventor 2019.

Thanks 

0 Likes
Message 4 of 7

HideoYamada
Advisor
Advisor

Hi,

 

I tried your model with Inventor 2019, and got no error/trouble. ("M10" is displayed.)

Is this trouble depending on the model?

If you try this code to the simple model (one plate and one hole), do you get same trouble?

(Of cause, the hole identifier number in the code must be changed 3 to 1.)

 

=====

Freeradical

 Hideo Yamada

 

=====
Freeradical
 Hideo Yamada
https://www.freeradical.jp
0 Likes
Message 5 of 7

mostafamahmoudseddek94
Advocate
Advocate

I have tried this code with a simple model (one plate and one hole) and have got the same response, what is the reason behind this? 

0 Likes
Message 6 of 7

HideoYamada
Advisor
Advisor

Hi,

 

I cannot reproduce your issue in my environment, so it's difficult to help you...

 

Does the phenomenon change if the code is changed as follows?

 

Sub main()
    Dim oDoc As PartDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oHoleF As HoleFeatures
    Set oHoleF = oDoc.ComponentDefinition.Features.HoleFeatures
    
'    MsgBox (oHoleF.Item(3).ClearanceInfo.FastenerSize)
    Debug.Print oHoleF.Item(3).ClearanceInfo.FastenerSize
End Sub

 

 

This code show the result in the Immediate window instead of the Message Box.

 

=====

Freeradical

 Hideo Yamada

 

=====
Freeradical
 Hideo Yamada
https://www.freeradical.jp
0 Likes
Message 7 of 7

mostafamahmoudseddek94
Advocate
Advocate

Thanks for helping me,

since you tried to use the 2019 version like what I do and you did not get the same error, I have tried to install the latest update for inventor which is 2019.4.2 and now the inventor works well on my Computer and this creepy error has been vanished.  

0 Likes