Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro to run analysis until a displacement vector equals a certain value

Status
Not open for further replies.

jaredsmiller05

Automotive
Nov 12, 2015
5
US
Hello there,

This will be my first post on the forum so thanks for having me!

I am looking to write a catia macro that will run an analysis until the displacement vector that I created equals a value that a user inputs. The way the displacement vector will change is by changing the young's modulus of the part that the pressure is applied to. I know I will need a loop but I do not know how to set up the code to have the analysis continually run until the displacement equals the user input. Below is the code that I have so far, it runs the analysis, then goes and tweaks the young's modulus and then comes back and runs the analysis again. I need to check the value of the displacement vector against the user input after each run and stop the run if the target is reached. I would like to adjust the young's modulus by 5 MPa each time.

Any help would be greatly appreciated.

Code:
Sub CATMain()

Dim analysisDocument1 As AnalysisDocument
Set analysisDocument1 = CATIA.ActiveDocument

Dim analysisManager1 As AnalysisManager
Set analysisManager1 = analysisDocument1.Analysis

Dim analysisModels1 As AnalysisModels
Set analysisModels1 = analysisManager1.AnalysisModels

Dim analysisModel1 As AnalysisModel
Set analysisModel1 = analysisModels1.Item(1)

Dim analysisCases1 As AnalysisCases
Set analysisCases1 = analysisModel1.AnalysisCases

Dim analysisCase1 As AnalysisCase
Set analysisCase1 = analysisCases1.Item(1)

analysisCase1.Compute

Dim documents1 As Documents
Set documents1 = CATIA.Documents

Dim productDocument1 As ProductDocument
Set productDocument1 = documents1.Item("Pad_Compressibility.CATProduct")

Dim product1 As Product
Set product1 = productDocument1.Product

Set product1 = product1.ReferenceProduct

Set product1 = product1.ReferenceProduct

Set product1 = product1.ReferenceProduct

Set product1 = product1.ReferenceProduct

Set product1 = product1.ReferenceProduct

Set product1 = product1.ReferenceProduct

Dim partDocument1 As PartDocument
Set partDocument1 = documents1.Item("APT_Pad_Mold_Inner (working).CATPart")

Dim part1 As Part
Set part1 = partDocument1.Part

Dim parameters1 As Parameters
Set parameters1 = part1.Parameters

Dim dimension1 As Dimension
Set dimension1 = parameters1.Item("Pad Modulus")

dimension1.Value = 1000000000#

analysisCase1.Compute

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top