Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Isolating sub asm with dwg from main asm 1

Status
Not open for further replies.

Berserk

Automotive
Jan 23, 2003
248
Hello,

Using ugzip, we make a copy of a sub asm to isolate it from thousands of other component/sub asm files.
The original folder that contain the top asm also includes the drawing files for most of the components.
Since the drawing files are not included in the top asm, ugzip does not include them in the isolated sub asm.

Is there a way to copy/move all the drawings files that has a match with the sub asm model files?

The file format for the models are abc12345.f01.0010.prt and for the corresponding drawing is abc12345.d01.0010.prt. The only difference is the f & d in the middle of the file name.

What I have been trying is generating a text file that list the model file names in the sub asm folder and trying to use that list to copy over the drawing files. I can't figure out how to do it. I am thinking that the batch file or script should be looking at the first 8 characters of the file names in the list, ignore the rest of the characters and copy or move the files into the specified folder. I don't care if the script overwrites the existing models of the sub asm in the sub asm folder.

Really appreciate any help or hints!

TIA!

Roark

UGNX 8/8.5/9
Windows 7 64bit

UGNX7.5.2.5 MP3 Rev D \ Windows 7 64bit
Productive Design Services
 
Replies continue below

Recommended for you

Roark,

For your consideration...

This example is deigned to run from the directory where the isolated sub assembly parts have been (already) copied to.

This example requires that "source_dir" be edited on the third line.

As coded this will just display the copy command that would be executed.

To actually perform the copy operation remove the "ECHO" (bold) from the "if exist" line (third from bottom).

HTH,
Joe

Code:
@echo off
setlocal ENABLEDELAYEDEXPANSION
set source_dir=x:\Edit_this_to_point_to_location_of_drawings
set source_dir
for /f "usebackq tokens=*" %%i in (`dir /b *.f??.*.prt`) do (
set part=%%i
set part
set dwg=!part:f=d!
set dwg
if exist "!source_dir!\!dwg!" [b]ECHO[/b] copy /y "!source_dir!\!dwg!"
)
pause
 
Thank you very much for the help.
I modified it a bit so the user is prompted for the source_dwg_dir. Could you tell me how to modify it so that it would ignore the 4 character revision at the end of the filename? Just in case if the model and the drawing does not have the same revision.

@echo off
setlocal ENABLEDELAYEDEXPANSION
set /p Source_DWG_Dir= Enter directory for drawing files:
set source_dir=%Source_DWG_Dir%
echo off set source_dir
for /f "usebackq tokens=*" %%i in (`dir /b *.f??.*.prt`) do (
set part=%%i
set part
set dwg=!part:f=d!
set dwg
if exist "!source_dir!\!dwg!" copy /y "!source_dir!\!dwg!"
)
pause

UGNX 8 / 8.5 / 9 - Windows 7 64bit
Productive Design Services
 
Roark,

Apologies. It was clear in your original post and I missed that requirement.

This will copy all of the .d drawing files for the .f part files independent of the revisions of the drawing(s).

It ignores the 4 character .prt extension and the 4 characters of the revision.

HTH,

Joe

Code:
@echo off
setlocal ENABLEDELAYEDEXPANSION
set /p Source_DWG_Dir= Enter directory for drawing files: 
set source_dir=%Source_DWG_Dir%
set source_dir
for /f "usebackq tokens=*" %%i in (`dir /b *.f??.*.prt`) do (
set full_part=%%i
set part=!full_part:~0,-8!
set part
set dwg=!part:f=d!
set dwg
if exist "!source_dir!\!dwg!*.prt" copy /y "!source_dir!\!dwg!*.prt"
)
pause
 
I am just wondering if it is possible to add this to the right mouse click in windows 7 64bit.

UGNX 8 / 8.5 / 9 - Windows 7 64bit
Productive Design Services
 
In NX 8.5 and NX 9.0 you could easily add it to the Shortcut Toolbar which now comes-up when you press MB3. Just go into Customize and select the 'Shortcut Toolbars' tab and then add a 'New User Command' assigning the 'Action' to execute the Journal of your choice.

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

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

Yes. To create the MB3 action this presumes:
- You are logged as a member of the administrator group on the computer.
- The Windows explorer MB3 action is to be launched from the directory where the NX part files have been copied to.
- MB3 is invoked while the mouse pointer is over the windows explorer background and no row(s) (files) are selected.
- The MB3 action is titled "Get NX Drawings" (edit below as desired).
- The script name and location in the example below is edited to use the actual script name and location.

Code:
reg.exe add "HKCR\Directory\Background\shell\[highlight #FCE94F]Get NX Drawings[/highlight]\Command" /t REG_SZ  /d "cmd.exe /k \"pushd . ^&^& \"[highlight #FCE94F]E:\dwgs_for_parts\script\find_dwgs.bat[/highlight]\" \" "

The use of the MB3 action does not require administrator rights.

I wondered if copying all of the drawings for the model part was the best solution when there was more than one drawing.
Here is an alternative that will only copy the highest numbered drawing for the given part revision.

HTH, Joe

Code:
@echo off
setlocal ENABLEDELAYEDEXPANSION
set /p Source_DWG_Dir= Enter directory for drawing files: 
set source_dir=%Source_DWG_Dir%
set source_dir
for /f "usebackq tokens=*" %%i in (`dir /b *.f??.*.prt`) do (
echo;
REM echo "%%i"
set full_part=%%i
set part=!full_part:~0,-8!
set part
set dwg=!part:f=d!
set dwg
REM copy only the highest numbered drawing
if exist "!source_dir!\!dwg!*.prt" (
for /f "usebackq tokens=*" %%j in (`dir /b !source_dir!\!dwg!*.prt`) do (
echo %%j
set newest_dwg=%%j
set newest_dwg
)
echo copy /y "!source_dir!\!newest_dwg!"
)
)
pause


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor