VBA: Edit a file without opening the 3D

Hello

I have noticed in Excel macros, that when I open several files, some do not load in the Solidworks screen, however, they are subject to the changes (it's not a problem of speed, because I have already seen it with F8).

I noticed that I sometimes have to do the Visible = True action, for the file to be displayed on the screen.

Now, I'm wondering if there's a method that would allow you to open files without physically loading them into the Solidworks screen. Just to exploit this bug to check if the macro is not faster. A bit like with Excel when you cancel the automatic calculation or the screen update.

 

Thank you.

Hello

It's not a bug, it just allows you to open it up and make changes faster. (no rebuilding or graphical loading)

This mode is therefore done on purpose, but it is not possible to launch changes in solidworks without at least opening a solidworks in a hidden version.

1 Like

Hello

For "but not possible to launch changes in solidworks without at least opening a solidworks in hidden version", except for some manipulations through the Solidworks Document Manager APIs where it is not necessary to have Solidworks installed. Otherwise I agree with sbadenis.

Kind regards

1 Like

"So this mode is done on purpose"

Opening Solidworks is not a problem, but how can you open files voluntarily in this way?

To speed up a macro there are several methods that can be put in place.

Like:

swApp.UserControl = False
swApp.Visible = False

swModel.Visible = False

swApp.DocumentVisible(False, swDocumentTypes_e.swDocPART)
swApp.DocumentVisible(False, swDocumentTypes_e.swDocASSEMBLY)
swApp.DocumentVisible(False, swDocumentTypes_e.swDocDRAWING)

swModel.FeatureManager.EnableFeatureTree = False

swModel.FeatureManager.EnableFeatureTreeWindow = False

swApp.CommandInProgress = True

Dim modView as ModelView
set modView = swModel.ActiveView
modView.EnableGraphicsUpdate = False

See here for more information

Note: Some API functions do not work if the part is not visible.

2 Likes

I don't know which function you use to open your documents but here is for example a small excerpt from the doc on the OpenDoc7 function:

"ISldWorks::OpenDoc7 does not activate or display the document if the file is already open in memory in an assembly or drawing. However, ISldWorks::OpenDoc7 must return a valid IModelDoc2 pointer that can be used with functions that do not require a document to be displayed.

Optionally, ISldWorks::ActivateDoc2 or ISldWorks::IActivateDoc3 will activate and display the document. Because calling ISldWorks::OpenDoc7 doesn't activate or display the file, calling the ISldWorks::ActiveDoc or ISldWorks::IActiveDoc2 property doesn't return a pointer to this document."

Kind regards

1 Like