CATIA VBA Macro GetItem error

Ravi Bilkhu

CATIA VBA Macro GetItem error

Hello,

I am trying to learn Macro's in CATIA and attempted by starting to record VBA Macros in Advanced Machining for a simple operation.

I am trying to save the video result of the operation but when I run the recorded Macro I get an error stating that "The method GetItem failed.

This is the code and the error is thrown in Set manufacturingProgram1 = processDocument1.GetItem("Program1") as highlighted in red.

Thanks for any help or suggestions.

 

Language = "VBSCRIPT"

 

Sub CATMain()

 

Set settingControllers1 = CATIA.SettingControllers

 

Set visualizationSettingAtt1 = settingControllers1.Item("CATVizVisualizationSettingCtrl")

 

Dim boolean1

boolean1 = visualizationSettingAtt1.NoZBufferSelectionMode

 

visualizationSettingAtt1.NoZBufferSelectionMode = False

 

Set specsAndGeomWindow1 = CATIA.ActiveWindow

 

Set viewer3D1 = specsAndGeomWindow1.ActiveViewer

 

Set viewpoint3D1 = viewer3D1.Viewpoint3D

 

Dim manufacturingGeneratorData1

' No resolution found for the object manufacturingGeneratorData1...

 

Dim processDocument1

Set processDocument1 = CATIA.ActiveDocument

 

Dim manufacturingProgram1

Set manufacturingProgram1 = processDocument1.GetItem("Program.1")

 

Set cATMfgPrismaticActivity1 = manufacturingProgram1.GetItem("Operation.1")

 

manufacturingGeneratorData1.SetLastObjectToGenerate cATMfgPrismaticActivity1

 

Set manufacturingAPTGenerator1 = processDocument1.GetItem("Program.1")

 

manufacturingAPTGenerator1.RunFileGenerator manufacturingGeneratorData1

 

Set specsAndGeomWindow2 = CATIA.ActiveWindow

 

Set viewer3D2 = specsAndGeomWindow2.ActiveViewer

 

Set viewpoint3D2 = viewer3D2.Viewpoint3D

 

End Sub

Kevin Arnold

RE: CATIA VBA Macro GetItem error
(in response to Ravi Bilkhu)

Set manufacturingProgram1 = processDocument1.GetItem("Program.1").Value

Kevin Arnold

RE: CATIA VBA Macro GetItem error
(in response to Kevin Arnold)

 

Dim myProcessDoc As PROCESSITF.ProcessDocument

Dim myPPRDocument As PPRDocument

Dim myProcess As ManufacturingProcess

 

myProcessDoc = CATIA.ActiveDocument

myPPRDocument = myProcessDoc.PPRDocument
myProcess = myPPRDocument.Processes.Item(1)

 

Dim theSetup as integer

Dim mySetup As MANUFACTURING.ManufacturingSetup
mySetup = myProcess.Setups.GetElement(theSetup)

 

Dim myProgram As MANUFACTURING.ManufacturingProgram

Dim I, J as integer

myProgram = mySetup.Programs.GetElement(I)

myActivity = myProgram.Activities.GetElement(j)

Ravi Bilkhu

RE: CATIA VBA Macro GetItem error
(in response to Kevin Arnold)

Thanks for the response on this.

I have tried to replace the script in VBA and a Run-Time error ('91') (Object variable or With block variable not set) occurs in this line.

myProcessDoc = CATIA.ActiveDocument

Many thanks,

Samarinder Singh Cheema

RE: CATIA VBA Macro GetItem error
(in response to Ravi Bilkhu)

Hi,

Try this.

Set myProcessDoc = CATIA.ActiveDocument

Regards,
Samarinder Singh Cheema