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!

CATIA VBA Macro GetItem error

Status
Not open for further replies.

Ra214

Aerospace
Feb 10, 2021
2
GB
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.1") and after commenting this, it's mainly through the GetItem("....")

Thanks

Code:
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...

Set processDocument1 = CATIA.ActiveDocument

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

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

manufacturingGeneratorData1.SetLastObjectToGenerate cATMfgPrismaticActivity1

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

manufacturingAPTGenerator1.RunFileGenerator manufacturingGeneratorData1

Set specsAndGeomWindow2 = CATIA.ActiveWindow

Set viewer3D2 = specsAndGeomWindow2.ActiveViewer

Set viewpoint3D2 = viewer3D2.Viewpoint3D

End Sub



 
Replies continue below

Recommended for you

Check your specification tree if "Program1.1" is still there. If it was re-made and named Program1.2 (or something other than what is specifically named in your script) it wont be able to find it.

If you plan on the "Program" not always having the same name, assign it to a variable. In other words, add some code to your script that searches the sepcification tree for that object type (the "program") assign it to a variable. call the variable rather than a specifically named object in your tree.
 
Thanks for the response LucasC.

When I run this macro, "Program1.1" has not been modified, it is still the same and there is no change to "Operation.1" either. For some reason it isn't finding it.

Is there any alternative to using the function GetItem?

Thanks
 
You got unlucky and recorded macro is not able to be replayed.

Actually, this is the case in most scenarios so you better write a script by yourself.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top