Cancel
Showing results for 
Search instead for 
Did you mean: 

Move an assembly (with parts) to a new folder?

Valued Contributor
Valued Contributor

How do I move an assembly and all associated parts?  I don't want to clone it.  I want to actually move it from it's current location to a new folder. How is that done?  Thanks!

18 REPLIES

Re: Move an assembly (with parts) to a new folder?

Phenom
Phenom

Move the files to new folder

Change Assembly Load options to "From Folder"

Open the assembly

If standard components are in other folders, after load from folder there will be "Not Found With Current Load Options" errors.

Change Load options back to "As Saved"

In "Assembly Navigator" right click on top level select  "open"->"Child Components" or "assembly"

Save assembly.

 

To be sure you are not loading from the wrong folder , temp rename the original folder.

or 

"Menu"->"Information"->"Parts"->"Loaded Parts" will list all parts with folder names.

Re: Move an assembly (with parts) to a new folder?

Valued Contributor
Valued Contributor

Why dont you want to use clone tool? It will copy all the components in the new directory.

If what you are searching is also deleting the files cloned from the old directory I don't know if there is a specific tool for that. A workaround I am thinking about is to make a forced save all (it will save all components in your assembly even if nothing is modified in them) so you can select them by sorting by modified date in windows.

Re: Move an assembly (with parts) to a new folder?

Valued Contributor
Valued Contributor

Thanks for the suggestions.  I'm surprised NX doesn't have a better tool for doing this (something similar to SE's Revision Manager). I'm sure this is a common need.

 

I could use the clone tool, but then I would have to manually delete the files from the old folder.  I was hoping to avoid that.  In this case there aren't that many (maybe 7 or 8) so that's probably what I'll do.  

Re: Move an assembly (with parts) to a new folder?

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

If you are using native NX, you simply open a file management tool (windows explorer, on Windows OS) and move the part files to your desired directory. You will need to either change your load options so that the files are found in the new location or you can use the utility "ug_edit_part_names.exe" to tell the assembly file the new locations of the components (this will allow the assembly to open correctly using the "as saved" load option).

Re: Move an assembly (with parts) to a new folder?

Siemens Honored Contributor Siemens Honored Contributor
Siemens Honored Contributor

If you're comfortable working with scripts, there's a sample in Solution Center called "command line utility to zip assembly and all components".  It was created as an alternative to an old utility called UGzipC, which would let you zip up the contents of an assembly - allowing you to place the zip in a new location and unzip the contents (obviously helpful when you want to send someone a copy of your assembly and it's spread out over several folders).

The actual UGzipC is still in circulation (appears that it's included in the NX Custom package) and there's a thread on it here.  Based on the comments it looks like the utility works in NX11, so you should be OK for NX10.

 

NXCustom for NX10

NXCustom for NX11

 

Regards, Ben

Re: Move an assembly (with parts) to a new folder?

Valued Contributor
Valued Contributor
Thanks for the additional suggestions. I've not done much with scripts, so I will probably just use the clone tool to start. But I have to ask, why isn't this zip utility (which sounds very useful) built into NX? Sending parts and assemblies to outside organizations is a very common need.

It would be nice if Siemens expanded the clone tool to include a move option (where the source files are removed). Doesn't seem like it would be that hard to do. Or better yet, adopt SE's Revision Manager! :^)

Re: Move an assembly (with parts) to a new folder?

Siemens Honored Contributor Siemens Honored Contributor
Siemens Honored Contributor

We have several existing Enhancement Requests submitted by customers:
ER 6233273 - Zip functionality built into NX
ER 7216125 - Zip assemblies from NX Manager
ER 6213736 - Save an assembly & components into a user defined folder

I could not find one that requests that a component is removed after cloning.  I can see where that could potentially cause a problem in the case where other assemblies (or parts with interpart links) could still refer to those parts, but you should still consider opening an IR with GTAC if you would like to submit a new Enhancement Request for that functionality to be include in the clone command.

Regards, Ben

 

Re: Move an assembly (with parts) to a new folder?

Siemens Phenom Siemens Phenom
Siemens Phenom

@pkelecy wrote:
Thanks for the additional suggestions. I've not done much with scripts, so I will probably just use the clone tool to start. But I have to ask, why isn't this zip utility (which sounds very useful) built into NX? Sending parts and assemblies to outside organizations is a very common need.

It would be nice if Siemens expanded the clone tool to include a move option (where the source files are removed). Doesn't seem like it would be that hard to do. Or better yet, adopt SE's Revision Manager! :^)

An alternate way to clone assembly command. You can use the following journal code which saves loaded assembly to the selected directory/folder.

 

Source: GTAC

https://solutions.industrysoftware.automation.siemens.com/view.php?sort=desc&q=copy+assembly&dt=nx-a...

 

Option Strict Off

' This program collects all loaded components
' from the assembly tree and copies them all
' into the specified target directory.

Imports System
Imports System.Collections 
Imports System.IO
Imports System.Environment
Imports System.Windows.Forms
Imports NXOpen
Imports NXOpen.Assemblies
Imports NXOpen.UF

Module copy_assembly_to_target_directory

    Dim theSession As Session = Session.GetSession()
    Dim ufs As UFSession = UFSession.GetUFSession()
    Dim lw As ListingWindow = theSession.ListingWindow

    Sub Main()

        Dim partlist As New ArrayList()
        Dim foldername As String = ""

        lw.Open()
        If (select_directory(foldername) <> DialogResult.OK) Then
            lw.WriteLine("Input canceled...exit" & vbCrLf)
            Return
        Else
            lw.WriteLine("Target directory " & foldername & vbCrLf)
        End If

        Dim root As Component = _
            theSession.Parts.Display.ComponentAssembly.RootComponent
        Dim c_part As Part = root.Prototype
        partlist.Add(c_part.FullPath)

        AddComponentsToList(root, partlist)

        CopyComponentsInList(partlist, foldername)
        partlist.Clear()

    End Sub

    Sub AddComponentsToList( ByVal comp As Component, _
        ByRef plist As ArrayList)

        Dim child As Component = Nothing
        Dim c_part As Part = Nothing
        Dim loaded As Integer
        Dim modified As Boolean
        Dim nxman As Boolean = False
        Dim cp_name As String = Nothing

        For Each child In comp.GetChildren()
            cp_name = child.DisplayName()

            Dim loadStatus As UFPart.LoadStatus = nothing
            ufs.Assem.EnsureChildLoaded( ufs.Assem.AskInstOfPartOcc(child.Tag), loadStatus)
            If loadStatus.failed = True Then
                lw.WriteLine("Cannot load " & child.DisplayName())
            Else 
                c_part = child.Prototype
                If plist.Contains(c_part.FullPath) = false Then
                    plist.Add(c_part.FullPath)
                End If
                AddComponentsToList(child, plist)
            End If
                 
        Next
    End Sub

    Sub CopyComponentsInList( ByVal plist As ArrayList, _
        ByVal targetfolder As String )

        Dim en As IEnumerator = plist.GetEnumerator
        While en.MoveNext
          Dim fi as new system.io.fileinfo(en.Current)
          Dim targetfile As String = targetfolder & "\" & fi.name
          lw.WriteLine("Copying " & en.Current & " --> " & targetfile)
          File.Copy(en.Current, targetfile , True)
        End While

    End Sub


    Public Function select_directory(ByRef foldername) As DialogResult

        Dim fbd As FolderBrowserDialog
        Dim result As DialogResult

        fbd = New FolderBrowserDialog()
        fbd.Description = "Select target directory"
        fbd.ShowNewFolderButton = True
        ' start browsing at Desktop folder, uncomment for any other default directory
        ' fbd.SelectedPath = GetEnvironmentVariable("UGII_BASE_DIR")
        ' fbd.SelectedPath = "c:\temp\target"
        result = fbd.ShowDialog()
        foldername = fbd.SelectedPath
        fbd.Dispose()
        Return result

    End Function

    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        Return Session.LibraryUnloadOption.Immediately
    End Function

End Module

 

Re: Move an assembly (with parts) to a new folder?

Valued Contributor
Valued Contributor

Thank Ganesh.  Being new to NX I don't know what a journal is (although I've seen the term mentioned a few times).  Since I'm still struggling with some of the basics, it will probably be a while before I try tackling this.  But at least I know where to look when the time comes.

 

Btw, I was able to move my assembly using the clone tool.  There were a few details I had to work out (like how to use the naming rules so I didn't have rename each file by hand).  The interface  (imo) could be more intuitive.  The NX team should really look at SE's revision manager or a tool like filezilla (which is designed for  file copying) and, if nothing else, incorporate some of the better interface features (like separate windows showing source and destination file structures, etc).  Just my 2 cents.