×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

NX9: Listing all assemblies in a folder and with blank character in part name

NX9: Listing all assemblies in a folder and with blank character in part name

NX9: Listing all assemblies in a folder and with blank character in part name

(OP)
Hi,

In this post thread561-335673: Listing all assemblies in a folder jmarkus and jptach help me to list all assemblies in a folder with the following .bat

____________________________________________________________________
@echo off
set base="C:\softs\ugnx9\"
set base_dir=%base:"=%
set UGII_BASE_DIR=%base_dir%
set UGII_ROOT_DIR=%base_dir%\UGIIset PATH=%base_dir%\ugii;%PATH%
if exist "%base_dir%\ugopen\ufvars.bat" call "%base_dir%\ugopen\ufvars.bat" "%base_dir%"
if "%DISPLAY%" == "" set DISPLAY=LOCALPC:0.0
REM Begin CODE
REM Jeff Markus, April 2009
REM
echo ===========================
echo MTC NX 5.0 Assembly File Determine
echo Scanning UG NX PRT files...
mkdir c:\temp\asmtemp
mkdir c:\temp\asmtemp\confirmed
for %%X in (*.prt) do (ug_inspect %%X | find "no components? FALSE" > c:\temp\asmtemp\%%X & echo %%X >> c:\temp\asmtemp\%%X)
echo The following files are assemblies:
pushd
c:
cd c:\temp\asmtemp
for %%X in (*.prt) do (findstr /M FALSE %%X) > c:\temp\asmtemp\confirmed\%%~nxX
cd confirmed
for %%X in (*.prt) do (if %%~zX EQU 0 del %%X)
i:
popd
for %%X in (c:\temp\asmtemp\confirmed\*.prt) do (ugpc %%~nxX & echo --)
del c:\temp\asmtemp\*.prt
del c:\temp\asmtemp\confirmed\*.prt
rmdir c:\temp\asmtemp\confirmed
rmdir c:\temp\asmtemp
echo Scan complete.
pause
____________________________________________________________________________

But I discovered that it doesn't work if part name contain blank characters like "Bande CVS 6HU 710 GPC.prt"

And I have sometimes the following message: Error File ...... is a pre-V10 part file

Any idea ?

TIA

Regards
Didier Psaltopoulos
http://www.psi-cad.com

RE: NX9: Listing all assemblies in a folder and with blank character in part name

The ug_inspect utility does not like spaces in the file names; it thinks you are passing in multiple parameters and errors out. Try wrapping the file name in double quotes. In the code above, this would be accomplished by using "%%X" instead of %%X in the following line:

CODE

for %%X in (*.prt) do (ug_inspect "%%X" | find "no components? FALSE" > c:\temp\asmtemp\%%X & echo %%X >> c:\temp\asmtemp\%%X) 

There may be other places in the code where you will need to do similar, but that's the one that stuck out to me.

www.nxjournaling.com

RE: NX9: Listing all assemblies in a folder and with blank character in part name

(OP)
Thanks Cowski, I was able to find the other places with your help

The folowing code works well

@echo off
REM Begin CODE
REM Jeff Markus, April 2009
REM
mkdir asmtemp
mkdir asmtemp\confirmed
for %%X in (*.prt) do (ug_inspect "%%X" | find "no components? FALSE" > asmtemp\"%%X" & echo "%%X" >> asmtemp\"%%X")
echo The following files are assemblies:
pushd
for %%X in (asmtemp\*.prt) do (findstr /M FALSE "%%X") > asmtemp\confirmed\"%%~nxX"
for %%X in (asmtemp\confirmed\*.prt) do (if "%%~zX" EQU 0 del "%%X")
popd
setlocal ENABLEDELAYEDEXPANSION
set dir_list=
for /d %%i in (*) do @(echo "%%i" && set dir_list=-p%%i !dir_list!)
for %%X in (asmtemp\confirmed\*.prt) do (ugpc -s4 !dir_list! "%%~nxX" > %%~nX_list_ass.txt & echo --)
echo Scan complete.
pause


But I have the following error with many parts : Error File ...... is a pre-V10 part file What does it mean ?

Regards
Didier Psaltopoulos
http://www.psi-cad.com

RE: NX9: Listing all assemblies in a folder and with blank character in part name

It means you have a very old .prt file. I'd guess the ug_inspect utility can't handle files that old.

www.nxjournaling.com

RE: NX9: Listing all assemblies in a folder and with blank character in part name

Yes, 'pre-V10' files have no 'history' nor some other bits of header data that 'ug_inspect' was expecting to find. After all, this goes back a ways, 23 years to be exact, when UG V9.1, the last 'pre-V10' version, was released. Note that while 'ug-inspect' might have a problem with files this old, NX itself shouldn't have any problems opening them (I have a UG V9.1 file that has not been saved since 1992 that I keep around to test each new version of NX and it still opens with no problems).

John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Digital Factory
Cypress, CA
Siemens PLM:
UG/NX Museum:

To an Engineer, the glass is twice as big as it needs to be.

RE: NX9: Listing all assemblies in a folder and with blank character in part name

(OP)
Hi,

OK for ug_inspect and the pre V10 part

I found a solution by using only ugpc and I have now a more simple code when all part are in the same assembly

@echo off
setlocal ENABLEDELAYEDEXPANSION
set dir_list=
for /d %%i in (*) do @(echo "%%i" && set dir_list=-p%%i !dir_list!)
for %%X in (*.prt) do (ugpc -s4 !dir_list! "%%~nxX" & echo ----------------------------------------------------------)
echo Scan complete.
pause !

Regards
Didier Psaltopoulos
http://www.psi-cad.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources