scripting in Ansys and Catia

During my investigation of creating a looping script that was able to access all of the different programs on its own and loop (which was my goal) it became nessicary to implement different languages and methods to access the automation features of Ansys and Catia, both of which i was investigating as tools to return stress information. I eventually chose ansys as my tool because of its better compatability with other programs. I was forced to use the workbench environment because i was unable to acheive the same contact results with ansys classical version, ultimately ending the potential to have a fully automated program. I am still working on this, If anyone can help me out to provide a source of documentation for ansys workbench that would be greatly appreciated.  For everyone else who is just curious here is a sample maco written in Fortran (the ansys APDL language) and a sample Catia script written in Visual Basic.

sample Ansys batch file

/BATCH

! /COM,ANSYS RELEASE 11.0    UP20070125       17:33:10    05/08/2008

/input,menust,tmp,”,,,,,,,,,,,,,,,,1

! /GRA,POWER

! /GST,ON

! /PLO,INFO,3

! /GRO,CURL,ON

! /CPLANE,1

! /REPLOT,RESIZE

WPSTYLE,,,,,,,,0

/AUX15

!*

IOPTN,IGES,NODEFEAT

IOPTN,MERGE,YES

IOPTN,SOLID,YES

IOPTN,SMALL,YES

IOPTN,GTOLER, DEFA

IGESIN,’standard’,'igs’,’.\Desktop\iaac 3\scripting\ansys scripts\tube test\tubes process\’

! APLOT

!*

!*

/NOPR

/PMETH,OFF,0

KEYW,PR_SET,1

KEYW,PR_STRUC,1

KEYW,PR_THERM,0

KEYW,PR_FLUID,0

KEYW,PR_ELMAG,0

KEYW,MAGNOD,0

KEYW,MAGEDG,0

KEYW,MAGHFE,0

KEYW,MAGELC,0

KEYW,PR_MULTI,0

KEYW,PR_CFD,0

/GO

!*

! /COM,

! /COM,Preferences for GUI filtering have been set to display:

! /COM,  Structural

!*

FINISH

/PREP7

!*

ET,1,SHELL63

!*

R,1,.01, , , , , ,

RMORE, , , ,

RMORE

RMORE, ,

!*

!*

MPTEMP,,,,,,,,

MPTEMP,1,0

MPDATA,EX,1,,7.0e4

MPDATA,PRXY,1,,.33

MSHAPE,0,2D

MSHKEY,0

!*

FLST,5,2,5,ORDE,2

FITEM,5,2

FITEM,5,-3

CM,_Y,AREA

ASEL, , , ,P51X

CM,_Y1,AREA

CHKMSH,’AREA’

CMSEL,S,_Y

!*

AMESH,_Y1

!*

CMDELE,_Y

CMDELE,_Y1

CMDELE,_Y2

!*

NUMMRG,ALL, , , ,LOW

!*

FLST,2,2,4,ORDE,2

FITEM,2,17

FITEM,2,21

!*

/GO

DL,P51X, ,ALL,

FLST,2,2,4,ORDE,2

FITEM,2,17

FITEM,2,21

!*

/GO

DL,P51X, ,ALL,1

FLST,2,2,4,ORDE,2

FITEM,2,9

FITEM,2,18

DL,P51X, ,ASYM

FLST,2,9,1,ORDE,7

FITEM,2,18

FITEM,2,20

FITEM,2,-23

FITEM,2,180

FITEM,2,-181

FITEM,2,183

FITEM,2,-184

!*

/GO

F,P51X,FX,100

FINISH

/SOL

! /STATUS,SOLU

SOLVE

FINISH

/POST1

!*

! /EFACET,1

! PLNSOL, S,EQV, 0,1.0

!*

! PRNSOL,S,PRIN

! NLIST,ALL, , ,XYZ,NODE,NODE,NODE

! /USER,  1

! /FOC,   1,  0.763705425239    ,  0.264992745895    ,   9.66552488853

! /REPLO

! /VIEW,  1, -0.492889145410    , -0.179965920439    ,  0.851277015910

! /DIST,  1,   9.54167865921

! /ANG,   1,   10.7563724758

! /REPLO

! /DIST,1,1.08222638492,1

! /REP,FAST

! /VIEW,  1, -0.137361939167E-01, -0.709726502987    ,  0.704343387798

! /DIST,  1,   10.1643422280

! /ANG,   1,  -8.50234350480

! /REPLO

! /VIEW,  1,  0.277591718758    , -0.934206138939    ,  0.224057420420

! /ANG,   1,  -54.5633764824

! /REPLO

! /VIEW,  1, -0.732053311299    , -0.284874207643    ,  0.618825205721

! /ANG,   1,   10.7731045152

! /REPLO

! /DIST,  1,   11.4253656115

! /ANG,   1,  -17.4268954848

! /REPLO

! /VIEW,  1,  0.210970106974    ,  0.357060720133    ,  0.909944644526

! /DIST,  1,   11.4434366283

! /ANG,   1,  -2.73724601541

! /REPLO

! LGWRITE,’better for script’,”,’C:\DOCUME~1\erik\Desktop\IAAC3~1\SCRIPT~1\ANSYSS~1\TUBETE~1\TUBESP~1\’,COMMENT

sample catia script intended to create 4 simple pads.

Private Sub CreatePad()

Dim CATIA As INFITF.Application

CATIA = GetObject(, “CATIA.Application”)

If Err.Number <> 0 Then True End If

CATIA = CreateObject(CATIA.Application)

CATIA.Visible = True

End If

Dim arrayOfVariantOfDouble1(8)

arrayOfVariantOfDouble1(0) = 0.0

arrayOfVariantOfDouble1(1) = 0.0

arrayOfVariantOfDouble1(2) = 0.0

arrayOfVariantOfDouble1(3) = 1.0

arrayOfVariantOfDouble1(4) = 0.0

arrayOfVariantOfDouble1(5) = 0.0

arrayOfVariantOfDouble1(6) = 0.0

arrayOfVariantOfDouble1(7) = 1.0

arrayOfVariantOfDouble1(8) = 0.

Dim partDocument1 As PartDocument

partDocument1 = CATIA.ActiveDocument

Dim part1 As Part

part1 = partDocument1.Part

Dim bodies1 As Bodies

bodies1 = part1.Bodies

Dim body1 As Body

body1 = bodies1.Item(”PartBody”

Dim sketches1 As Sketches

sketches1 = body1.Sketches

Dim originElements1 As OriginElements

originElements1 = part1.OriginElements

Dim reference1 As Reference

reference1 = originElements1.PlaneXY

Dim sketch1 As Sketch

sketch1 = sketches1.Add(reference1)

sketch1.SetAbsoluteAxisData(arrayOfVariantOfDouble1)

part1.InWorkObject = sketch1

Dim factory2D1 As Factory2D

factory2D1 = sketch1.OpenEdition()

Dim geometricElements1 As GeometricElements

geometricElements1 = sketch1.GeometricElements

Dim axis2D1 As Axis2D

axis2D1 = geometricElements1.Item(”AbsoluteAxis”

Dim line2D1 As Line2D

line2D1 = axis2D1.GetItem(”HDirection”

line2D1.ReportName = 1

Dim line2D2 As Line2D

line2D2 = axis2D1.GetItem(”VDirection”

line2D2.ReportName = 2

Dim point2D1 As Point2D

point2D1 = factory2D1.CreatePoint(0.0, 0.0)

point2D1.ReportName = 3

Dim circle2D1 As Circle2D

circle2D1 = factory2D1.CreateClosedCircle(0.0, 0.0, 30.0)

circle2D1.CenterPoint = point2D1

circle2D1.ReportName = 4

sketch1.CloseEdition()

part1.InWorkObject = body1

part1.Update()

part1.InWorkObject = body1

Dim shapeFactory1 As ShapeFactory

shapeFactory1 = part1.ShapeFactory

Dim pad1 As Pad

pad1 = shapeFactory1.AddNewPad(sketch1, 20.0)

part1.Update()

End Sub


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button

Leave a Reply