GPS ERROR arrayofvariant

Ajar Mazi

GPS ERROR arrayofvariant
Hi all, I got a problem in running macro. I write a macro code to open a few part files automatically, and for each file I do GPS analysis (I create a loop in macro to automatically open and analyse differenr file\part). For the first part/file the macro is doing well but when it open the second part/file an error of 'Description: Type mismatch:'arrayofVariantOfShort1' occured. I dont know whats the problem and really need a help ?(Thanks in advanced Below is my macro code

Sub CATMain()
'i= part & file name

For i = 1 To 3
Dim documents1 As Documents
Set documents1 = CATIA.Documents

Dim partDocument1 As Document
Set partDocument1 = documents1.Open("C:\Documents\trycat\Pocket"&CStr(i)&".CATPart")

Dim part1 As Part
Set part1 = partDocument1.Part

Dim specsAndGeomWindow1 As Window
Set specsAndGeomWindow1 = CATIA.ActiveWindow

Dim viewer3D1 As Viewer Set viewer3D1 = specsAndGeomWindow1.ActiveViewer
Dim viewpoint3D1 As Viewpoint3D Set viewpoint3D1 = viewer3D1.Viewpoint3D

CATIA.StartWorkbench "GPSCfg"

Dim analysisDocument1 As Document
Set analysisDocument1 = CATIA.ActiveDocument

Dim analysisManager1 As AnalysisManager
Set analysisManager1 = analysisDocument1.Analysis

Dim arrayOfVariantOfShort1(0)
arrayOfVariantOfShort1(0) = 1
analysisManager1.ImportDefineFile"C:\Documents\trycat\Pocket"&CStr(i)&".CATPart","CATAnalysisImport", arrayOfVariantOfShort1

viewer3D1.Reframe Set viewpoint3D1 = viewer3D1.Viewpoint3D

Dim analysisModels1 As AnalysisModels
Set analysisModels1 = analysisManager1.AnalysisModels

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

analysisModel1.RunTransition "CATGPSStressAnalysis_template"

Dim analysisSets1 As AnalysisSets
Set analysisSets1 = analysisModel1.AnalysisSets

Dim analysisMeshManager1 As AnalysisSet
Set analysisMeshManager1 = analysisSets1.ItemByType("MSHMeshSet")

Dim analysisImages1 As AnalysisImages
Set analysisImages1 = analysisMeshManager1.AnalysisImages

Dim analysisImage1 As AnalysisImage
Set analysisImage1 = analysisImages1.Add("Mesh", True, True, False)

Dim analysisCases1 As AnalysisCases
Set analysisCases1 = analysisModel1.AnalysisCases

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

Dim analysisSets2 As AnalysisSets
Set analysisSets2 = analysisCase1.AnalysisSets

Dim analysisSet1 As AnalysisSet
Set analysisSet1 = analysisSets2.Item("Restraints.1", catAnalysisSetSearchAll)

Dim analysisEntities1 As AnalysisEntities
Set analysisEntities1 = analysisSet1.AnalysisEntities

Dim analysisEntity1 As AnalysisEntity
Set analysisEntity1 = analysisEntities1.Add("SAMClamp")

Set viewpoint3D1 = viewer3D1.Viewpoint3D

Dim analysisLinkedDocuments1 As AnalysisLinkedDocuments
Set analysisLinkedDocuments1 = analysisManager1.LinkedDocuments

Set partDocument1 = analysisLinkedDocuments1.Item(1)

Dim product1 As Product
Set product1 = partDocument1.Product

Dim reference1 As Reference
Set reference1 = part1.CreateReferenceFromName("Selection_RSurFaceBrpPad.1;2);None);Cf11));Pocket.1_ResultOUT;Z0;G2960)")

analysisEntity1.AddSupportFromProduct product1, reference1

Dim analysisSet2 As AnalysisSet
Set analysisSet2 = analysisSets2.Item("Loads.1", catAnalysisSetSearchAll)

Dim analysisEntities2 As AnalysisEntities
Set analysisEntities2 = analysisSet2.AnalysisEntities

Dim analysisEntity2 As AnalysisEntity
Set analysisEntity2 = analysisEntities2.Add("SAMDistributedForce")

Set partDocument1 = analysisLinkedDocuments1.Item(1)
Set product1 = partDocument1.Product

Dim reference2 As Reference
Set reference2 = part1.CreateReferenceFromName("Selection_RSurFaceBrpPocket.1;0BrpSketch.2;4)));None);Cf11));Pocket.1_ResultOUT;Last;Z0;G2960)")

analysisEntity2.AddSupportFromProduct product1, reference2

Dim basicComponents1 As BasicComponents
Set basicComponents1 = analysisEntity2.BasicComponents

Dim basicComponent1 As CATBaseDispatch
Set basicComponent1 = basicComponents1.GetItem("SAMForceAxis.1")

basicComponent1.SetValue "Values", 0, 0, 0, 1

Dim basicComponent2 As CATBaseDispatch
Set basicComponent2 = basicComponents1.GetItem("SAMForceVector.1")
basicComponent2.SetDimensions 3, 1, 1
basicComponent2.SetValue "Values", 1, 1, 1, 0.000000
basicComponent2.SetValue "Values", 2, 1, 1, 38.000000
basicComponent2.SetValue "Values", 3, 1, 1, 0.000000


Dim analysisSet3 As AnalysisSet
Set analysisSet3 = analysisSets2.Item("Static Case Solution.1", catAnalysisSetSearchAll)

Dim analysisImages2 As AnalysisImages
Set analysisImages2 = analysisSet3.AnalysisImages

Dim analysisImage2 As AnalysisImage
Set analysisImage2 = analysisImages2.Add("Mesh_Deformed", True, False, False)

Dim analysisImage3 As AnalysisImage
Set analysisImage3 = analysisImages2.Add("Disp_Symbol", True, False, False)

Set analysisDocument1 = CATIA.ActiveDocument
analysisDocument1.SaveAs "C:\Documents\trycat\parttogpsPocket"&CStr(i)&".CATAnalysis"

Set analysisDocument1 = CATIA.ActiveDocument

End Sub