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!

Journal (Part Cleanup) 1

Status
Not open for further replies.

phillpd

Mechanical
Oct 19, 2006
780
I have a Journal that I run to perform a Part Cleanup (Cleanup - Save - Close).

What I'd like to do, is enhance it so that it will execute against a specified folder. Is this possible ? Could someone give me some idea of what I need to add to the journal ?

NX 6.0.5.3 (NX 8 Testing)
Windows XP32 (Windows 7 64)
 
Replies continue below

Recommended for you

What I'd like to do, is enhance it so that it will execute against a specified folder.

Does this mean you want to run a part cleanup on all parts in a particular folder?

Marc
NX Software Developer
 
Marc,

Yes, that's correct.

Now I have used the following ... "Refile_part.exe -d <path> -l <log filename> -nop -ndates -cleanup" ... but i'm guessing it's only a basic cleanup. It doesn't work.

NX 6.0.5.3 (NX 8 Testing)
Windows XP32 (Windows 7 64)
 
Refile is something else entirely; it is used to update the part from one NX version to another. In addition, -cleanup is just a switch to indicate that a part cleanup should be executed before updating the part.

It is very easy to get a list of files in a directory in .NET (take a look at the System.IO.GetFiles() method). The tricky thing is able to run a part cleanup externally. I am not sure if NX/Open has functionality to run the part cleanup automatically.

What you can do is to record a journal while running part cleanup interactively and see if anything is recorded. If you are lucky and something is recorded, then that code is what you need to call in your journal. If not, then you will have to see if NX has supplied the possibility by running a part cleanup using a separate program.

The major setback of what you are trying to accomplish via is a journal is performance. You will need to open each part in the specified folder, run the part cleanup, save it, close it, and repeat for all remaining parts.


Marc
NX Software Developer
 
Marc,

I have the journal recorded ... Cleanup, Save, Close.

What I need to do is 'add' the lines to open a file from the folder, loop through the part cleanup section and then open the next file etc etc etc ...

NX 6.0.5.3 (NX 8 Testing)
Windows XP32 (Windows 7 64)
 
Gotcha. Which language did your record your language in? VB or C#?

Marc
NX Software Developer
 
VB

NX 6.0.5.3 (NX 8 Testing)
Windows XP32 (Windows 7 64)
 
Here is some code showing the principle of how one might do it (untested!)

Code:
' Goes to the very top of your code
Imports System.IO
Imports NXOpen
Imports NXOpen.Utilities

Dim ufSession as UFSession = UFSession.GetUFSession()

' Path containing parts to clean up including subdirectories
Dim partPath as String = "c:\partstoclean"
Dim partFiles() as String = Directory.GetFiles(partPath, "*.prt", SearchOption.AllDirectores)

Dim partTag as Tag = Tag.Null
Dim loadStatus as UFPart.LoadStatus = Nothing
Dim partResponses as PartCloseResponses = Nothing

Try
For Each partFile as String in partFiles

' Open the part
ufSession.UFPart.Open(somePart, partTag, loadStatus)

' Convert Tag to Part
Dim somePart as Part = CType(NXObjectManager.Get(partTag), Part)

' Calls the function to clean up the part, save it, and close it.
CleanSaveClosePart(somePart)

End For
Catch ex as NXException

End Try

The function which cleans, saves and close the part should have the following signature:

Code:
Public Sub CleanSaveClosePart(ByVal partToUpdate as Part)

Marc
NX Software Developer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor