Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

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

Status
Not open for further replies.

PSI-CAD

Computer
Joined
Feb 13, 2009
Messages
997
Location
FR
Hi,

In this post thread561-335673 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
 
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 [highlight #FCE94F]"%%X"[/highlight] | 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
 
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
 
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.
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top