NX二次开发源码分享: 通过命令行的方式写外部命令的方法
NX二次开发源码分享: 通过命令行的方式写外部命令的方法对于批量并行运行的命令,可能需要用到调用exe的方式去处理,我们可以通过NX提供的开发函数,快速完成带有参数的命令行方式开发。
uc4624/uc4620 是含有名称的方式比如 , helloplmhome.exe -p=xxx -u=xxx -g=xxx
uc4624/uc4621 是直接的方式,如果一个参数可以,多个的话不是太灵活,helloplmhome.ext xxx xxx xxx
void ECHOUsage()
{
ECHO("Usage: exportAssemblyUtility [-part=<part path>]\t - Specify the input part \n");
ECHO("[-prefix=<prefix name>] \t - Specify the prefix name \n");
ECHO("[-postfix=<postfix name>] \t - Specify the postfix name \n");
ECHO("[-exportoption=<export option name>] \t - Specify the output option \n");
ECHO("[-exportfolder=<output folder name>] \t - Specify the export folder Path \n");
ECHO("[-h=<help>] \t - print the help usage \n");
ECHO("\n");
}
int main( int argc, char *argv[] )
{
tag_t part;
char part_name = {0};
char prefix = {0};
char postfix = {0};
char exportOption = {0};
char exportPath = {0};
char helpStr[] = {0};
logical
nxmanager_mode;
char msg;
UF_PART_load_status_t
status;
bool ispartok,isprefixok,ispostfixok,isoptionok,isfolderok = false;
if (!UF_CALL(UF_initialize()))
{
UF_CALL(uc4624(0, argc, argv));
UF_CALL(UF_TEXT_init_native_lang_support());
UF_CALL(UF_is_ugmanager_active(&nxmanager_mode));
if (nxmanager_mode == true)
{
ECHO("*** You are in NX Integration Environment ***\n ");
}
else
{
ECHO("*** You are inLocal NX Environment ***\n ");
}
/* for (int i = 0; i<argc;i++)
{
printf("argv[%d] = %s\n",i, argv);
}*/
/*uc4621(prefix) == 1 is OPTIONAL */
if (uc4620("part",part_name) == 3)
{
ispartok = true;
}
if (uc4620("prefix",prefix) == 3)
{
isprefixok = true;
}
if (uc4620("postfix",postfix) == 3)
{
ispostfixok = true;
}
if (uc4620("exportfolder",exportPath) == 3)
{
isfolderok = true;
}
if (uc4620("exportoption",exportOption) == 3)
{
isoptionok = true;
}
if (uc4620("h",helpStr) != 0)
{
ECHOUsage();
return 0;
}
if ( ispartok == true )
{
ECHO("===== The part exported and renamed as belows: =====\n ");
// your code
}
页:
[1]