Silo - Tips Catia v5 Scripting With Python and Win32api
Silo - Tips Catia v5 Scripting With Python and Win32api
Pavel Schor
Brno
June 2012
Short introduction for non-programmers
Variable:
- stores numbers, characters,strings, objects..
- variable = address of an object in computer memory
Short introduction for non-programmers
Variable:
- address is managed by the operating system / program environment
Reference: C PROGRAMMING LANGUAGE, Kerninghan, Ritchie
Short introduction for non-programmers
Structures:
- A lot of variables makes program bad readable for humans
- This usually leads to errors, prolongs program development, …
Parent.child=something
Aircraft=struct()
Wing=struct()
Wing.parameters=struct()
Wing.parameters.span=10.0
Wing.parameters.rootChord=0.9
Wing.parameters.tipChord=0.35
Wing.parameters.airfoil = „NACA 2412“
Aircraft.wing=Wing
Short introduction for non-programmers
Functions:
- A lot of lines makes program bad readable for humans
- This usually leads to errors, prolongs program development, …
returnValue=function(input1,..inputN)
function m=getVectorMagnitude(v)
m=( v(1)^2 + v(2)^2 + v(3)^2 )^0.5;
end
a=[1,0,0]
vm=getVectorMagnitude(a)
Short introduction for non-programmers
Objects:
- Contains data and functions
- Functions are called “methods“
- Object is an instance of an class
- Class is a template, which defines the methods and how the data are
stored
- Dot convention is usulally used:
object.data=something
something=Object.method(input1,..inputN)
Short introduction for non-programmers
Python:
- mainly used as a scripting language, but Python code can be packaged into
standalone executable programs.
WindowsAPI:
- API = Application Programming Interface
- Collection of objects, which can be used by programmer
- Examples:
Example:
Spell check is used in word processor and in e-mail application.
If there is a need for e-mail spell checking, the spell check object
from the word processor is called via WinAPI.
- The strategy for working with CATIA from the script is same as the
strategy for working with CATIA using the GUI.
- COM objects require same inputs as the user fills in GUI forms.
- Help is available:
Dassault Systemes/B19/intel_a/code/bin/V5Automation.chm
Scripting the CATIA V5
V5Automation.chm
Using hybridShapeFactory