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?
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:(
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)
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)
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.