OnNew Work Feature Event

OnNew Work Feature Event

Anonymous
Not applicable
789 Views
7 Replies
Message 1 of 8

OnNew Work Feature Event

Anonymous
Not applicable

Hi. I would like to request my engineers to name all work features as they are created. So, for example, when an engineer creates a new work axis, I will show you a dialog asking axis name. Then I change the name of the property of the work feature to the entered text. I've tried to find an event that tells the program when work feature has been added. I found DocumentEvents onChange event, but it does not give me enough information. I just get the following info from the Context parameter:
Context (0): "Create Work Feature"
Context (1): "Work Feature"
Context (2): 1

This event does not give me a work feature object itself, which I need. How can I get it? Is there another event I missed?

0 Likes
Accepted solutions (1)
790 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
I have still unable to find how to do this. Does anyone have a suggestion?
0 Likes
Message 3 of 8

nmunro
Collaborator
Collaborator
Accepted solution
You have done the hard part already. You now know that a work feature has just been created. You can then get the last created feature in the document, test for the type of work feature, and then present the user with a method to rename it.

        


https://c3mcad.com

Message 4 of 8

Anonymous
Not applicable
So Inventor won't give me the feature via event? This method of getting last feature has potential for getting wrong feature I believe.
0 Likes
Message 5 of 8

nmunro
Collaborator
Collaborator
No, it will not give you the created object. Yes you have to validate that you have the correct feature but it is not difficult. Inventor's event model does have some weak points but it is unlikely they will improve much at least in the short term

        


https://c3mcad.com

Message 6 of 8

Anonymous
Not applicable
Thanks, it was not the answer I hope for but at least I know I can not do it as I wish.
0 Likes
Message 7 of 8

rjay75
Collaborator
Collaborator

Inventor can give you the feature via event. There's a different event to use:

 

ModelingEvents.OnNewFeature( DocumentObject As Document, Feature As PartFeature, BeforeOrAfter As EventTimingEnum, Context As NameValueMap, HandlingCode As HandlingCodeEnum )

 

To do it as things are changed use:

 

ModelingEvents.OnFeatureChange( DocumentObject As Document, Feature As PartFeature, BeforeOrAfter As EventTimingEnum, Context As NameValueMap, HandlingCode As HandlingCodeEnum )

 

The second parameter is the feature for both. You have to cast it to the feature type.

 

The OnChange event is the wrong event to watch for new features or feature changes.

 

 

0 Likes
Message 8 of 8

Anonymous
Not applicable
These events do not fire when adding a work feature such as work point or work plane.
0 Likes