Macro features and component configurations

This may be a bonehead question. Should I expect to be able to change a component's configuration with a macro feature in an assembly? When I try it, SW thinks for a second, then crashes with an unhandled error.

My only theory is that changing the configuration causes the assembly to rebuild while the macro is running, essentially in the middle of a rebuild. I may be wrong. RedLight was not able to stop this.

Reading through the API help, I saw warnings about limitations on what macro features may modify. I didn't see anything to convince me that this shouldn't be possible. I didn't see anyhting to convince me that it absolutely should be possible either. Does anyone happen to know?

Reply to
Dale Dunn
Loading thread data ...

I think your theory is correct. The macro feature is run as a part of each rebuild, and a change in configuration calls a rebuild in that configuration. And so it loops back on itself...sounds almost like the plot for an episode of Star Trek...


Reply to
Brenda D. Bosley

this happens if your macro starts a rebuild, as SW already is rebuilding...

It wasn't designed to do so. I remember having experimented a bit, and found this : If a macro feature tries to start a rebuild, SW crashes even before issuing a RegenNotify, which means you cannot use the RedLight trick to block the second rebuild.

This greatly limits the use of macro features. In fact I'm aware of no commercial product using them...

However, I had a simple idea to circumvent this which I plan to try one of these days: postpone the macro-generated rebuild until the main rebuild is over. It would work like this (sorry, C++...)

1) the macro-feature rebuild method would push a pointer on its "execute" method on a queue 2) when RegenPostNotify occurs, add-in would PostMessage itself a "RegenReallyOverNotify", because you aren't allowed to start a new rebuild in the RegenPostNotify handler.... 3) RegenReallyOverNotify handler would block the rebuilds using RedLight's trick, then call all the "execute" methods in the queue, then re-enable rebuilds, and rebuild the whole thing.

I think it should work...

Reply to
Philippe Guglielmetti

Have you tried

"Referenced Configuration Example (VB)" in the Help file?

"This example demonstrates how to change the configuration of a component in an assembly without opening the part." I need to do this and am just going to try now.

Regards Tony O'Hara

Reply to

That's the method I was trying to use. It works just fine in a normal macro. Just not in the middle of a rebuild, apparently.

Reply to
Dale Dunn

You're right, this does severely limit macro features. It does make sense though, now that I've run up against it. For some reason, it didn't click in my head that changing a configuration would trigger an unavoidable rebuild.

Thanks for the confirmation of my theory. I'd try your idea in C++, except it's in C++.

I guess I'll have to try another tactic. Maybe a add-in to make the configuration changes after a rebuild event. I don't like the idea of causing another rebuild though.

Reply to
Dale Dunn

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.