introduction to the femap api - ata engineering inc · 2015. 6. 23. · 13290 evening creek drive...

23
Date: Prepared by: 13290 Evening Creek Drive South Suite 250 San Diego, CA 92130 T 858.480.2000 F 858.792.8932 www.ata-e.com Introduction to The Femap API June 23, 2015 Kurt Knutson Manager of Software Services ATA Engineering, Inc.

Upload: others

Post on 30-Jan-2021

0 views

Category:

Documents


0 download

TRANSCRIPT

  • Date: Prepared by: 13290 Evening Creek Drive South Suite 250

    San Diego, CA 92130

    T 858.480.2000

    F 858.792.8932

    www.ata-e.com

    Introduction to The Femap API

    June 23, 2015 Kurt Knutson

    Manager of Software Services

    ATA Engineering, Inc.

  • 13290 Evening Creek Drive South, Suite 250, San Diego, CA 92128 | T 858.480.2000 | F 858.792.8932 | www.ata-e.com

    FEMAP API Can Benefit Users with

    Simple to Advanced Needs

    Benefits of the API Include:

    • Automate repetitive tasks

    • Augment or customize existing modeling and post-

    processing functionality

    • Program complexity can range from simple utilities up to

    entire toolboxes to provide new capabilities

    • Ability to interface with external software – Office tools

    Presentation Outline:

    • Introduction to the API – what is it?

    • How to get started

    • ATA examples

    2

  • 13290 Evening Creek Drive South, Suite 250, San Diego, CA 92128 | T 858.480.2000 | F 858.792.8932 | www.ata-e.com

    ATA Uses Femap’s API to Create New Tools

    for General & Industry-Specific Workflows

    Femap’s Application Program Interface (API) allows users to

    customize and create Femap tools for their specific needs

    • The API is an OLE/COM-based programming interface to FEMAP with

    hundreds of functions

    • Codes calling these functions are written in programming languages

    such as Visual Basic, C++, or even Python

    • Can automate manual and tedious processes in Femap

    • Can interact with other software such as Excel or Matlab

    View FEMAP as a development platform where the out of the box

    functionality fits 95% of the users 95% of the way

    • But different companies have different FEA needs & methods of doing

    analysis or specialized interests and requirements

    • The API provides users with the flexibility to automate both routine and

    complex tasks and tailor the software to their specific needs

    3

  • 13290 Evening Creek Drive South, Suite 250, San Diego, CA 92128 | T 858.480.2000 | F 858.792.8932 | www.ata-e.com

    Introduction To The Femap API

    4

  • 13290 Evening Creek Drive South, Suite 250, San Diego, CA 92128 | T 858.480.2000 | F 858.792.8932 | www.ata-e.com

    Terminology, Definitions, &

    Common Questions

    What is an API? – Application Programming Interface

    • In Femap, we often call programs we create using the Femap API,

    API programs, API macros or just APIs for short.

    • The Femap API Programming is the most common way we

    automate tasks in Femap.

    What is OLE/COM?

    • OLE, Object Linking and Embedding: Microsoft's framework for a

    compound document technology.

    • COM, Component Object Model: Microsoft's framework for

    developing and supporting program component objects.

    • These frameworks allow programs to talk with each other and use

    each other’s functions and capabilities.

    – For example, we can use an Excel Visual Basic Macro to load data from

    Femap using the Femap API.

    5

  • 13290 Evening Creek Drive South, Suite 250, San Diego, CA 92128 | T 858.480.2000 | F 858.792.8932 | www.ata-e.com

    Terminology, Definitions, &

    Common Questions

    6

    API can be accessed through the

    API Programming Pane within

    Femap – great for writing

    programs quickly

    You can also write programs in

    Visual Studio – lots of debugging

    tools and easy GUI construction

    You can do this with Visual Studio

    Express

    Where can I use the API?

    • Use the API within Femap or through visual studio

  • 13290 Evening Creek Drive South, Suite 250, San Diego, CA 92128 | T 858.480.2000 | F 858.792.8932 | www.ata-e.com

    Terminology, Definitions, &

    Common Questions

    7

    What kind of programming is the API?

    • API Programs are most often written in Visual Basic, not a

    proprietary command language

    • The FEMAP API is object oriented, meaning interactions with the

    API are performed by querying and manipulating a series of objects

    – Objects have properties and methods

    – Properties describe things about the object,

    – Car.color = red

    – Element.topology = CQUAD4

    – Methods provide a way of interacting with an object

    – Car.drive( 50, “grocery store” )

    – Surface.mesh()

  • 13290 Evening Creek Drive South, Suite 250, San Diego, CA 92128 | T 858.480.2000 | F 858.792.8932 | www.ata-e.com

    Terminology, Definitions, &

    Common Questions

    How can the API and FEMAP interact?

    8

    FEMAP

    API

    1 – Use API as an add-in

    FEMAP API

    2 – Run as two separate applications

    FEMAP API

    3 – Run FEMAP as an invisible server

    4 – Embed FEMAP components in API

  • 13290 Evening Creek Drive South, Suite 250, San Diego, CA 92128 | T 858.480.2000 | F 858.792.8932 | www.ata-e.com

    Visual Basic for Applications (VBA) allows us to directly access

    Femap from Excel, Word or other Microsoft Office tools since they

    they can work with OLE and COM.

    Terminology, Definitions, &

    Common Questions

    • Use EXCEL to Control FEMAP Renumber Entities: Nodes, Elements, Properties, Materials, etc. by layer, color, group, etc.

    Extract Model Information: Mass, Volume, CG, Layer/Group/Color Name, etc., to spreadsheets

    • Output Model Information All Information Displayed in a Formatted Table

    Can Be Easily Transferred to a Stress Report

    9

  • 13290 Evening Creek Drive South, Suite 250, San Diego, CA 92128 | T 858.480.2000 | F 858.792.8932 | www.ata-e.com

    How To Get Started

    10

  • 13290 Evening Creek Drive South, Suite 250, San Diego, CA 92128 | T 858.480.2000 | F 858.792.8932 | www.ata-e.com

    Femap Help Has Full Documentation

    of Objects and Functions

    11

    The FEMAP Help can

    be accessed in the

    top border menu bar,

    HELP --> Help Topics

    Can also access pdf

    version in the Femap

    installation directory:

    {install}\pdf\api.pdf

  • 13290 Evening Creek Drive South, Suite 250, San Diego, CA 92128 | T 858.480.2000 | F 858.792.8932 | www.ata-e.com

    The Femap API Has Some Basic Objects and

    Syntax to Learn – More Resources for Details…

    12

    Go to the Femap User Community

    Search posts for:

    “Introduction to the Femap API”

    For an entire presentation with syntax basics and details…

    Three main types of objects:

    Application Object - Provides access to Femap GUI

    as well as all entity and tool objects

    Entity Objects – Anything created and stored in the

    Femap database, elements, nodes, analysis sets,

    etc.

    Tool Objects – A special class that provide

    functionality and are not stored in the database,

    Data Table, File Reader, Sets, Beam Calculator, etc.

  • 13290 Evening Creek Drive South, Suite 250, San Diego, CA 92128 | T 858.480.2000 | F 858.792.8932 | www.ata-e.com

    Femap Has a Wide Variety of Example

    API programs in “Custom Tools”…

    13

    These tools are frequently API programs

    with examples and source located at:

    {femap install}\api\

    Study, try or debug and examples from here…

    Place your own tools in this folder and they will

    Show up in your Femap session…

    Add your own custom tools or tools

    directory here…Add tools copies your tool

    to the Femap installation directory, Tools

    Directory lets you specify your own

    folder…

  • 13290 Evening Creek Drive South, Suite 250, San Diego, CA 92128 | T 858.480.2000 | F 858.792.8932 | www.ata-e.com

    Femap Has a Built In “API Programming Pane”

    Which Can Be Used to Edit or Debug Programs

    14

    Beginning of the Program…

    Create and Set a Femap

    Application Object

    End of the Program…

  • 13290 Evening Creek Drive South, Suite 250, San Diego, CA 92128 | T 858.480.2000 | F 858.792.8932 | www.ata-e.com

    Make, Toolbars, Shortcuts or Icons to

    Execute API Commands You Like

    15

    Create a new toolbar

    Add a user command

    And then go to

    add Keyboard

    Shortcut if you like

    Drop and Drag

    Commands to toolbar Right click on the tool bar to customize change buttons

  • 13290 Evening Creek Drive South, Suite 250, San Diego, CA 92128 | T 858.480.2000 | F 858.792.8932 | www.ata-e.com

    ATA Examples

    These are available at:

    www.ata-plmsoftware.com

    16

    http://www.ata-plmsoftware.com/http://www.ata-plmsoftware.com/http://www.ata-plmsoftware.com/

  • 13290 Evening Creek Drive South, Suite 250, San Diego, CA 92128 | T 858.480.2000 | F 858.792.8932 | www.ata-e.com

    Example API #1: Save and Load Element,

    Material, Property Colors Across Similar Models

    18

    save_elem_color.bas

    load_elem_color.bas

    .col

    (color file)

  • 13290 Evening Creek Drive South, Suite 250, San Diego, CA 92128 | T 858.480.2000 | F 858.792.8932 | www.ata-e.com

    Example API #2: Freebody Loads

    for Many Groups and Load Cases

    20

  • 13290 Evening Creek Drive South, Suite 250, San Diego, CA 92128 | T 858.480.2000 | F 858.792.8932 | www.ata-e.com

    Example API #3: Automate PPT

    Documentation

    22

    PPT of

    Accelerometer

    Data

    (optional)

    FEM with Many CSYS User Inputs PPT with

    Pictures of

    Accelerometer

    Locations

    Femap API

  • 13290 Evening Creek Drive South, Suite 250, San Diego, CA 92128 | T 858.480.2000 | F 858.792.8932 | www.ata-e.com

    Example API #4: Reflect Element Properties,

    Materials, and Coordinate Systems

    24

    FEM with Multiple

    Properties and Specific

    Material Orientations

    Reflected Model

    Femap API – User Inputs

    Filter on Element Types?

    Filter on Material Types?

    Reflect CS?

    Choose Reflection Plane

  • 13290 Evening Creek Drive South, Suite 250, San Diego, CA 92128 | T 858.480.2000 | F 858.792.8932 | www.ata-e.com

    Example API #5: Write Groups to

    Nastran Files

    26

    FEM with Many Groups Femap API - User Inputs

    .bdf Include

    Files for

    Each Group

    Example output for group export

    in FEMAP message window

  • 13290 Evening Creek Drive South, Suite 250, San Diego, CA 92128 | T 858.480.2000 | F 858.792.8932 | www.ata-e.com

    Final Thoughts About the Femap

    API

    • The easiest way to get started is to pick a simple task

    • Formulate the path with manual operations

    • Identify corresponding Femap API functions and methods

    • Everything you need is in the documentation or examples

    • Femap API code can be written within Femap or with external

    interfaces – learning visual basic syntax is helpful to get started.

    • Don’t forget about debugging and test models

    • Enjoy!

    27

  • 13290 Evening Creek Drive South, Suite 250, San Diego, CA 92128 | T 858.480.2000 | F 858.792.8932 | www.ata-e.com

    Appendix – Using Python With

    Femap

    1. Get the "win32com" module for your version of Python from Source Forge:

    http://sourceforge.net/projects/pywin32/files/pywin32/. With Python 2.6.6, we used

    build 216, so the download was pywin32-216.win32-py2.6.exe. Install it in your

    Python's ~\Lib\site-packages folder.

    2. Use the win32com "makepy" script to translate the Femap TLB into a Python file

    1. [Python_path]\Lib\site-packages\win32com\client\makepy.py -v -o PyFemap.py

    [Femap_path]\femap.tlb

    3. Import "PyFemap.py" in every Python module that will call the API. You MUST use

    "early binding" to get Python to handle the Femap API -- API calls have many

    "output arguments" and Python cannot inherently handle those.

    4. API "output arguments" become return values in Python. So, e.g., where "zOset" is

    an feOutputSet object

    1. VB code: iRet = zOset.GetTitleList (0, 0, nSets, liIDs, lsNams)

    2. Python code: iRet, nSets, liIDs, lsNams = zOset.GetTitleList (0, 0)

    28

    http://sourceforge.net/projects/pywin32/files/pywin32/