You are on page 1of 21

Flux10

Macro creation and application management

Macros

Flux10

Table of Contents
Forward.. ...................................................................................................... ..3
1.Creation of a New Macro ....................................................................................................... .4
1.1 Objective: ...................................................................................................................... 4
1.2 Macro Components and creation stages ........................................................................ 4
1.3 Example..5
1.4 Structure.6
1.5 Process...7
1.5.1 Create.py file...7
1.5.2 Create.txt file.............................................................................................10
1.5.3 Load the macro.11
1.5.4 Run the macro...12
1.6 Create_Line.pfm.12-14
2.Management and execution of macros.......15
Overview15
2.1 Management of macros15
2.2 Macro interface with Flux16
2.3 Running a macro..16
3.

Macros included with Flux V10.X ........................................................................................ 17


Overview ................................................................................................................. 17
3.1 Table of Macros17
3.1.1 Geometry macros.....17
3.1.2 Change of materials macros..18
3.1.3 Import materials macros.......18
3.1.4 Physics macros....19
3.1.5 Post Processing macros20

This document outlines the process of Macro creation, installation, activation and execution in Flux V10
software, New 2D and 3D

Page

Macros

Flux10

Forward

Overview:

This document gives a concise, step by step, explanation of macro creation


and execution for use in Flux V10.X software.
A macro is a Pyflux function with parameters. The macro is a command
script, added to the Flux application interface to streamline repetitive
operations.
Macro's can be created by users. Several Macro's are shipped with the
program and can be found in the C:\Cedrat\Extensions\Macros directory
once the program is installed. Macros are described in Chapter 3 of this
document.
A macro can be activated and executed automatically once it is loaded into the
Flux interface.
A macro groups several Pyflux commands in a given order and enables the user to
input one or more parameters and execute a series of predefined actions.
A macro is loaded using the Extension/Macro menu item. When a macro is
loaded, its associated icon is added to the bar of icons. The macro is also
added to the data tree.( see page 16)
Advantages of using Macros:
Macros make repetitive tasks automatic.
Macros allow the input of geometric items from a table or spreadsheet.
Macros customize Flux for specific applications.
Macros automate treatment for each phase of project development.

Page

Macros

Flux10

1. Creation of a New Macro

Introduction

This Chapter will give a general overview along with a specific example of
writing a Macro.

Contents

This chapter contains the following topics:


Topic
1.1 Objective:

See Page
4

1.2 Macro Components and creation stages

1.3 Example

1.4 Structure

1.5 Process: Create_point.pfm


1.6 Create_line.pfm

7-13
13

1.1 Objective: Write, load and execute a basic Macro in Flux.


The objective is to show on a simple example how to write and use a macro.
This macro makes repetitive tasks, such as entering the coordinates during
the creation of points, easier.
1.2 Macro components:
The Macro consists of a .PFM file containing an icon (.gif) and .py command function,
located by default in the C:\Cedrat\Extensions\Macros directory.
The names of these files should be the same for all three extensions.
a) test1.PFM (contains .gif and .py files)
b) test1.gif
c) test1.py

a.
b.
c.
To write python command and parameterize the command using the macro format see
Sec. 1.4.

Page

Macros

Flux10

Stages

Description of file

Of
Creation
1

Required
applications
for macro creation

Creation of the macro definition .py file

Text editor (see Idle


Editor download link
pg.6)

Creation of the image-formatted file for the


associated icon (optional but recommended)

Image editor (.gif)


Paint, Clip-Art etc.

Loading of the macro into the Flux project

Flux

Execution of the macro

Flux

1.3 Example

Description

The Create_point.PFM macro is designed to automatically create 3D points


starting from a series of coordinates previously saved in a text file.
The file name and the coordinate system for definition of the points are
selected by the user during the execution of the macro.
* The definition of a macro requires good knowledge of Pyflux commands and
basic macro programming.
To define the macro in the Pyflux language
Step

Action

Type a header of executable Flux program

Describe input parameters of the macro

Define the Polypoint3D parameterized function in the PyFlux


language

Save the file of the macro under the name Polypoint3D.py in


the Polypoint3D.PFM directory.

1.4 Structure The structure of a file defining the macro (*.py) is presented in the example
below.
Page

Macros

Flux10

The Idle .py editor is the most efficient tool to use for writing pyflux scripts.
To download the python tutorial and IDLE .py editor.
http://www.python.org/
(useful when constructing .py files and macros)
The macro can be broken into 3 sections.

(1) Program
header

Part

Description

Header of an executable Flux program

Description of input parameters of the macro

Definition of a parameterized function in the PyFlux language

The Flux program header is compulsory. It specifies which Flux program (2D
and/or 3D) will execute the macro and its version*.
* The indicated version can correspond to the current software version or a
previous version.

(2) Description of This second section deals with the description of the input parameters of the
macro.
parameters
For each parameter it is necessary to define:
A parameter name
A Pyflux type
Minimal and maximal values corresponding to
the data structure
A default value or a keyword None
A label associated to the parameter
(this label appears in the dialogue box for the running macro)
(3)
Parameterized
function

This third section contains the description of the parameterized function.


For this function it is necessary to define:
Page

Macros

Flux10

A function name (= name of the macro)


Input parameters of the de function
Body of the function (PyFlux instructions)
By default these files are kept in the C:\Cedrat\Extensions directory.
You can create a new directory for them and navigate to the location
when you activate the macro.

1.5 Process:
1.5.1 Create the .py file
We will examine the steps necessary in creating the

Create_point.PFM for use in the macro interface of Flux 3D.

Page

Macros

Macro .py input

Flux10

Function description: *(Python IDLE used in this


example IDLE download: http://www.python.org ;
color coding is using IDLE Classic color setting)*
1) Header #! This statement designates the
compatible Flux Version. (The macro may
be executed from PreFlu 3D 9.31 through
the present release) red=python item
History: Date and Author M/Y/D
Allows direct use of python debugger module
elements. (pydb) Python Debugger (IDLE
download)
Python keywords in orange**.
Python definitions in blue.
A class is created to handle: User Exceptions

attributes definition in green

**def: user function

Page

Macros

Flux10

2) Description of input parameters for the


macro:(main attribute definition)
@param filename: Attribute definition for the input
field.
File: Required input source in Pyflux syntax
(Pyflux type)
1 1 : input range (min-max)
File defining points : (field interface label)
None : (default entry)

@ param coordSys: Attribute definition for the


inputs required in a field
CoordSys: Required input source in Pyflux
syntax(Pyflux type)
1 1: input range (min,max)
Coordinate system: (field interface label)
[XYZ] :(default entry for coordinate system)

3a)Parameterized Function interface: Definition


of the Polypoint3D function interface with 2
parameters (keyword/definition/functions)
(parameters that define the file name and the
coordinate system)

Page

Macros

Flux10

Example of input file:


Note inserted describing the creation and set-up of
the point coordinate input file with an example of
the formatted input (.txt file format).

(n+1) refers to the Id x y z heading line and


subsequent point and coordinate lines in 4
columns.

*This input file will be requested from the macro interface once the macro is loaded.
Input files are not necessary for all macros. This is dependent on the input format for the input
parameters. In this case geometric coordinates are required and are input using the .txt file.
The point.txt file is presented as follows:
Locate this in your project folder and navigate to it using the macro input interface.

To save the coordinates of points from Flux to a in text file:


type data in the form of a table
(You can export geometric .py data directly from Flux 2d and 3D as a .txt or excel export).

extract point data and save the file under the name point.txt
Page 10

Macros

Flux10

3b) Python parameterized command:


Creation of the variable f.
reference for the file input/output
creation of a for loop to iterate through all of the
file lines

# Get coordinate command followed by:


The creation of variable coordinates which takes
values from the list of strings for each file line
**purple commands indicate built in function
creation of the points with the following
characteristics:
color = white
visibility = visible
coordinates = inputs coordinates from
points.txt (0, 0, 0); (3, 0, 0); (3, 2, 0);
(2, 2, 0); (2, 1, 0); (1, 1, 0); (1, 2, 0); (0, 2, 0)
nature = standard
User Exception definition
*You can check for proper formatting of the python file by using Run/Check Module in the Idle
editor. For more information on IDLE go to the IDLE Help menu.
Place the .py and .gif files in a .PFM folder of the same name
Place in the default in the C:\Cedrat\Extensions\Macros directory

Page 11

Macros

1.5.2

Flux10

Select the Load command in the Extensions/ Macro menu


or in the contextual menu of the macro

Load the
Macro

1.5.3
Run the macro
Click on the Run command in the contextual menu of the macro
Fill out the fields in the dialog box Polypoint3D
After running the Polypoint3D macro, the user has the following 8 points in
his Flux project
(0, 0, 0), (3, 0, 0), (3, 2, 0), (2, 2, 0), (2, 1, 0), (1, 1, 0), (1, 2, 0), (0, 2, 0).

Page 12

Macros

Flux10

1.6 Create_line.pfm

Following the execution of the Create_point.pfm


Load the Create_line.pfm to connect the points to form a cubic base.

Create Line .PFM Follows same format as Create_point.PFM

Page 13

Macros

Flux10

#1
Header

#2 parameter
input interface
definition

Example of
input file

#3 a) Parameterized
Function interface

#3 b) Pyflux command
script

Page 14

Macros

Flux10

2. Management and execution of Macros

Overview

This section describes the steps required to manage and execute existing
macros.

Contents

This section contains the following topics:


Topic
Management of macros, Flux commands
Macro interface with Flux
Running a macro

2.1 Management
of macros

See Page
15
16
16

The user can load, unload and reload macros within the
project.
The Flux commands for the management of macros are
located in the Extensions menu. (see screenshots)

Load, Run, Unload, Update.

Page 15

Macros

Flux10

All the macros loaded into the Flux project appear:


2.2 Macro
interface with
in the Extensions/ Macros node of the data tree
Flux
in the toolbar (icons)
The loaded macros are saved with the project.

Macro will appear in the General


Data Tree

2.3
Running a
macro

..in the toolbar

The user can run a macro by using the Run command from the macro
contextual menu or by clicking on the corresponding icon. The dialog box
associated to the types of parameters is then displayed.

Page 16

Macros

Flux10

3. Macros included with Flux V10.X


Overview
The following is a list of Macros included in Flux V10 for 2D and 3D with a
brief description of the application

Contents

This section contains the following topics:


Topic
Table of macros contained in Flux 10 and description
Geometry Macros
Change Materials Macros
Import Materials Macros
Physics Macros
Post Processing Macros

See Page
17
17
18
18
19
20

3.1 Table of Macros in Flux 2D and 3D


3.1.1 Geometry Macros
Flux New 2d/3D
Create_Points.PFM

Create_Lines.PFM

Description
Executable macro that
creates cubic point
configuration from a
.txt file input in
3D(example in .py file)
Executable macro
creates lines .txt file
input(example in .py
file

3.1.2 Change Materials


Macros
Flux New 2d
RegLin_ChangeMater.PF
M

Changes the material


associated with a line
region
RegSurf_ChangeMater.PF Changes the material
M
associated with a
surface region
Flux 3D
RegVol_ChangeMater.PF Changes the material
M
associated to a Volume
region.
Page 17

Macros
3.1.3 Import Materials
Macros
Import_RCP_TTableFunc
tion.PFM

Flux10
Description cont.

Imports a table to
describe material
properties: Temp. Vs.
Specific heat (RhoCP
(rho density [kg/m] cp
specific heat capacity
[J/kg/K]))
Import_KT_IsotropicTTa Imports a table to
bleFunction.PFM
describe: Isotropic
Thermal Conductivity
Import_JE_TTableFunctio Imports a table to
n.PFM
describe: Temp Vs.
Rho (density)
Import_BH_NonlinearSpli Imports a property
ne.PFM
table to describe a nonlinear BH curve
Import_BH_MagnetNonli A macro to import the
nearSpline.PFM
B(H) values of a
Magnet Nonlinear
Spline
Import_BH_LinearTTable Imports properties for
Function.PFM
the B(H) values of a
Linear Temp. Table
Function

Page 18

Macros

3.1.4 Physics Macros

Flux New 2d
assignSquirrelCage.PFM

BHSplinetoexcel.PFM

Flux10

Descriptions

This macro will


facilitate assigning
solid conductors
defined in the circuit
module with the
squirrel component to
existing regions.
This macro allows
creating an EXCEL file
from B(H) curve of
spline type. It also
allows computing the
differential
permeability (slope).

Flux 3d
Import_ComposedCoil.PF
M

This macro will


create a non-meshed
composed coil from
coordinates imported
from a .txt file
(example in .PFM)
Create_ComposedCoil_Sp This macro will create
ire.PFM
a helical composed
non-meshed coil with
the input of path
coordinate .txt file
(example in .PFM)

Page 19

Macros

3.1.5 Post Processing


Macros
Flux New 2d
AnimationArrowsFaceRe
gionAC.PFM

animationColorShadeFace
Region.PFM

animationIsolineFaceRegi
onAC.PFM

ColorShadeFaceRegion.P
FM
IsolinesVectorPotential.P
FM

Flux10

Descriptions

This macro creates


image files (.png) for
arrows displayed on
face region(s) at
different phases( in the
range from 0 to 360)
This macro creates .png
files for use in creating
an animation in 2D
(displays color shade
quantity on face region)
This macro creates files
for animation in 2D
(display quantity on
face region) .png
This macro display the
gradient of B on all the
face regions
This macro allows
displaying the isolines
of the magnetic vector
potential on face
region(s)

Flux 3d
animationIsolineVolumeR
egionAC.PFM

This macro creates files


(.png) for animation in
3D (display Isolines in
volume region)
AnimationArrowsVolume This macro creates
RegionAC.PFM
image files (.png) of
arrows displayed on
volume region(s) for
different phases in the
range from 0 to 360
animationColorShadeVolu This macro creates files
meRegionAC.PFM
(.png) for animation of
the color shade of B in
3D (display quantity on
volume region)
Create sensors from
Create_Sensors.PFM
coordinates imported
from a .txt file
Page 20

Macros

Flux10

Page 21

You might also like