cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Where used?

sloman
7-Bedrock

Where used?

Is there a way to see in which assembly’s a part is being used?

I have creo parametric 2.0. I don’t seem to have PDM link what is explained in the question of Mike Minsterketter.

ACCEPTED SOLUTION

Accepted Solutions

Hi Stefan,

I've written a batch file to do this. It's a little slow and sometimes returns false positives, but it works.

The key lines are:

for /r . %%9 in (.) do findstr /m /i "%1" %%9\*.asm.* >> \whereused_%1.txt

start notepad \whereused_%1.txt

I've named it whereused.bat, and it is saved in the root directory of our Pro/E data drive (Z:).

To use it we call up a command prompt and type e.g.:

z:

cd \

whereused 12345

View solution in original post

41 REPLIES 41

Hi Stefan,

I've written a batch file to do this. It's a little slow and sometimes returns false positives, but it works.

The key lines are:

for /r . %%9 in (.) do findstr /m /i "%1" %%9\*.asm.* >> \whereused_%1.txt

start notepad \whereused_%1.txt

I've named it whereused.bat, and it is saved in the root directory of our Pro/E data drive (Z:).

To use it we call up a command prompt and type e.g.:

z:

cd \

whereused 12345

Thanks Jonathan!

I followed your instructions and it works!

Strange that it is not possible to have a standard option in Creo for "where used". But your batch file is a good alternative.

Stefan

This implies that part names are stored in assemblies as text strings. Something I didn't know but will hereafter exploit. Nice.

Will this "where used" work for family table instances?

Dale_Rosema
23-Emerald III
(To:BillChapman)

That is why I am using it. My predecessors didn't do a good job of house keeping, so I have a lot of dead instances. So far it is working really well for finding where these instances are or are not used.

Where do I download this? It sounds very useful!

Hi Bill,

Just paste the three lines I provided above (starting @echo off) into Notepad, then save the file as "whereused.bat".

That's it - no download! Because many email systems, and I'm guessing some virus checkers, are fussy about .bat files, it's easier to create it yourself than do through the trouble of renaming the file, uploading it and explaining to people how to rename it back...

Dave,

My files are in multiple directories. When I search, it will find parts/assemblies created in WF2.0, regardless of what directory it is in, but never anything for WF5.0 or CREO 2.0.

I have created a simple assembly today with 3 parts in it. I was hoping to upload it to the forum so someone could see if it would work on their system.


Is there a way to upload a file on this forum?

Dale_Rosema
23-Emerald III
(To:BobCondra)

In the top left corner is the "Use advanced editor" icon.

Click on that and in the lower left you can attach your data.

Thanks, Dale

Re: Add "Insert File icon" into standard Reply window

This search does not seem to work on our CREO 2.0 files or Wildfire 5.0 files. It does work on our very old Wildfire 2.0 files.

It appears that the file formats changed sometime between WF2.0 and WF5.0. In looking at the files, both of these are almost totally unreadable in notepad, but in looking at the old WF2.0 files, the part names are sprinkled and readable in the files - thus making the search work.

Is anyone else having the same issue?

Dale_Rosema
23-Emerald III
(To:BobCondra)

I am using WF5.0/Creo without Windchill and I am able to use it.

Caveat - all my files are in one directory, I am not sure if this would change if they are not.

I have attached a sample assembly file that I created. Can someone test the "where used" on their system to see if it will work?

It does not find anything on my system. This is the batch file I use:

@echo off

for /r . %%9 in (.) do findstr /m /i "%1" %%9\*.asm.* >> C:\Users\bcondra.TRIJICON1\whereused_%1.txt

start notepad C:\Users\bcondra.TRIJICON1\whereused_%1.txt

Just editing your file with a text editor, I can see that it is not going to work. It looks like you might have "compress_output_files" set to "YES" in your config.pro and/or something else is preventing your component references from being written in ASCII characters. Since the batch file logic depends on being able to find text strings, it's not going to work for you.

Kenneth,

Thank you. You have solved the mystery.

In WF2 we had "compress_output_files" set to "yes" (lowercase and likely not understood) in WF5 and CREO set to "YES" (uppercase).

I saved some new files, and was able to see the text in the .asm file, and now the search will work properly.

There is a program called findmymother that is windows based, and may be a little easier to use. I found it on MCAD central a while ago, but gave up when we went to WF5, and our settings got changed. Here is the link to it. MCAD Central‌.

I've got another interesting (?) inquiry about this stuff. I built a DOS batch file to look for occurrences of parts in assemblies. Here's an example of the situation that prompts my inquiry:

(1) I search for assemblies that are using a particular bolt, which is a member of a family table.

(2) I find a couple of assemblies that use the bolt.

(3) I replace the bolt in those assemblies with another from the family table.

(4) If I search again for the same bolt, it still shows up in the same assemblies that were found in step (1).

Is there some behavior of the database for the assemblies that causes it to continue to refer to a part that has been replaced? Is it storing history information or is there some other reason I can't eliminate reference to replaced parts? This makes "seek and repair" operations kind of difficult. Could the fact that these assemblies are very very old (circa ProE 2000) be the cause of the oddities?

For the record, I'm currently using Creo 2.0, M160.

JLG
12-Amethyst
12-Amethyst
(To:KenFarley)

Here is a potential source of your problem:  When you use Replace functionality, if you have "Remember These Components" checked, the model will remember the corresponding references between the two models (in case you might like to use the same replacement again later).  That will keep a reference to the old model.

Untitled.png

Personally, I like to set the config option remember_replaced_components to no so I don't forget and keep these extra references.

HTH

KenFarley
21-Topaz I
(To:JLG)

Oddly enough, "Remember These Components" is grayed out for me, but I can set the checkbox option via my config.pro file.

Unfortunately, it appears that another annoying bit of Creo behavior is making this batch utility less useful. For assemblies, the "Change History" is retaining every single change, including replacement of components. Thus a large number of entries are logged into the file referencing the names of the replaced components. So if a file has ever had a specific part in its assembly structure, it is forever telling us that. There is no way to remove this history, to the best of my knowledge. Thus the DOS batch file method of doing a "where used" is questionable.

That's a shame. I don't see the benefit of knowing that some guy 12 years ago changed a cap screw from 1 inch long to 1-1/4 inch long. It's not like it will save me any time if I need to change it back. It just seems to be contributing to the bloating of file sizes.

JLG
12-Amethyst
12-Amethyst
(To:KenFarley)

Wow, this was an eye-opener for me.  I had no idea that was going on.  For what it's worth, I did discover that if I have the config option purge_history_on_save_copy set to yes, when I save a copy that information is removed in the copy.

There ought to be a config option to control this behavior for normal save; saving this information increases the file size for no great reason.  Maybe there's an option and I just can't find it.  If so, maybe someone will chime in.

Dale_Rosema
23-Emerald III
(To:JLG)

Once you have done a replace with that check, is there a way to go back and have them "unremember these components"?

TomU
23-Emerald IV
(To:Dale_Rosema)

Yes, you can manually go into the reference viewer and "break" the reference.  See CS46402.

Dale_Rosema
23-Emerald III
(To:TomU)

I am on instruction #2 in the resolution. After clicking on the Dependencies tab, RMB on the desired component > Break Dependencies. How do I proceed from that? What do I RMB on? I cannot find the break dependencies.

Thanks, Dale

Dale_Rosema
23-Emerald III
(To:Dale_Rosema)

Here is a different model.

What does the red X mean by the two parts?

Thanks, Dale

TomU
23-Emerald IV
(To:Dale_Rosema)

Those models are not currently in session.

How does this batch file actually work? I have tried to create a batch file in Notepad and it always attaches the .txt extension. Is this batch file that you have mentioned funning a .bat file or a .txt file? 

 

When I go to the command prompt to try to execute it I simply get a message that it doesn't recognize it. 

I tried using this "batch file" approach. For some reason the file will not run properly. Just so you know, I had to use the command prompt to change the file name to whereused.bat. It won't allow you to save it as a .bat in Notepad without attaching a .txt behind it. 

 

I am using Creo 7 and wonder if this message is outdated now. 

Dale_Rosema
23-Emerald III
(To:sloman)

Can you help me a little with the batch file, JONATHAN Hodgson?

It this something that is like an old Dos program?

Thanks, Dale

Hi Dale,

Yes, it is indeed effectively a DOS BATch script (only I think they're called "command scripts" these days).

Basically you just create a text file (Notepad works fine) containing those lines, but with a .bat extension instead of .txt - so "whereused.bat". You could also add @echo off as the first line - echo off stops it displaying (echoing) each command it executes to the screen, and the @ stops it echoing the echo off!

Then call up a command prompt and run it as I describe above.

"for /r . %%9 in (.)": recurse (/r) through all directories starting from the current one (.) and output the directory name to %%9

"do findstr /m /i "%1" %%9\*.asm.*": look for the string "%1" (which is the part number you typed after whereused) in *.asm.* in each directory %%9, not case sensitive (/i), outputting just the filename(s) where the string was found (/m)

">> \whereused_%1.txt": and append that filename to the end of a file in the root directory of the current drive called "whereused_%1.txt"

"start notepad \whereused_%1.txt": finally, open the file in Notepad

You can get help on most commands by typing them followed by /? at a command prompt:

for /?

findstr /?

or there are several webpages around devoted to the arcana of batch file language.

Maybe I am not getting the spacing quite right:

whereused.bat

Yep, more spaces required - and as a single line. Copy and paste:

@echo off

for /r . %%9 in (.) do findstr /m /i "%1" %%9\*.asm.* >> \whereused_%1.txt

start notepad \whereused_%1.txt

Announcements
NEW Creo+ Topics: Real-time Collaboration


Top Tags