Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UGii_env.dat files options 1

Status
Not open for further replies.

KKKing

Mechanical
Sep 12, 2014
28
0
0
US
I have a situation where in rolling out a new version of NX, I want to have the launch of NX look at the system to see if it can find a program log.txt file, and if so set one custom ugii_eng_cust_ectr.dat file. This configuration would be based on running NX with a SAP PLM system. If it does not find this txt file, it should then load an alternative custom file, ugii_env_cust.dat, which would be the custom settings for running NX native. The two custom dat files are located on a network drive and are currently selected by manually changed the Ugii_evn.dat file with the correct custom data file.

The logic of what I am trying to do is:
if c:\"Local path"\ectr_revision_log.txt is located
Load U\"network path"\ugii_env_cust_ectr.dat (SAP customizations)
If not then load U:\"network path"\ugii_env_cust.dat (Native Customizations)

The questions that I have are:
Is there a list of commands that can be used within the Ugii_env.dat file? It would be nice if there are any type of commands that allows for if then type statements.
How would be the best way to set up something like this where the launching of the NX program then has to look to see if there is a set file on it to know which custom conf file it needs to load?

The over all goal is that the launching of the program can determine if the workstation has been switched over to a SAP user or still a native NX user.

Thanks,

Kevin
 
Replies continue below

Recommended for you

Kevin,

The ugii_env.dat does support the notion of conditional branching that would let you implement the decision based on the existence of a file.

Good examples exist in the "%UGII_BASE_DIR%\ugii_env_ug.dat" file.

Code:
#  Cam express environment file
#if FILE ${UGII_CAM_AUXILIARY_DIR}\cam_express_env.dat
#include ${UGII_CAM_AUXILIARY_DIR}\cam_express_env.dat
#endif

and

Code:
#if FILE ${UGII_BASE_DIR}\ugii\materials\${UGII_LANG}
UGII_PHYS_MATERIAL_LIB_DIR = ${UGII_BASE_DIR}\ugii\materials\${UGII_LANG}#else
UGII_PHYS_MATERIAL_LIB_DIR = ${UGII_BASE_DIR}\ugii\materials\english#endif

It is possible to test for the existence of file (absolute path or with environment variable expansion) using the "#if FILE" approach.

It is important to note that Comment line begin with a "#" usually followed by a space then the comment contents.

The special # directives begin with # followed immediately with the directive without any spaces. E.g.
#if
#else
#endif
#include

It is then possible to use "#include FILE" approach from a common %UGII_ENV_FILE% and control which additional file on the network share to use. (And you can use UNC (\\server\share) naming and not rely on a common mapped U: drive)

HTH, Joe

Code:
#  Test for local file to control which env.dat to use.
#if FILE C:\Local_path\ectr_revision_log.txt
#include U:\network_path\ugii_env_cust_ectr.dat
#else
#include U:\network_path\ugii_env_cust.dat
#endif
 
Thanks Jpetach.

I have worked my local copy of ugii_env.dat with the method that you suggested to see if it would work. See below on what it looks like:

##############################################################################
#
#
# This file should be used to override any standard NX environment variables.
# The values defined here will take precedence over the NX values, as long as
# they are defined before the #include of ugii_env_ug.dat. This file will not
# be overwritten by an MR installation.
#
# Override any variables here.
#if FILE C:\ProgramData\DSCSAG_INST\ectr_clients\ECTR_44\ectr_revision_log.txt
#include U:\NX7.5\default\ugii_env_cust_ectr.dat
#else
#include U:\NX7.5\default\ugii_env_cust.dat
#endif

#
# Do not define any variables after the #include below. They must be defined
# before the #include in order to override the NX defaults.
#
#if FILE ${UGII_BASE_DIR}\ugii\ugii_env_ug.dat
#include ${UGII_BASE_DIR}\ugii\ugii_env_ug.dat
#endif

When I run it I get the following error. (see attachment) The error references the #endif line which does not make sense.

Thanks for taking a look at this and all the help

Kevin
 
 http://files.engineering.com/getfile.aspx?folder=80814e75-1d72-4a5b-87dc-61b2d7556e7b&file=Error_Message.jpg
Kevin,

I tested your example. I copied and pasted it from the posting into a new text file. Saved it and set the environment variable UGII_ENV_FILE pointing to it.
I changed two "U" characters for U:\ to E:\ due to my U: being mapped to a read-only share. This should not explain the difference in behavior or the error message that you got.

I created two files E:\NX7.5\default\ugii_env_cust_ectr.dat and UE\NX7.5\default\ugii_env_cust.dat. In each I added only one line UGII_TESTING=electrical and UGII_TESTING=plain respectively.

Using NX 7.5.5 MP12 my NX syslog shows UGII_TESTING=plain as expected since I don't have the local file.

I can't see any syntax errors in your posted example that would cause the error that you got.

One potential suspect is the editor that was used for the actual file editing. If it was MS Word or Wordpad etc. the contents of the file may include additional "invisible" characters that are not included during the copy paste to/from the e-tips post. I prefer to use (free) Notepad++. It is a very good editor. However, as rudimentary as Notepad.exe is, it is still better to use Notepad than other word processor-like editors for files like this that are expected to be pure text files.

Can you try starting a new notepad session and copying your post to it and using that file for UGII_ENV_FILE and see if the results are different?

Also, (something to look forward to) as of NX 9.0 there is no need to explicitly perform the #include ${UGII_BASE_DIR}\ugii\ugii_env_ug.dat anymore. It is done automatically. (and if it is still explicitly requested there is no harm)

Which NX 7.5 release are you using? I may be able to test in that version.

HTH,

Joe


 
Joe,

I was able to find out the problem. Your sample that you provided and the one that I have does run. The problems was the special characters at the end of the lines was not following suit with the rest of the .dat file. I have always used Notepad++ as it is a good editor and allows for line review.

The issue was that the new lines of text was only putting a CR at the end of them and all of the other lines had a CRLF. After a bit of reading, I found that in notepad++ to get everything to show the LF, you need to just do the following Edit--> ELO Conversion--> and select windows format.

Once this was done, the program functioned as expected.

I will also remove the {UGII_Base_Dir} commands in the NX9 version and test it as I like to keep the files as clean as possible.

Thanks for all your help on this.

Kevin
 
Status
Not open for further replies.
Back
Top