I actually wanted to do my PhD in Catia with this, but the problem turned out to be less tricky than it seemed.
I wrote a batch script that makes it possible to convert step files in Explorer.
The prerequisites are a working Catia installation and an available Step license.
The batch script creates an XML file with the same structure as Tools/Utilities/Batch-DXF-IGES-STEP when Save is pressed instead of Run.
This XML is used to start the Tools/Utilities/Batch-DXF-IGES-STEP process independently via the CATBatchStarter.
The process is executed in a DOS window, draws a Catia license and the step license for the duration of the conversion and releases them again immediately after completion.
If a Catia instance is already running, no additional license is used (if the same license configuration is used).
Thus, it is possible to convert step data without manually applying the step license.
Since some information about the Catia installation has to be collected, I instruct a macro to generate the batch file.
Features
The new files are stored in the same location.
Drag'n'Drop is implemented.
Linking of step files via “Open with” is possible (for double-click)
Multifile support is implemented for drag'n'drop (with multifile/“Open with”, however, a separate process is triggered for each file).
Catia files to Step is implemented.
If no Step license is available, the script waits 30 seconds and starts the process again (3 attempts).
Weaknesses of the program:
“Open with” of multiple files starts a separate process for each file. (With multi-drag'n'drop, ONE process is started, which processes all files one after the other).
Error handling for unsupported formats is not implemented, as two loops are currently run through that do not communicate with each other. A separate string is needed to create the output section within the loop of the input section and to discard invalid file types.
Not all supported formats are implemented, as querying the file types in upper and lower case results in a disgusting litany in the source code. I am not aware of an elegant case query and a simple UCASE in the batch.
The script is restarted three times for every error that occurs. This could also be an incorrect input file. The message is always “Step license not available”.
The actual procedure is really simple, which is why I assume that a large number of new implementations will be created in the next few days/weeks in the favorite languages of the respective programmers.
And since a program idea cannot be protected by a software license, I'll save myself the trouble of naming a license. Nevertheless, I am happy to receive a note “Inspired by Lionel Hutz at cad.de” or similar.
Here is the content of the batch file:
Code:
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
REM Don't modify the order of the next 6 lines.
REM ------------Local CATIA Settings---------------
SET sLicPack=MD2.slt
SET env_dir=C:\Users\username\AppData\Local\Temp
SET env_file=env_CATIAV5_R32.txt
SET sCATTEMP=C:\Temp\CATIAV5\username\CATTemp
SET install_path=C:\Program Files\Dassault Systemes\B32\win_b64REM -------------File Properties----------------
SET /A count = 0
SET sTimestamp=%date:~6,4%%date:~3,2%%date:~0,2%_%time:~0,2%%time:~3,2%%time:~6,2%
SET sTimestamp=%sTimestamp: =0%
REM Add a random number to filename to avoid overwriting of xml when using File-open-dialog on multiple files.
SET sBatchfile=Batch_stp_%sTimestamp%_%Random%.xml
SET BatchFileFull=%sCATTEMP%\%sBatchfile%
ECHO.^<?xml version="1.0" encoding="UTF-8"?^>> %BatchFileFull%
ECHO.^<^^!DOCTYPE root SYSTEM "Parameters.dtd"^>>> %BatchFileFull%
ECHO.^<root batch_name="BatchDataExchange" user="" password="" env="" version="" licfile="" ^>>> %BatchFileFull%
ECHO.^<inputParameters^>>> %BatchFileFull%
REM Create input section of xml-file
FOR %%A IN (%*) DO (
SET sFilePath=%%~A
ECHO.^<file id="FileToProcess" destination="" filePath="!sFilePath!" type="bin" upLoadable="RightNow" automatic="1"/^>>> !BatchFileFull!
)
ECHO.^</inputParameters^>>> %BatchFileFull%
ECHO.^<outputParameters^>>> %BatchFileFull%
REM Create output section of xml-file
FOR %%A IN (%*) DO (
SET sInputFiletype=%%~xA
SET sfolderPath=%%~dpA
SET sfolderPath=!sfolderPath:~0,-1!
ECHO %%A
ECHO %%~xA
REM ECHO sInputFiletype !sInputFiletype!
IF "!sInputFiletype!" == ".stp" (
SET sOutputFiletype=CATPart/CATProduct
) ELSE (
IF "!sInputFiletype!" == ".step" (
SET sOutputFiletype=CATPart/CATProduct
) ELSE (
IF "!sInputFiletype!" == ".STP" (
SET sOutputFiletype=CATPart/CATProduct
) ELSE (
IF "!sInputFiletype!" == ".STEP" (
SET sOutputFiletype=CATPart/CATProduct
) ELSE (
IF "!sInputFiletype!" == ".CATProduct" (
SET sOutputFiletype=stp
) ELSE (
IF "!sInputFiletype!" == ".CATPart" (
SET sOutputFiletype=stp
) ELSE (
SET sOutputFiletype=unsupported
))))))
ECHO OutputFiletype !sOutputFiletype!
SET /A count += 1
ECHO.^<folder id="OutputFolder" destination="!sfolderPath!" folderPath="!sfolderPath!" type="bin" upLoadable="RightNow" extension="*" automatic="1"/^>>> !BatchFileFull!
ECHO.^<simple_arg id="OutputExtension!count!" value="!sOutputFiletype!"/^>>> !BatchFileFull!
)
ECHO.^</outputParameters^>>> %BatchFileFull%
ECHO.^<PCList^>>> %BatchFileFull%
ECHO.^<PC name="%sLicPack%" /^>>> %BatchFileFull%
ECHO.^<PC name="ST1.prd" /^>>> %BatchFileFull%
ECHO.^</PCList^>>> %BatchFileFull%
ECHO ^</root^>>> %BatchFileFull%
ECHO xml %BatchFileFull% erstellt.
REM ----------Execute Catia batch-------------
SET CounterAttempts=3
SET ERRORLEVEL = 0
REM ECHO ERRORLEVEL=%ERRORLEVEL%
ECHO Conversion will be started.
:loop
%install_path%\code\bin\CATSTART.exe -run "CATBatchStarter -input %BatchFileFull%" -env %env_file% -direnv %env_dir%
IF %ERRORLEVEL% NEQ 0 (
SET /a CounterAttempts=%CounterAttempts%-1
IF %CounterAttempts% GTR 0 (
ECHO No Step License available at this moment.
timeout /T 30
goto loop
) ELSE (
ECHO.
ECHO ------No Step License available at this moment. Please try again later.-----
ECHO.
goto exitloop
)
) ELSE (
DEL %BatchFileFull%
ECHO.
ECHO ----------BATCH SUCCHESSFULL FINISHED-----------
)
:exitloop
endlocal
REM pause
goto :end
The structure of the XML file looks like this.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE root SYSTEM "Parameters.dtd">
<root batch_name="BatchDataExchange" user="" password="" env="" version="Catia Version and Build Date deleted]" licfile="" >
<inputParameters>
<file id="FileToProcess" destination="" filePath="C:\Temp\SomeStep.STP" type="bin" upLoadable="RightNow" automatic="1"/>
<file id="FileToProcess" destination="" filePath="C:\Temp\SomePart.CATPart" type="bin" upLoadable="RightNow" automatic="1"/>
<file id="FileToProcess" destination="" filePath="C:\Temp\SomeDrawing.CATDrawing" type="bin" upLoadable="RightNow" automatic="1"/>
</inputParameters>
<outputParameters>
<folder id="OutputFolder" destination="C:\Temp\" folderPath="C:\Temp\" type="bin" upLoadable="RightNow" extension="*" automatic="1"/>
<simple_arg id="OutputExtension1" value="CATPart/CATProduct"/>
<folder id="OutputFolder" destination="C:\Temp\" folderPath="C:\Temp\" type="bin" upLoadable="RightNow" extension="*" automatic="1"/>
<simple_arg id="OutputExtension2" value="stp"/>
<folder id="OutputFolder" destination="C:\Temp\" folderPath="C:\Temp\" type="bin" upLoadable="RightNow" extension="*" automatic="1"/>
<simple_arg id="OutputExtension3" value="dwg"/>
</outputParameters>
<PCList>
<PC name="MD2.slt" />
<PC name="ST1.prd" />
</PCList>
</root>
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP