Assembly Shift Show Modified Parts

Hi all

I am currently working in an assembly in which the dimensions of the parts are managed by the notepad.

This is very practical because it allows you to modify a single dimension and the software takes care of updating the linked elements.

However, I would like it to highlight the parts that are going to be changed before performing the update because I have a lot of parts related to each other and I would like not to forget any in the plan update.

Does anyone know if this is possible in Solidworks?

 

1 Like

How is your link between notepad and solidworks made? Direct or Macro? 

The link is made live via the Equations menu

Unfortunately I don't know I will look at how it works

 

EDIT Ok I just learned something:) nevertheless I don't see how to put an alert or anything :/

 

 

Hello

I don't know, can you post an example?

May the force be with you

I generated it to discover


maj_dassemblage_montrer_ieces_modifiees.zip

Here is an example.

Notice that if I change one of the parameters in my notepad, it will have an influence on the two parts in my assembly as soon as I click on rebuild

In the case of an assembly with several parts, it can be interesting for solidworks to put in red the parts that are impacted by this modification before rebuilding.

No matter how hard I look, I can't find how to do it. I'm starting to think that this is not possible with Solidworks:(


exemple.zip

Hello

I couldn't open your files because of different SW versions but I think your two pieces are editable by the same notepad file. One way would be to check on your assembly all the parts of which one of the equations calls for this notepad file.

Here is already the beginning of the code of a macro allowing to list the child elements if an assembly is loaded or to see which file an equation calls if it is a part that is loaded:

Option Explicit

Dim swApp As Object

Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim swEqnMgr As SldWorks.EquationMgr
Dim eqnLinked As Boolean
Sun i As Long
Dim nCount As Long

Sub main()

Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc

TraverseAssemly

Set swEqnMgr = Part.GetEquationMgr
nCount = swEqnMgr.GetCount
For i = 0 To nCount - 1
    eqnLinked = swEqnMgr.LinkToFile
    If eqnLinked Then
         swEqnMgr.UpdateValuesFromExternalEquationFile

        MsgBox "Equation File Path: " & swEqnMgr.FilePath
    End If
Next i

End Sub

Sub TraverseComponent(swComp As SldWorks.Component2)
    Dim vChildComp as Variant
    Dim swChildComp As SldWorks.Component2
    Sun i As Long
    
    vChildComp = swComp.GetChildren
    
    For i = 0 TB UBound(vChildComp)
        Set swChildComp = vChildComp(i)
        MsgBox "Sons:" & swChildComp.Name
    Next i
End Sub

Public Function TraverseAssemly()
    Dim swConfMgr As SldWorks.ConfigurationManager
    Dim swConf As SldWorks.Configuration
    Dim swRootComp As SldWorks.Component2
    
    Set Part = swApp.ActiveDoc
    If part is nothing then exit function
    If Part.GetType() <> swDocASSEMBLY Then Exit Function

    Set swConfMgr = Part.ConfigurationManager
    Set swConf = swConfMgr.ActiveConfiguration
    Set swRootComp = swConf.GetRootComponent3(True)
    
    Call TraverseComponent(swRootComp)
End Function

Kind regards

1 Like

Thanks for the demos, I'll come back  to them later (no time).

May the Force be with you

2 Likes

D.Roger, thank you for the macro bit. I'm going to test that.

If I have understood how it works, it may list all the components of my assembly because they all use the same notepad file.

In any case, it's a start :) I'll try to improve a little in macro to see if I can ask it to list only the elements that use a given equation

 

 

Hello

The following macro allows from an assembly loaded in SW to list all the equations of all the first-level parts, but you have to compare these equations with the one you are looking for to keep only the desired parts. If the parsing of the parts must be done on a multi-level basis, then the TraverseComponent function must be modified to change it to a recursive version.

Option Explicit

Dim swApp As Object

Dim Part As Object
Dim SwModel As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim swEqnMgr As SldWorks.EquationMgr
Dim eqnLinked As Boolean
Sun i As Long
Sun j As Long
Dim nCount As Long
Dim Son As String

Sub main()

    Set swApp = Application.SldWorks
    Set Part = swApp.ActiveDoc

    TraverseAssemly 1

End Sub

Sub TraverseComponent(swComp As SldWorks.Component2)
    Dim vChildComp as Variant
    Dim swChildComp As SldWorks.Component2
    Sun i As Long
    
    vChildComp = swComp.GetChildren
    
    For i = 0 TB UBound(vChildComp)
        Set swChildComp = vChildComp(i)
        sons = swChildComp.GetPathName
        If UCase(Sons) Like "*. SLDPRT*" Then
            Set SwModel = swApp.OpenDoc(Threads, 1)
            Set swEqnMgr = SwModel.GetEquationMgr
            nCount = swEqnMgr.GetCount
            For j = 0 To nCount - 1
                MsgBox swChildComp.Name2 & " - Equation: " & swEqnMgr.Equation(j)
            Next j
        End If
    Next i
End Sub

Public Function TraverseAssemly(trie As Long)
    Dim swConfMgr As SldWorks.ConfigurationManager
    Dim swConf As SldWorks.Configuration
    Dim swRootComp As SldWorks.Component2
    
    Set Part = swApp.ActiveDoc
    If part is nothing then exit function
    If Part.GetType() <> swDocASSEMBLY Then Exit Function

    Set swConfMgr = Part.ConfigurationManager
    Set swConf = swConfMgr.ActiveConfiguration
    Set swRootComp = swConf.GetRootComponent3(True)
    
    Call TraverseComponent(swRootComp)
End Function

Kind regards

1 Like

Sorry for the digression but how do you create the link between the txt file and the odds?
Does it also work to activate/delete a component in an ASM?

stefbeno

If I'm not mistaken, just make your equation and then export, there it will create the chichier text with the equation and then in a new part or assembly import.

1 Like

Simply.

Thank you for letting me discover this.

Hello

 

Sorry to have taken the time to answer, I had gone on vacation :).

@d.roger: I tried to launch the macro but nothing happens.

When I launch it via the debugger, it tells me a syntax error on the line: Set swApp = Application.SldWorks

 

 

Hello

Do you have the Dim swApp As Object line at the beginning of the macro?

Check the references in Tools/References too!

Kind regards