Invoke GiD

Moderator: GiD Team

Post Reply
juancho150
Posts: 9
Joined: Wed Dec 10, 2014 11:04 pm

Invoke GiD

Post by juancho150 »

Hi to everyone!

i have a little problem that i hope anyone can help me... I´m trying to execute a batch file that generates a geometry and export it to an IGES file, so i already have the batch file and i´m trying to execute it from MatLab, anyone knows if this is possible to do? I was looking in the GiD help manual the section about invoke GiD but i dont know if it is the right way...



Thanks!!!!
User avatar
escolano
Posts: 1922
Joined: Sun Sep 05, 1982 10:51 pm

Re: Invoke GiD

Post by escolano »

It seems that Matlab could execute an external program with its system command.
system('your_exe');

and about GiD, you can execute it from the command line with a batch file input with
gid.exe -b your_batch_file

remember to finish the GiD batch file with the orders to exit GiD:

Code: Select all

...
Mescape quit no escape
'no' is the answer to the possible question to save the GiD model before exit.

and better you can invoke GiD without any window with the -n flag (to create the geometry and export the IGES don't require any window)

gid.exe -n -b your_batch_file

Can read all GiD command line options in the 'GiD reference manual': http://www.gidhome.com/component/manual ... voking_gid
juancho150
Posts: 9
Joined: Wed Dec 10, 2014 11:04 pm

Re: Invoke GiD

Post by juancho150 »

Thanks for the answer but im still having problems
i write:
System('D:\GiD\GiD 12.0.6\gid.exe')
And the program runs, but when i add the batch file it doesnt work im doing this way:
System('D:\GiD\GiD 12.0.6\gid.exe' -b 'E:\Tornillo_Generico_Recto.bch' -n)

Im doing something wrong???
Thanks!!!!
User avatar
escolano
Posts: 1922
Joined: Sun Sep 05, 1982 10:51 pm

Re: Invoke GiD

Post by escolano »

first do the tests from a DOS console, e.g. in a console try:
D:\GiD\GiD 12.0.6\gid.exe -n -b E:\Tornillo_Generico_Recto.bch

once it works the problem is not related to GiD more.
Then try it from matlab, probably this will work (I don't have matlab to test it)
it seems that for matlab you must enclose in single quotes ' ' the whole system command, not each part:

Code: Select all

System('D:\GiD\GiD 12.0.6\gid.exe -n -b E:\Tornillo_Generico_Recto.bch')
try also with paths an and filenames with spaces to do it well, then names must be enclosed with double quotes " "
maybe this is the right syntax in a general case with spaces

Code: Select all

System('"D:\GiD\GiD 12.0.6\gid.exe" -n -b "E:\Tornillo_Generico_Recto.bch"')
Maybe it is necessary something special to protect special characters like \ or " that have a special meaning.
for example in C strings is necessary prefix them with an slash and use \\ and \" respectively to write the special characters \ and "
try also this, protecting from substitutions the \:

Code: Select all

System('D:\\GiD\\GiD 12.0.6\\gid.exe -n -b E:\\Tornillo_Generico_Recto.bch')
and in case of spaces need enclose in double quotes " "

Code: Select all

System('\"D:\\GiD\\GiD 12.0.6\\gid.exe\" -n -b \"E:\\Tornillo_Generico_Recto.bch\"')
and invoking system the command will be dependen on the operating system, something could be different between both platforms.
In Linux instead of \ the file separator is / that is not a problematic charater, (you can try also is this in Windows, some commands also accept its syntax)

Code: Select all

System('D:/GiD/GiD 12.0.6/gid.exe -n -b E:/Tornillo_Generico_Recto.bch')
juancho150
Posts: 9
Joined: Wed Dec 10, 2014 11:04 pm

Re: Invoke GiD

Post by juancho150 »

Its works!!!! Thanks!!!!!
Post Reply