'Run CATIA VBA macro in batch mode from Visual Studio
I have created a VB class to manipulate a CATIA project. The VB code is compiled into a dll loaded into a C# project.
Imports ProductStructureTypeLib
Imports INFITF
Imports MECMOD
Public Class MyCATIAClass
Private catia As INFITF.Application
Public Sub New()
catia = GetObject(, "CATIA.Application")
End Sub
Public Sub doStuff()
' do stuff
End Sub
End Class
And in C#:
MyCATIAClass catOb = new MyCATIAClass();
catOb.doStuff();
This works just fine. My question is: Is it possible to run the method in batch mode? this would significantly increase the performance at run time.
Solution 1:[1]
you better create a batch file (and call the vbfile from inside it) and run it from the c# code by the following code Process.Start("path of your batch file\nameOfBatchFile.bat")
Before that to create a batch file in a note pad write the following commands and save it as fileName.bat
@echo on
cd path of vbfileName
start vbfileName
Solution 2:[2]
In order to execute tasks without visualization, it was enough to set the visible property to false.
Imports ProductStructureTypeLib
Imports INFITF
Imports MECMOD
Public Class MyCATIAClass
Private catia As INFITF.Application
Public Sub New()
catia = GetObject(, "CATIA.Application")
End Sub
Public Sub doStuff()
catia.Visible = False
' do stuff
End Sub
End Class
Solution 3:[3]
start CATIA in Batch: "C:\cv5\B20\win_b64\code\bin\CNEXT.exe -batch -env CATIA.V5R20.B20 -direnv C:\cv5env\CATEnv"
Solution 4:[4]
We can use CATStart for batch mode:
CATSTART.exe –direnv C:\CATEnv –env CATIA.V5R30 -object “-batch -macro C:\Temp\BatchTest\DwgParamBatch.CATScript”
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | nilakantha singh deo |
Solution 2 | Nic |
Solution 3 | Ralf |
Solution 4 | Jeremy Caney |