Force Model Browser to update with new geometry

Force Model Browser to update with new geometry

AlexFielder
Advisor Advisor
972 Views
4 Replies
Message 1 of 5

Force Model Browser to update with new geometry

AlexFielder
Advisor
Advisor

Related to this other post I have managed to get the resultant hole features created correctly based on the axes that intersect with the workpoints created by that method, but one thing that I cannot fathom is why these new features don't show up in the Model Browser until I close and reopen the file.
 
I have tried:

 

partDoc.Update();
RadialHoles.m_InventorApp.ActiveView.Update();



as well as:
 

private static void updateBrowserPane()
{
BrowserPane pane = partDoc.BrowserPanes.ActivePane;
pane.Update();
}


None of which seem to work.
 
It's probably something dead simple but I was hoping that someone else has experienced this and might be able to share the answer.
 
Thanks,
 
Alex.

0 Likes
Accepted solutions (1)
973 Views
4 Replies
Replies (4)
Message 2 of 5

GeorgK
Advisor
Advisor

Hello Alex,

 

does it help to change the browserpane?

 

    Dim invDoc As Document
    Set invDoc = ThisApplication.ActiveDocument
    If invDoc Is Nothing Then
        MsgBox "No documents open!", vbOKOnly
        Exit Sub
    End If
    If invDoc.DocumentType <> kAssemblyDocumentObject Then
        MsgBox "Active document is not an assembly model!", vbOKOnly
        Exit Sub
    End If
    Dim invModelTree As BrowserPaneObject
    Set invModelTree = invDoc.BrowserPanes.Item("AmBrowserArrangement")
    Dim OccBrowserNode As BrowserNode
    Dim LabelName As String
    Dim DocName As String
    
    invModelTree.Activate
    invModelTree.Refresh
    invModelTree.Update

Georg

0 Likes
Message 3 of 5

AlexFielder
Advisor
Advisor

Hi @GeorgK,

 

Unfortunately, that doesn't help me since I am working in a part file and the .Refresh throws an error as a result.

 

Thanks,

 

Alex.

 

0 Likes
Message 4 of 5

wayne.brill
Collaborator
Collaborator

Hi Alex,

 

The holes that are created with the code I have show up instantly in the browser.

 

I can research the problem you are seeing. Can you provide a small but complete code example that will allow me to recreate the behavior where the hole features are showing in the browser only after the file is re-opened?

 

Thanks,

Wayne



Wayne Brill
Developer Technical Services
Autodesk Developer Network

Message 5 of 5

AlexFielder
Advisor
Advisor
Accepted solution

Hi @wayne.brill,

 

After looking at this with fresh eyes, I revisited my code and removed a transaction that I had set up to effectively "end" after having placed the sketch points.

 

I can't really fathom why I had it there in the first place, but, after making this change:

 

public static void Button1_Execute()
        {
            log.Info("Radial Holes button was clicked!");
            Transaction trans = RadialHoles.m_InventorApp.TransactionManager.StartTransaction(RadialHoles.m_InventorApp.ActiveDocument, "Radial Holes");
            reporter.UpdateStatusBar("Hello from the first button extension!");
            try
            {
                GetExcelData();
                if (selectedAFaceAnAxisAndPlane())
                {
                    checkForAndClearExistingAttributes();
                    createSketchForPoints();
                    createSketchPointsFromList();
                    createGeomForHolePositions();
                    createHolesFromDefinitions();
                    updateBrowserPane();
                    
                    //createWorkAxesForHolePoints();
                }
                
            }
            catch (Exception ex)
            {
                trans.Abort();
                log.Error(ex.Message);
                NullAllTheThings();
            }
            finally
            {
                trans.End();
                
                if(reporter != null)
                {
                    partDoc.Update();
                    RadialHoles.m_InventorApp.ActiveView.Update();
                    NullAllTheThings();
                }
                log.Info("Radial Holes completed.");
            }

            
        }

Wherein the transaction wraps the whole process, all newly created features appear as expected.

 

It was you assertion that the code you had worked without issue that sparked the light-bulblight-bulb-32x32.png in my head to say "try it without the transactions in the middle" which solved it so Thank you!