cancel
Showing results for 
Search instead for 
Did you mean: 

MenuScript and Python

Creator
Creator

Hi,

 

This is my first post and I am not trying to be confusing.

 

Is it possible to activate a Python script through the the PRE and POST actions of a MenuScript customization?

 

I would like to do "something" before and after the "save" button(s).

The documentation is also a bit confusing about the matter: https://docs.plm.automation.siemens.com/tdoc/nx/10/nx_api/#uid:index_menuscript:exercises_exercise_i...

 

Here, we do two separate modifications in two separate files and then save them with the same name and on the same place ... since the File menu is not application specific, do I need the first part of this code?

 

EDIT UG_GATEWAY_MAIN_MENUBAR
    MODIFY
    CASCADE_BUTTON UG_FILE
    MENU_FILES my_modeling_mods.men
    END_OF_MODIFY


EDIT UG_GATEWAY_MAIN_MENUBAR
    MODIFY
    BUTTON UG_FILE_SAVE_PART
    ACTIONS/PRE test.py
    END_OF_MODIFY

 

 

Best Regards,

lookcho

4 REPLIES

Re: MenuScript and Python

Siemens Phenom Siemens Phenom
Siemens Phenom

No, you do not need the first part.  You do need to be sure that your .men file has a version statement.

 

I tested with this .men file, and it worked as expected:

 

VERSION 120

EDIT UG_GATEWAY_MAIN_MENUBAR
MODIFY
BUTTON UG_FILE_SAVE_PART
ACTIONS/PRE test.py
END_OF_MODIFY

 

Be sure that your .men file is in a valid "startup" folder, and that test.py is in a valid "application" folder.

 

 

Re: MenuScript and Python

Genius
Genius

You can also use the Block UI styler to generater a custom dialog box and python file

 

Developer--> Block UI styler

 

Click on the "code generation" tab and choose Python as your language. You should now have a .dlx file and an associated .py file 

Re: MenuScript and Python

Creator
Creator

Thank you, somehow I missed the part with the subfolders Smiley Happy

It does work now! I will ask again when I hit another obstacle.

Re: MenuScript and Python

Creator
Creator

Yep, I read about that. I will ask particular questions when I get there Smiley Happy