From a5b0dfac39e5cc2129a5106fe806760769330f04 Mon Sep 17 00:00:00 2001 From: Artem Date: Wed, 13 Sep 2023 16:42:45 +1000 Subject: [PATCH 1/2] Added alternative version of the macro to only process configurations of the active file --- .../ActiveDocumentMacro.vba | 36 +++++++++++++++++++ .../assembly/add-display-data-marks/index.md | 10 ++++-- 2 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 solidworks-api/document/assembly/add-display-data-marks/ActiveDocumentMacro.vba diff --git a/solidworks-api/document/assembly/add-display-data-marks/ActiveDocumentMacro.vba b/solidworks-api/document/assembly/add-display-data-marks/ActiveDocumentMacro.vba new file mode 100644 index 00000000..e9945d6f --- /dev/null +++ b/solidworks-api/document/assembly/add-display-data-marks/ActiveDocumentMacro.vba @@ -0,0 +1,36 @@ +Dim swApp As SldWorks.SldWorks + +Sub main() + + Set swApp = Application.SldWorks + + Dim swModel As SldWorks.ModelDoc2 + + Set swModel = swApp.ActiveDoc + + If Not swModel Is Nothing Then + + If swModel.GetType() = swDocumentTypes_e.swDocASSEMBLY Or swModel.GetType() = swDocumentTypes_e.swDocPART Then + + Dim vConfNames As Variant + vConfNames = swModel.GetConfigurationNames + + Dim i As Integer + + For i = 0 To UBound(vConfNames) + Dim swConf As SldWorks.Configuration + Set swConf = swModel.GetConfigurationByName(CStr(vConfNames(i))) + swConf.LargeDesignReviewMark = True + Next + + swModel.ForceRebuild3 False + + Else + Err.Raise vbError, "", "Only assemblies and parts are supported" + End If + + Else + Err.Raise vbError, "", "No files opened" + End If + +End Sub \ No newline at end of file diff --git a/solidworks-api/document/assembly/add-display-data-marks/index.md b/solidworks-api/document/assembly/add-display-data-marks/index.md index a175fccd..497557ce 100644 --- a/solidworks-api/document/assembly/add-display-data-marks/index.md +++ b/solidworks-api/document/assembly/add-display-data-marks/index.md @@ -2,11 +2,11 @@ layout: sw-tool caption: Add Display Data Marks title: Macro to add display data marks to configuration used by the main SOLIDWORKS assembly -description: VBA macro to add display data mark for configurations used in Large assembly to be opened in Large Design Review Mode +description: VBA macro to add display data mark for configurations used in Large assembly to be opened in Large Design Review Mode or eDrawings image: display-data-mark.svg group: Assembly --- -This VBA macro is useful for the users working with assemblies in the Large Design Review mode. +This VBA macro is useful for the users working with assemblies in the Large Design Review mode or when it is required to support configurations in eDrawings. By default only active configuration is preserved for using the the Large Design Review mode and other configurations of the assembly cannot be activated: @@ -18,4 +18,8 @@ This macro will traverse all components of the root assembly and find all the us This will allow to open all sub components in the Large Design Review mode and activate used configurations. -{% code-snippet { file-name: Macro.vba } %} \ No newline at end of file +{% code-snippet { file-name: Macro.vba } %} + +Alternative version of the macro will only process configurations of the active part or assembly and add the Display Data marks + +{% code-snippet { file-name: ActiveDocumentMacro.vba } %} \ No newline at end of file From 1c6930342a7530c7098e93bd1e5125056813cd32 Mon Sep 17 00:00:00 2001 From: Artem Date: Tue, 3 Oct 2023 11:44:47 +1100 Subject: [PATCH 2/2] Added the dirty flag for the modified ref document files --- solidworks-api/document/appearance/color-assembly/Macro.vba | 1 + 1 file changed, 1 insertion(+) diff --git a/solidworks-api/document/appearance/color-assembly/Macro.vba b/solidworks-api/document/appearance/color-assembly/Macro.vba index 94775dec..090a066c 100644 --- a/solidworks-api/document/appearance/color-assembly/Macro.vba +++ b/solidworks-api/document/appearance/color-assembly/Macro.vba @@ -141,6 +141,7 @@ Sub ColorizeComponents(vComps As Variant) Dim sConfs(0) As String sConfs(0) = swComp.ReferencedConfiguration swRefModel.Extension.SetMaterialPropertyValues dMatPrps, IIf(ALL_CONFIGS, swInConfigurationOpts_e.swAllConfiguration, swInConfigurationOpts_e.swSpecifyConfiguration), IIf(ALL_CONFIGS, Empty, sConfs) + swRefModel.SetSaveFlag End If End If