Demo extension with Python code

Michal Stefuca
Michal Stefuca
Altair Employee
edited August 2024 in Altair Exchange

Overview

A simple extension example demonstrating how to link custom Python code to a ribbon icon in HyperMesh. Upon clicking the icon, a message will be printed in the IPython console.

image

Usage/Installation Instructions

1. Unzip the DemoExtensionWithPython.zip

2. Register the extension - File > Extensions and click Add Extension in the Extension Manager dialog

Comments

  • AndreasAltmann
    AndreasAltmann Altair Community Member

    Hello Michal,
    Thanks for sharing.

    When I tried to adapt the example to our environment, I encountered an issue. I received the following error:

    TypeError: myFunc() got an unexpected keyword argument 'charmap'

    The solution was to modify the function definition to include *args and **kwargs:

    def myFunc():             ⇒                def myFunc(*args, **kwargs):
    

    I hope this helps anyone else facing a similar issue.

  • Michal Stefuca
    Michal Stefuca
    Altair Employee

    Hi @AndreasAltmann

    Thank you for adding your comment. You are absolutely right - the functions are internally passed some arguments which they need to be able to "consume".

    FYI We will make sure to include this information in the future documentation updates and in the training package that is currently being worked on.

    Best regards,
    Michal

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.