Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

How do I get a journal to get the part family save directory

Status
Not open for further replies.

aluminum2

Aerospace
Joined
Apr 27, 2010
Messages
218
Location
US
I would like to obtain the part family save as directory as a varible in a journal. I found the following in the .net reference file but not sure how to use it.

Namespaces -> NXOpen -> SaveOptions -> FamilyDefaultDirectory

public string FamilyDefaultDirectory { get; set; }

Public Property FamilyDefaultDirectory As String
Get
Set

Also if possible I would also like to know if there is a way to find out what family members were created last or created in the current session. Maybe copy lines from the information window if there are no UG functions for it.
 
Near the bottom of the page for the "SaveOptions" you'll see a line that says:
"To obtain an instance of this class, refer to PartCollection"
Follow the link for the PartCollection and do the same, you'll see you need a reference to the Session object. So your code will look something like:
Code:
myVariable = SessionObject.PartCollection.SaveOptions.FamilyDefaultDirectory


Code:
Option Strict Off
Imports System
Imports NXOpen

Module Module1

    Sub Main()

        Dim theSession As Session = Session.GetSession()

        Dim lw As ListingWindow = theSession.ListingWindow
        lw.Open()

        Dim myPartFamSaveDir As String = ""

        myPartFamSaveDir = theSession.Parts.SaveOptions.FamilyDefaultDirectory

        lw.WriteLine("Part family save directory: " & myPartFamSaveDir)

        lw.Close()

    End Sub


    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        'Unloads the image when the NX session terminates
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

        '----Other unload options-------
        'Unloads the image immediately after execution within NX
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

        'Unloads the image explicitly, via an unload dialog
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
        '-------------------------------

    End Function

End Module

www.nxjournaling.com
 
Thanks, but after trying it I realize that is is the default directory from NX just as the code suggests. I needed the save as directory of the current opened part which can be different from NX's directory. I did come accross UF_PART_ask_family_save_dir but it is an older style code and makes less sense to me.
 

After a lot of searching I found the following on the gtac website. It seems to work.

Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module report_part_families
Sub Main

Dim theSession As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim lw As ListingWindow = theSession.ListingWindow

Dim dir As String = ""
Dim family As Tag
Dim family_count As Integer
Dim families As Tag() 
Dim instance As Tag

lw.Open()

ufs.Part.AskFamilyInstance(displayPart.Tag, instance)
lw.WriteLine("Family instance = " & instance.ToString())

ufs.Part.AskFamInstSaveDir(dir)
lw.WriteLine("Family Instance Save Dir = " & dir)

ufs.Part.AskFamilies(displayPart.Tag, family_count, families)
lw.WriteLine("Families in Part = " & family_count.ToString())

for ii As Integer = 0 To family_count-1
  ufs.Part.AskFamilySaveDir(families(ii), dir)
  lw.WriteLine("Family = " & families(ii).ToString())
  lw.WriteLine("Family Save Dir = " & dir)
Next


End Sub
End Module
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top