×
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

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

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

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

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

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

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

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

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

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

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

(OP)

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 

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