Option Explicit
' COPYRIGTH DASSAULT SYSTEMES 2000
' ***********************************************************************
' Purpose: Read an Analysis document already linked to a CATPart Document
' Define boundaries and loading condition on the Part and launch the
' Computation
' Assumptions: Looks for AnalysisCrank.CATAnalysis linked to Crankshaft.CATPart
' stored in the DocView
' Author:
' Languages: VBScript
' Locales: English
' CATIA Level: V5R6
' ***********************************************************************
Sub CATMain()
' -----------------------------------------------------------
' Optional: allows to find the sample wherever it's installed
dim sDocPath As String
sDocPath=CATIA.SystemService.Environ("CATDocView")
If (Not CATIA.FileSystem.FolderExists(sDocPath)) Then
Err.Raise 9999,,"No Doc Path Defined"
End If
' -----------------------------------------------------------
' Get the collection of documents in session
Dim documents1 As Documents
Set documents1 = CATIA.Documents
' Open the CATAnalysis Document
Dim oAnalysisDocument As Document
Set oAnalysisDocument = documents1.Open(sDocPath & "\online\CAAScdAniUseCases\samples\AnalysisCrank.CATAnalysis")
'_____________________________________________________________________________________
' Retrieve the CATPart document in order to compute the references for preprocessing
Dim PartDocument As PartDocument
Set PartDocument = documents1.Item(2)
' Retrieve the Part from this document
Dim part1 As Part
Set part1 = PartDocument.Part
' Extract the product as input of preprocessing feature.
Dim product1 As Product
Set product1 = PartDocument.Product
' Retrieve the References
Dim referenceBound As Reference
Set referenceBound = part1.CreateReferenceFromName("Selection_RSur:(Face:(Brp:(GSMRotate.2;(Brp:(GSMTranslate.2;(Brp:(Shaft.2;0:(Brp:(Sketch.5;7)))))));None:());GSMRotate.2)")
Dim referenceLoad As Reference
Set referenceLoad = part1.CreateReferenceFromName("Selection_RSur:(Face:(Brp:(GSMRotate.2;(Brp:(GSMTranslate.2;(Brp:(Shaft.1;0:(Brp:(Sketch.4;4)))))));None:());GSMRotate.2)")
'_____________________________________________________________________________________
' Start to scan the existing structure of analysis document: Retrieve the AnalysisManager
Dim AnaManager As AnalysisManager
Set AnaManager = oAnalysisDocument.Analysis
' Retrieve the AnalysisModels
Dim AnaModels As AnalysisModels
Set AnaModels = AnaManager.AnalysisModels
' To work with the first AnalysisModel of the collection
Dim AnaModel As AnalysisModel
Set AnaModel = AnaModels.Item(1)
' Retrieve the AnalysisCases
Dim Cases As AnalysisCases
Set Cases=AnaModel.AnalysisCases
' To work with the first AnalysisCase of the collection
Dim MyCase As AnalysisCase
Set MyCase=Cases.Item(1)
' Retrieve the AnalysisSets
Dim ListSets As AnalysisSets
Set ListSets = MyCase.AnalysisSets
'_____________________________________________________________________________________
' To work with the AnalysisSet of the collection that is typed for Boundary condition
Dim MySet As AnalysisSet
Set MySet = ListSets.ItemByType("RestraintSet")
' Retrieve the AnalysisEntities collection defined on the set
Dim anEntities As AnalysisEntities
Set anEntities = MySet.AnalysisEntities
' Define an Analysis Entity on the set in order to Fix the referencebound of the Part
Dim analysisEntity As AnalysisEntity
Set analysisEntity = anEntities.Add("SAMClamp")
analysisEntity.AddSupportFromProduct product1, referenceBound
'_____________________________________________________________________________________
' To work with the AnalysisSet of the collection that is typed for Load condition
Set MySet = ListSets.ItemByType("LoadSet")
' Retrieve the AnalysisEntities collection defined on the set
Set anEntities = MySet.AnalysisEntities
' Define an Analysis Entity on the set in order to assign a pressure the referenceLoad of the Part
Set analysisEntity = anEntities.Add("SAMMoment")
' Valuate the momentum value and assign it to the reference
analysisEntity.SetValue "SAMMomentVector","", 1, 1, 1, 100000.
analysisEntity.SetValue "SAMMomentVector","", 2, 1, 1, 0.
analysisEntity.SetValue "SAMMomentVector","", 3, 1, 1, 0.
analysisEntity.AddSupportFromProduct product1, referenceLoad
'_____________________________________________________________________________________
' Launch the computation of the Case
MyCase.Compute
End Sub