Just to add to a discussion following recorded Macro in R16SP4 doesn’t work when you try to replay it but returns an error. I recorded following steps in the Macro
1 Open process file
2 Start “Generate APT Source Interactively”
3 Close the process
End of recording
Language="VBSCRIPT"
Sub CATMain()
Set documents1 = CATIA.Documents
Set processDocument1 = documents1.Open("C:\processname.CATProcess")
Set manufacturingAPTGenerator1 = processDocument1.GetItem("Manufacturing Program.1") ‘Here is where error occurs
manufacturingAPTGenerator1.InitFileGenerator "APT", "c:\Temp\filename.aptsource", manufacturingGeneratorData1
manufacturingAPTGenerator1.RunFileGenerator manufacturingGeneratorData1
manufacturingGeneratorData1.ResetAllModalValues
Set processDocument1 = CATIA.ActiveDocument
processDocument1.Close
Set productDocument1 = CATIA.ActiveDocument
productDocument1.Close
End Sub
When I change the code to a version below, which is equivalent of VB program in first post, error occurs in different place… So what would be working version of the script for this task? Any thoughts?
Language="VBSCRIPT"
Sub CATMain()
Set documents1 = CATIA.Documents
Set processDocument1 = Documents1.Open("processname.CATProcess")
Set mfgSelection = processDocument1.Selection
mfgSelection.Search "Name='Manufacturing Program.1',all"
Set manufacturingAPTGenerator1 = mfgSelection.Item2(1).Value
'Set manufacturingAPTGenerator1 = processDocument1.GetItem("Manufacturing Program.1")
manufacturingAPTGenerator1.InitFileGenerator "APT", "c:\Temp\filename.aptsource", manufacturingGeneratorData1 ‘Here is where error occurs in this case
manufacturingAPTGenerator1.RunFileGenerator manufacturingGeneratorData1
manufacturingGeneratorData1.ResetAllModalValues
Set processDocument1 = CATIA.ActiveDocument
processDocument1.Close
Set productDocument1 = CATIA.ActiveDocument
productDocument1.Close
End Sub
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP