Go easy on ForceRebuild3 ?

Is there a sensible limit to the amount/quantity you can usethe "modeldoc2.ForceRebuild3(true)" trick ?

In my case at a certain moment it crashes my macro. And doing sowithout giving an error message.
When I restart the macro I do get the notification about the macropossibly beeing unstable due to a problem on previous playback ...

This is my situation :

I've got 1 macro that has a playbutton on my menubar.
It functions as a "main menu" for my configurator.
The user has 3 options to pick.

Once the desired product is selected, the main macro unloadsitself, and launches a seperate macro designed to configure/drawthe chosen product.

This macro opens an assy, runs (alters dimensions, features etc)then rebuilds the assy.
After this the macro unloads itself and opens the "mainmenu"-macro.

When i choose to do another config/run, it once again unloadsitself , loads the config macro, runs the config macro and does aforceRebuild. Only this time it crashes the VBA and halts all .

There is quite some time between the 2 rebuilds .. i'm not surewhat goes wrong here ..

Any ideas are allways more then welcome !
greets,
BertSolidworksApi macros
Answers 5
JB
JB 2009-03-17 Best Answer
I think your problem is that you are stacking up macrosinside of each other. When you run macro "B" using RunMacro insideof macro "A", macro "A" doesn't actually finish or unload frommemory untilafter macro "B" finishes running. Then you're running macro"A" again inside of macro "B", then running "B" inside of thesecond instance of "A".

It sounds to me like you need to better manage your program flow. Iwould recommend that all your code reside in one macro file ratherthan two. If you need to better organize your code, use multiplemodules inside the same file.
SF
SF 2009-03-17
Hmm yes. That just might be it really.
Problem is that its getting tough on organising it all.
It all started out as 1 macro, but the several jobs it did allreadywhere using several methods ..

i've added a simple diagram (in attachment) on how it "works" now.
But i think you're right, i'll have to go back and put it in 1macro, and reorganise it to bits !


JB
JB 2009-03-17
That diagram may be how it's "supposed to" work, but the wayit works now is that the red arrows that you think point back up tothe "menu" macro actually point down to a new instance of the"menu" macro. The macros really don't "unload". To verify this,immediately after the RunMacro line, put a message box. The messagebox will never be displayed! This will tell you that the macronever actually unloads.
SF
SF 2009-03-18
to josh,

I agree, use msgbox, or pass boolean return to check the macrosloaded or not.
JS
JS 2009-03-18
Bert-

You might try using VSTA rather that VBA. I'm no expert, but Ithink that it does a better job sequencing things. I've hadproblems with VBA and solidworks events that VSTA fixed--theseshowed up with swx2009 64.

-Jason S.