×
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

Isolating sub asm with dwg from main asm

Isolating sub asm with dwg from main asm

Isolating sub asm with dwg from main asm

(OP)
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
www.productivedesign.com

RE: Isolating sub asm with dwg from main asm

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 --> DOS_batch

@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!" ECHO copy /y "!source_dir!\!dwg!"
)
pause 

RE: Isolating sub asm with dwg from main asm

(OP)
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
www.productivedesign.com

RE: Isolating sub asm with dwg from main asm

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 --> DOS_batch

@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 

RE: Isolating sub asm with dwg from main asm

(OP)
Thanks very much!

UGNX 8 / 8.5 / 9 - Windows 7 64bit
Productive Design Services
www.productivedesign.com

RE: Isolating sub asm with dwg from main asm

(OP)
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
www.productivedesign.com

RE: Isolating sub asm with dwg from main asm

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.

RE: Isolating sub asm with dwg from main asm

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 --> Dos_command_line

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

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 --> DOS_batch

@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 


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