Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

OnNew Work Feature Event

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
bLennitz
570 Views, 7 Replies

OnNew Work Feature Event

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?

7 REPLIES 7
Message 2 of 8
bLennitz
in reply to: bLennitz

I have still unable to find how to do this. Does anyone have a suggestion?
Message 3 of 8
nmunro
in reply to: bLennitz

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
bLennitz
in reply to: nmunro

So Inventor won't give me the feature via event? This method of getting last feature has potential for getting wrong feature I believe.
Message 5 of 8
nmunro
in reply to: bLennitz

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
bLennitz
in reply to: nmunro

Thanks, it was not the answer I hope for but at least I know I can not do it as I wish.
Message 7 of 8
rjay75
in reply to: bLennitz

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.

 

 

Message 8 of 8
bLennitz
in reply to: rjay75

These events do not fire when adding a work feature such as work point or work plane.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report