Hide construction in VBA

Hello everyone,

As part of a project, I have a rather long macro to do (creation of several shots + sketches) to repeat in a loop. Everything works but slowly, very slowly. At each step of calculation (restart of my loop) I delete the previous construction to lighten the model. In addition, each time I create a plan or sketch I hide it (Part.BlankRefGeom or Part.BlankSketch). But here's my problem: the program is always slow (partly due to the fact that SW created the plan or the sketch and then only after the mask so the construction step still appears for a short time and burns the resource), do you have a technique to completely hide the construction (ask SW not to display it)?

Thank you!

Hello

do you have SolidWorks visible pdt your macro? (swapp. Visible = True ) 

It can improve performance not to put this line. 

Yes, indeed SW is visible during the execution of the macro. So to hide:

swapp. Visible = False

I'm trying, thanks for the idea!

Hello

 

Does this control work for you? 

swapp.Visible = False

 

hello @ aera.damallard

Who is your message for??

Can you describe your problem because if you ask this question it suggests that you have a problem with the syntax.

(maybe a little attention to the spaces before and after the equal  sign also pay attention to the case of the letters if it matters ( swApp.xxx) )

Tell us or it should be highlighted normally.

Also attaches the code before and after the swApp.xxx

Kind regards

Hello

Yes it works but respecting a few rules to see here in the chapter "Remarks", taking into account that "ISldWorks::UserControl" is equal to True by default when Solidworks is not launched by your program.

So to make Solidworks invisible if it is not launched by your program, there must be no document open in Solidworks and put "swApp.UserControl = False" before the line "swApp.Visible = False".

Be careful, if you quit your program with Solidworks invisible, it will remain open but in invisible mode so you must remember to either make it visible or close it before quitting your program.

Kind regards

2 Likes

Ok so the logic is that I get the info from my activedoc

Then I apply the usercontrol and the visible and I loop the other way around after ok its working I'll try it right away!

Test successfully indeed you have to close the document otherwise it doesn't hide anything :/

1 Like