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

Cannot modify a drawing view

marin_israel
Enthusiast

Cannot modify a drawing view

marin_israel
Enthusiast
Enthusiast

The problem is intermittent, so very difficult to correct.

When we modify a view created by my AddIn, sometimes, when we click on Ok after the modification, the projection of the next view remains active. Then, the only way to end the modification is to cancel with "Esc" and the modification initially wanted is also canceled. The only way to make the change is to close Inventor and start over.

 

Here is the code that creates the view:

Dim oBaseViewOptions As NameValueMap = goApp.TransientObjects.CreateNameValueMap()
If oModelDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
oBaseViewOptions.Add("DesignViewRepresentation", strType)
oBaseViewOptions.Add("DesignViewAssociative", True)
End If

Dim oView As DrawingView = oSheet.DrawingViews.AddBaseView(oModelDoc, oPoint, 1, oViewOrientation, oDrwStyle, "", Nothing, oBaseViewOptions)

If oModelDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
oView.ActiveLevelOfDetailRepresentation = "Avenger"
End If
oView.IsRasterView = False
oView.Suppressed = False
oView.DisplayTangentEdges = True

Return oView

 

All suggestion is welcome!

Thank you!

-------------------------------------
Israël Marin
Programmeur | Programmer
Logiflex
0 Likes
Reply
732 Views
11 Replies
Replies (11)

AlexKorzun
Autodesk
Autodesk

Try to disable background updates as shown below:

AlexKorzun_0-1619648123785.png

 

This option is available in API: https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=GUID-578FBD54-63C5-4E4B-9151-6393DA99334A

 

Also, it would be worth to check the effect of Defer Update on performance,  if you Update the drawing in the code:

AlexKorzun_1-1619648558300.png

https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=GUID-7C544688-3219-493E-A926-CF2029373ABC

 

Thank you,




Alex Korzun
Inventor-Revit Interop / Inventor-Fusion Interop / Inventor ETO
Autodesk, Inc.

0 Likes

marin_israel
Enthusiast
Enthusiast

Thank you @AlexKorzun for your suggestions.

 

I made a test version with your suggestions and so far it seems to work. On the other hand, the bug is intermittent, I want to continue my tests before claiming victory.

 

-------------------------------------
Israël Marin
Programmeur | Programmer
Logiflex
0 Likes

marin_israel
Enthusiast
Enthusiast

Unfortunately, the bug is still present ... even when enabling "defer update" and disabling "background update".
Does anyone have any other suggestions?
Thanks, any help is welcome!

-------------------------------------
Israël Marin
Programmeur | Programmer
Logiflex
0 Likes

WCrihfield
Mentor
Mentor

When you place a base view, it is automatically expecting you to continue placing more projected views from that view, so a command is still active, until you do something to complete it.  I believe what you need is to execute a command right after you have placed the view, and before you try to do anything else, that lets it know you're done placing views.  Something like "AppContextual_OKCmd".   That would look something like this:

ThisApplication.CommandManager.ControlDefinitions.Item("AppContextual_OKCmd").Execute

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) :thumbs_up:.

If you want and have time, I would appreciate your Vote(s) for My IDEAS :light_bulb:or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

marin_israel
Enthusiast
Enthusiast

@WCrihfield 

Thanks for your solution tip.

However, the bug does not occur when creating the view by programming but when modifying it manually.

-------------------------------------
Israël Marin
Programmeur | Programmer
Logiflex
0 Likes

WCrihfield
Mentor
Mentor

Does your add-in include some sort of custom event handler that would be triggered when you attempt to edit the view (or some similar/related event)?  Is it possible that the add-in is attempting to do something with that view when you attempt to edit it?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

marin_israel
Enthusiast
Enthusiast

@WCrihfield 

Very good point, I had not thought of it.
The only events I trigger are: OnActivatedocument, OnReady, OnTerminatedDocument and OnActivateView. If I'm not mistaken, when I edit a view none of these events should be triggered. And the only actions I do there are on the ribbons tabs.
In my opinion, this is not what could be causing the problem. What do you think?

 

Thank you for your help!

-------------------------------------
Israël Marin
Programmeur | Programmer
Logiflex
0 Likes

WCrihfield
Mentor
Mentor

After seeing which events you're using, I'm inclined to agree with you, that it doesn't sound like they would be triggered by you manually editing the drawing view.  The thing that raised my suspicion about the add-in was the first line of your original post, where it says the drawing view you are editing was created by the add-in.  Made me think, maybe since it was created by the add-in, there may still be some sort of active reference or related automation.  I know that when you manually edit a base view, it will not only open the 'Drawing View' dialog, but also activate the projected views placement mechanism again.  But usually all you have to do is either click OK on the dialog, or hit the Enter key on the keyboard to end it without loosing your changed settings or progress.  If you're saying that the dialog box isn't present, and therefore you can't click OK ;  or you can't just somehow accept/confirm with Enter, and it's not the add-in causing it, then I'm stumped too.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

marin_israel
Enthusiast
Enthusiast

Hi @WCrihfield 

Your reasoning is quite logical, I really believe that there is a link with the fact that the view was created by programming, especially since we tested it for 8 hours without addin and the bug did not occur. Which leads us to believe that it is really the Addin that is causing the bug. The idea that a reference to the view remains active seems plausible to me, is there a way to ensure that it is released after manipulating it?

 

Thank you for your help!

 

-------------------------------------
Israël Marin
Programmeur | Programmer
Logiflex
0 Likes

WCrihfield
Mentor
Mentor

I'm not sure.  This would be going into the fringe/fuzzy area of my programming knowledge.  Although I have been writing iLogic rules and VBA macros for many years, and have Visual Studio installed, I don't have much add-in programming experience, due to corporate restrictions (no employees have admin rights on their own PC's).

I have used some basic techniques to release references in the past, but I'm not really a 'master' programmer by degree or profession...I've just learned a lot over the years through research/exploration as needed to accomplish specific automation goals.

I doubt doing something as simple as oView = Nothing, after your done with variables would do the trick, that would be too easy.  So here are a few related links I've bookmarked along the way that may or may not help in this situation.  (These are Microsoft websites, so you'll need to change the C# drop-down near the top right corner of the pages to VB.)

Marshal.ReleaseComObject(Object) Method 

Object Lifetime 

IDisposable.Dispose Method 

https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/nothing 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

marin_israel
Enthusiast
Enthusiast

@WCrihfield 

Thank you so much!
We all have our limits, despite being a full time programmer, I have mine too. Your help will allow me to deepen the subject. I think the trail is good.

-------------------------------------
Israël Marin
Programmeur | Programmer
Logiflex
0 Likes