Component Name Display Issue

Hello

 

I just 'finished' a macro that does an automatic assembly and even replaces a component inside another component, the second level of assembly. Once the assembly is finished, all saved my tree displays the old numbers and does not update anything. I even restarted my computer in case it was a cache issue. On a colleague's computer it has the right display and there are even the right references....

 

My assembly is good, there is no problem except for the display of the names and it's just on my computer, after using my macro. I no longer have access to the "reference" window when opening the said file.

I'm tearing my hair out on this 'little' problem, I'm a bit of a perfectionist....

 

Sincerely, Mandrake.


capture.png

Hello

You must have temporary files everywhere, cut Solidworks and then try to do a system cleanup using Solidworks RX:

Kind regards

Thank you for your quick answer, no change on my computer, I remind you that I have shut down and restarted my computer in the meantime, so logically cleaning all the caches.

 

Kind regards

 

 


capture.png

Hello

Sorry for the previous answer, I hadn't seen the point at the end of the sentence "My assembly is good, there is no problem except for the display of the names and it's just on my computer, after using my macro".

I deduce that this happens after using your macro but what if you load the new assembly, thus saved, on your computer without using your macro. And what if you use your macro on your colleague's computer?

Kind regards

I expressed myself badly too, I used the macro only once. Since when I open the assembly I always have the same display, the famous 9800 instead of F90149800 name and reference of the assembly in my F90149900.

 

I'll try to be clearer, it's not that simple! This morning I launched the macro.

Assembling my 8500, 9800, 8700, 9200 and 9900 components. File 85 already exists so I decide to replace it, still in the process of my macro. To finish recording each of my assemblies.

 

On a colleague's computer, the display when opening the file is correct. Assembly F90149900 composed of F90149800 and F90149200 .... You get the idea. Access to the set reference table and file names are correct.

 

On the other hand, on my computer when I open the file F90149900 my tree shows 9800 and 9200 with inside 9800 the F90148500 file (the file that I replaced with another one during the macro process).

Unable to open the 'reference'  window of the F90149900 file (only on my computer) 

 

Since this morning I tried to clean the cache with Rx, I restarted my computer and I don't know what to do anymore :'(

 

Namely that my basic files, 8500, 8700, 9200, etc. has no part and when I open the F90149900 all the part files are visible. So there is only a problem with the display of the name in the tree on the computer launching the macro. 

 

I haven't tried the macro on other posts yet, I prefer to avoid spreading problems! I spread enough of it without doing it on purpose;)

 

I hope I was clearer. I remain at your disposal!

 

Kind regards

Hello

After a small test I managed to reproduce part of the problem. To fix this, try adding the ReloadOrReplace function after each saving of an assembly, pay attention to the recursive parsing function of your assembly, here is an example:

(EDIT) removed the example, some working problems remaining.

Kind regards

Another solution, here is an example of code running at home on an assembly with more than 2 levels, the copies are done well and this without display errors as you may have in the tree. The principle is to save the son assembly under a new name and  immediately re-register its father, at the end of the cycle, I re-register the higher-level assembly, I close it and then I reopen it:

Option Explicit

Dim swApp As SldWorks.SldWorks
Dim chemin As String
Dim asmTitle As String
Dim boolstatut As Boolean
Dim lErrors As Long
Dim lWarnings As Long

Sub main()
    Dim swModel As SldWorks.ModelDoc2
    Dim swConfMgr As SldWorks.ConfigurationManager
    Dim swConf As SldWorks.Configuration
    Dim swRootComp As SldWorks.Component2
    
    Set swApp = CreateObject("SldWorks.Application")
    Set swModel = swApp.ActiveDoc
    Set swConfMgr = swModel.ConfigurationManager
    Set swConf = swConfMgr.ActiveConfiguration
    Set swRootComp = swConf.GetRootComponent3(True)
    
    chemin = "C:\Users\DRO\Desktop\Temp PDF\"
    asmTitle = swModel.GetTitle
    
    If swModel.GetType = SwConst.swDocASSEMBLY Then
        boolstatut = swModel.SaveAs3(chemin & "new-" & asmTitle, 0, 1)
        
        TraverseComponent swRootComp
        
        swModel.ForceRebuild3 True
    
        boolstatut = swModel.Save3(swSaveAsOptions_e.swSaveAsOptions_Silent + swSaveAsOptions_e.swSaveAsOptions_SaveReferenced, lErrors, lWarnings)
    
        swApp.CloseDoc swModel.GetTitle
        Set swModel = swApp.OpenDoc6(chemin & "new-" & asmTitle, 2, swOpenDocOptions_Silent, "", lErrors, lWarnings)
    End If
End Sub

Sub TraverseComponent(swComp As SldWorks.Component2)
    Dim vChildComp As Variant
    Dim swChildComp As SldWorks.Component2
    Dim swSelModelFils As SldWorks.ModelDoc2
    Dim swSelModelPere As SldWorks.ModelDoc2
    Dim i As Long
    vChildComp = swComp.GetChildren
    For i = 0 To UBound(vChildComp)
        Set swChildComp = vChildComp(i)
        Set swSelModelFils = swChildComp.GetModelDoc2
        If swSelModelFils.GetType = 2 Then
            boolstatut = swSelModelFils.SaveAs3(chemin & "new-" & swSelModelFils.GetTitle, 0, 1)
            Set swSelModelPere = swComp.GetModelDoc2
            boolstatut = swSelModelPere.Save3(swSaveAsOptions_e.swSaveAsOptions_Silent + swSaveAsOptions_e.swSaveAsOptions_SaveReferenced, lErrors, lWarnings)
            TraverseComponent swChildComp
        End If
    Next i
End Sub

Kind regards

This is indeed what my macro did at the beginning, recording the child, then the father and so on by going up the tree in a 'logical' way it works without problem and you get the right references and the right display in the tree.  But when I replaced a child with another assembly, The names of the other assemblies were not updated after registration. It was just the tree view that was wrong.

 

Thank you for taking the time to try to rectify the problem. Your macro is nice to save all the components of a two-level assembly under a new name! It's a good old Pack & Go;)

 

Someone found the solution I didn't check the box 'update component names when documents are replaced' :

 

Why make it simple when you can make it complicated =)

 

On the other hand, I don't understand why the names don't update the second time they open the computer or the next day, after restarting the computer, one of the mysteries of SolidWorks for sure.