Macro feature and cosmetic thread

Macro feature and cosmetic thread

Post by Dale Dun » Mon, 23 Feb 2004 05:00:26

Hello VBA geniuses...

I'm working on a macro feature that creates a body in a part document. I
will eventually need to apply a cometic thread to this body. What is the
best way to approach this? I'll need to drive the dimensions of the
cosmetic thread somehow from the macro feature.

I can add geometry to the macro feature's body, then use equations attached
to driven dimensions to drive the thread dimensions. That leaves the
cometic thread one rebuild behind. That's not acceptable.

I see that the macro feature can have display dimensions, but I don't see
any documentation on how to use those. If I knew how to do that, I could
connect the thread to those with an equation, and the thread should stay
current (I think).

Also, how can I make sure that the cosmetic thread stays attached to the
correct edge on the macro feature's body? The body generated by the macro
feature may change shape, and I'm afraid the cosmetic thread might become
attached to the wrong end of the body or go dangling.

If I can't guarantee an edge for the cosmetic thread to attach to, I
suppose I could create another macro feature body which would never change
shape. Therefore, the edge should never change, and the cosmetic thread
should stay put (I think).

Thanks in advance for any advice or redirection.

Macro feature and cosmetic thread

Post by Heikki Lei » Tue, 24 Feb 2004 14:12:36

> Hello VBA geniuses...

I might be wrong, but if I remember correctly, macro features are not
allowed to create another features (and cosmetic thread is a feature).
Creating new features and altering model dimensions during model rebuild is
a bit unethical, since rebuilding should should update the model. If the
dimensions are altered during rebuild, the model is not up-to-date after
rebuild and subsequent rebuilds are needed to clear the green lights from FM



Macro feature and cosmetic thread

Post by Philippe G » Tue, 24 Feb 2004 15:27:32



It might even crash SW.


The trick is :
1) to abort the rebuild when it occurs by trapping the "RegenNotify" event
and return S_FALSE (see apihelp)
2) use the PostMessage Windows API to queue a custom event (tricky in VB,
e-mail me if you need help)
3) handle your custom event (will happen once the rebuild is over) to do
everything you need
4) call Rebuild or EditRebuild, but don't abort it this time.

Would be simpler if MacroFeature had BeforeRebuild and AfterRebuild
Maybe people would even start using MacroFeatures...
Philippe Guglielmetti -

Macro feature and cosmetic thread

Post by Dale Dun » Tue, 24 Feb 2004 21:42:22

Hmm. I hope that's not the only route I can take to get this done.

I wasn't planning on having the macro feature insert the cosmetic thread. I
was going to add it myself after the macro feature is created. My problem
is to somehow expose some data so that the cosmetic thread dimensions can
be driven either by an equation or by dimension linking. In such a way that
only one rebuild (by the user) is needed. Also, I need to make sure that
the cosmetic thread stays correctly attached to the macro feature.

As for the number of people using macro features... At first I was ignorant
of the limitations of the macro feature. If I think of it as a user-defined
feature, it makes sense to me that it can't cause a new feature to be
built, or modify another feature. What discourages me about macro features
is how to implement them. It feels like you have to jump through a lot of
hoops to get it all working. Again, most of this seems justifiable, after I
understand more of the structure of what's going on.

What is terribly frustrating is the documentation of some of the features
of the API. I can't find it. Specifically, the documentation makes it clear
that a macro feature can have display dimensions. There is no explanation
of how to actually do this. Maybe I'm just ignorant. This is particularly
frustrating, because a display dimension on the macro feature could be used
to drive the dimensions of the cosmetic thread.

Macro feature and cosmetic thread

Post by Philippe G » Tue, 24 Feb 2004 22:14:58

here I don't get it. There is nothing wrong in letting a feature modify
things in child features (listed afterwards in feature tree) : Equations,
Design Tables or Sheetmetal functions do exactly this. I'd love to made my
own "Equations" feature with full VBA support...


No you're not ;-) MacroFeatureData::GetDisplayDimensions was just
implemented (SW2004). If you look at the MacroFeature API, you'll see it
changed a lot since SW2003, and it will probably (hopefully) evolve further.
Ask apisupport for specific help, they're very helpful.

What I feel frustrating is that SW Corp isn't clear about their intent. The
first time I heard about macro features was in a survey for partners where
they asked "do you plan to use macro features?" They never explained what
they want to make possible with MFs, what's the strategy, or at least the
intent behind them.
Philippe Guglielmetti -

Macro feature and cosmetic thread

Post by Dale Dun » Wed, 25 Feb 2004 03:01:29

> What I feel frustrating is that SW Corp isn't clear about their

Ok, I'll pester apisupprt for an explanation of that. I was thinking I
should only use them for "problems". Thanks for the pointer. I'll make sure
to ask how to use these.

WRT surveys, I agree that they're often dificult to interpret. I quite
often get through one, then wonder if they questions were asking something
other than what I thought. Part of the survey becomes trying to puzzle out
what's being asked.

I often fill out the comment at the end to try to explain what it is that
*I* am thinking. Just to try to close the communication gap.