cancel
Showing results for 
Search instead for 
Did you mean: 

UGII_ENV.dat file #if options

Creator
Creator

I am working to define our ugii_env.dat file to look at 3 different configuration files that are loaded on a server location.  I have it working with 2 of the customizations but have not figured out how to have two different #IF file statements together, which is needed for the 3rd customization file.  I have put the original .dat file where it works for 2 customization options and what I have now for the 3 custom files.

 

2 custom files (Works)

# Load custom variables based on SAP, or Native type system.
#if FILE C:\ProgramData\DSCSAG_INST\ectr_clients\ECTR_44\ectr_revision_log.txt
#include U:\NX9\default\ugii_env_cust_ectr.dat
#else
#include U:\NX9\default\ugii_env_cust.dat
#endif

 

3 Custom files (does not work.  NX9 does not load and quits working after some time)

# Load custom variables based on SAP, MFG, or Native type system.
#if FILE C:\ProgramData\DSCSAG_INST\ectr_clients\ECTR_44\ectr_revision_log.txt
#include U:\NX9\default\ugii_env_cust_ectr.dat
#if FILE T:\nx9\manufacturing.txt
#include U:\nx9\default\ugii_env_cust_MFG.dat
#else
#include U:\NX9\default\ugii_env_cust.dat
#endif

 

Is there some sort of seperator that can be put in between the two if statements that allow for each one to work?  Any help would be appreaciated.

 

 

8 REPLIES

Re: UGII_ENV.dat file #if options

Phenom
Phenom

Some languages have an "else if" structure that allows for multiple conditions. It would look something like this:

If [option 1]
    code for option 1
else if [option 2]
    code for option 2
.
.
.
else if [option N]
    code for option N
else
    code to run when none of the above conditions are met
end if

I don't know for sure if NX supports this construct in the env.dat file, but it is worth trying.

Re: UGII_ENV.dat file #if options

Siemens Phenom Siemens Phenom
Siemens Phenom

This is a simple logic problem. As coded, the result of the first if condition (using ugii_env_cust_ectr.dat) can never be achieved. One of the two files specified by the second if...else... will always be used.

 

If there is not an elseif, you need to nest the second if...else... in an else clause of the first if so that if only the first condition is true, it won't be trumped by the else clause of the second:

 

# Load custom variables based on SAP, MFG, or Native type system.
#if FILE C:\ProgramData\DSCSAG_INST\ectr_clients\ECTR_44\ectr_revision_log.txt
    #include U:\NX9\default\ugii_env_cust_ectr.dat

#else
    #if FILE T:\nx9\manufacturing.txt
        #include U:\nx9\default\ugii_env_cust_MFG.dat
    #else
        #include U:\NX9\default\ugii_env_cust.dat
    #endif

#endif

Re: UGII_ENV.dat file #if options

Esteemed Contributor
Esteemed Contributor

The #if syntax is documented in the release notes

NX 9 docs -> Release notes -> NX9 System information -> Platforms ->

NX variables in the ugii_env.dat file
 
in your example, I think you are missing a #endif
 
Overall I think you need (indents are for clarity, not sure you can indent in actual file).
And you might want to add some "UGII_KKKING_INCLUDE=FILE1" variables, or check VERY CAREFULLY which files exist, to make sure your logic is correct.
#if FILE file1
#else
    #if FILE FILE2

    #else

    #endif
#endif
Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled


Re: UGII_ENV.dat file #if options

Creator
Creator
I follow the logic of this but when I try this coding I get a dialog box that says the item at line 16, which is the 2nd #IF FILE statement, it says that there is no #endif.

I would think that the indented #endif would cover the above indented code with the last #endif for the overall program.

Any ideas as to why it is not processing through the entire indented part of the program and seeing the endif's at the end of each section?

Re: UGII_ENV.dat file #if options

Siemens Phenom Siemens Phenom
Siemens Phenom

The parsing engine may be very basic and not allow either elseif or nested if statements.

 

I would suggest opening a call with GTAC to get a definitive answer.

Re: UGII_ENV.dat file #if options

Creator
Creator
OK thanks for your help. I will give them a call to see if there is any possibility of doing this with 3 custom files being driven from one installed dat file. Thanks again

Re: UGII_ENV.dat file #if options

Esteemed Contributor
Esteemed Contributor

Nested "If"s are allowed, starting in ?NX7.5?

 

From the Nx7.5 UGII_UG_ENV.dat file:

 The following allows products like Power Drafting or NX Viewer to set
# environment variables that customize the NX behavior.  
#
#if ${UGII_PACKAGE_DIRECTORY} != ""
#if FILE $UGII_PACKAGE_DIRECTORY\ugii_env.dat
#include $UGII_PACKAGE_DIRECTORY\ugii_env.dat
#endif
#endif

 

 

Note we may have indented code in our examples to make it clearer, but you may have to NOT indent code in the actual file (see code above)

 

Another option, based on the ENV file behavior (FIRST definnition "wins")

#if FILE file1
YOUR_VARIABLE=file1
#endif

#if FILE file2
YOUR_VARIABLE=file2
#endif

YOUR_VARIABLE=file3

 

 

 

 

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled


Re: UGII_ENV.dat file #if options

Creator
Creator

Ken,

 

Thanks for the info.  I was able to get the program to run with the 3 option files with the suggestions that you provided.  I have attached the program as it looks in the working state.  The biggest different was that I had to have the endif at the end of the first IF File statement and then the ELSE between the 2nd and 3rd options.


Thanks again for everyones help.

 

#
# Load custom variables based on SAP, MFG, or Native type system.
#if FILE C:\ProgramData\DSCSAG_INST\ectr_clients\ECTR_44\ectr_revision_log.txt
#include U:\NX9\default\ugii_env_cust_ectr.dat
#endif
#if FILE T:\nx9\manufacturing.txt
#include U:\nx9\default\ugii_env_cust_MFG.dat
#else
#include U:\NX9\default\ugii_env_cust.dat
#endif