×
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!

*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

How I can know what is my tc dummypartname

How I can know what is my tc dummypartname

How I can know what is my tc dummypartname

(OP)
How I can know what is my tc dummypartname ?

CODE -->

Hi all, NXOpen API programmers.....

Normally when using a nxopen program together with a *.dlx file (BlockStyler) - it is not possible to run and and launch such a program , withpout having an active workpart in the NX session.....
Normaly not that big problem . but in my current project, I really need to be able to fire up the dialog - even if no parts are opened in the NX session..... 
In shortness: My program will show a dialog, where end users can choose between some pre-defined load options...
Lets call these "Favorites" or "Disiciplines"..... Depended on which kind of work task in the NX environment , it is very importnant, that users are using the correct loadoptions.....
But by using this program - it is straight forward for the users, to choose the desired discipline.......
How I solved the issue to let NX fire up Block Styler in NX session without any parts open....:
The trick is, that let the program open a part temporary in background, if no parts are active, when the program is executed...
1.In the very early beginning of the program open the dummypart quite in background (if no parts a active)...
2.let the program show the dialog in the NX GUI...
3.simply close the dummypart again....
4.user can continiue "playing" with the different settings and options in the dialog....
==================================================================
Feel free to let me know your comments - and ofcourse also give it try - if needed in your projects...
br. Lars...
 
(A small vdemo ideo is attached - all names and load options showed in this video, is just concept names and settings)....
 
Demo Choose Pre-defined Load Options In Nx Session-1.m4v (2)
>

(view in My Videos)
Me too
0
Reply
3 REPLIES
Re: Sharing of a method to fire up BlockStyler in NX session without any active parts open (no workp
Yamada
  Siemens Phenom Yamada  Siemens Phenom
Siemens Phenom
I can't read your code. Can you please insert it into your post using the "Insert Code" function, as explained here.
山田
yamada
0
Reply
Re: Sharing of a method to fire up BlockStyler in NX session without any active parts open (no workp
LarsKlokmose
  Siemens Pioneer LarsKlokmose  Siemens Pioneer
Siemens Pioneer
yeahh - I will do this.....
 
Remember if you will test - then change the variabel "dummyPartNumber" to places in the code...Simply the item number of your dummy part in teamcenter....
 
 
Public Sub New()
        Try
            theSession = Session.GetSession()
            theUI = UI.GetUI()
            theDlxFileName = lkl_dialog_name
            theDialog = theUI.CreateDialog(theDlxFileName)
            theDialog.AddUpdateHandler(AddressOf update_cb)
            theDialog.AddInitializeHandler(AddressOf initialize_cb)
            theDialog.AddDialogShownHandler(AddressOf dialogShown_cb)

            '#################################################################################################################################################################
            '########################################  START SPECIAL HANDLING OF CLOSING DUMMYPART - IF OPENEND QUITE  ##################################################
            '#################################################################################################################################################################
            '
            'When we come to this line - a workpart is always active - either the active workpart opened by the user in the NX session, or the dummy workpart opened from inside this program....
            '
            'Lets start find the Tag of the dummy part - no matter if it is opened or not.....
            Dim dummyPartNumber As String = "SGRE_LoadOption_DummyPart" ' Teamcenter (item) PartNumber >> will also be used when comparing active PartNumber...
            Dim dummyPartRevision As String = "001"
            Dim dummyPartFiletype As String = "master"
            Dim dummyPartFileName As String = ""
            Dim dummyPartTag As Tag ' to be used if part shall be closed....
            ufs.Ugmgr.EncodePartFilename(dummyPartNumber, dummyPartRevision, dummyPartFiletype, "", dummyPartFileName) 'we encode the four input parameters > output can be used to ask for the part tag later on...
            dummyPartTag = ufs.Part.AskPartTag(dummyPartFileName) ' now we have the Tag of the dummy part...NIce one...

            'Lets now find the Tag of the active workpart - no matter if the part is the dummy part, or a NX part opened from the NX user....
            Dim partName As String = ""
            Dim partNumber As String = ""
            Dim partRevision As String = ""
            Dim partFileType As String = ""
            Dim partFileName As String = ""
            ufs.Part.AskPartName(workPart.Tag, partName)
            ufs.Ugmgr.DecodePartFileName(partName, partNumber, partRevision, partFileType, partFileName) 'we decode active workpart > we need the partnumber > to be used when we compare with the dummy Part number...

            'Lets then compare if active partNumber is the same as the dummyPartNumber - if so - we simply close the dummy part.....
            If partNumber = dummyPartNumber Then
                ufs.Part.Close(dummyPartTag, 0, 1)
                NX("we closed the dummy part")
            End If
            'we are done with the workaround...
            '
            '#################################################################################################################################################################
            '#########################################  END SPECIAL HANDLING OF CLOSING DUMMYPART - IF OPENEND QUITE  ###################################################
            '#################################################################################################################################################################

        Catch ex As Exception

            '---- Enter your exception handling code here -----
            Throw ex
        End Try
    End Sub
Public Shared Sub Main()
        Dim Lkl_SGRE_Set_LoadOptions_Favorit As Lkl_SGRE_Set_LoadOptions_Favorit = Nothing
        Try

            '#################################################################################################################################################################
            '#############################################  START SPECIAL HANDLING OF OPENING A DUMMYPART  QUITE ###### ##################################################
            '#################################################################################################################################################################
            '
            'When we come to "this" stage in the program, the NX System & Block Styler requires that we have an active workpart in the NX session, before the program can continue.....
            'If no active part is present, when the NX user hit the button which starts this custom tool > we simply need to let the custom tool itself, open a dummy part in backgroound temporary...
            '
            'Lets start figure out if we have an active workpart...
            Dim theTempSession As Session = Session.GetSession
            Dim theTempWorkpart As Part = theTempSession.Parts.Work
            Dim theTempUfs As UFSession = UFSession.GetUFSession

            'If  not we have an active workpart, we need to open a dummy part ( in this case we simply open the dummy part in the background > ( so users will not be "confused"...!!!!!)....
            If theTempWorkpart Is Nothing Then
                Dim dummyPartNumber As String = "SGRE_LoadOption_DummyPart" ' Teamcenter (item) PartNumber
                Dim dummyPartRevision As String = "001"
                Dim dummyPartFiletype As String = "master"
                Dim dummyPartFileName As String = ""
                Dim dummyPartTag As Tag
                Dim dummyTag1 As Tag = Tag.Null
                Dim dummyTag2 As Tag = Tag.Null
                Dim dummyLoadStatus As UFPart.LoadStatus = Nothing
                theTempUfs.Ugmgr.EncodePartFilename(dummyPartNumber, dummyPartRevision, dummyPartFiletype, "", dummyPartFileName) 'now we have a partfile format, that can be used as argument, when we will open the part...
                theTempUfs.Part.OpenQuiet(dummyPartFileName, dummyTag1, dummyLoadStatus) ' open the dummy part Quiet....
                dummyPartTag = theTempUfs.Part.AskPartTag(dummyPartFileName) ' ask for the tag of the newly opened dummypart...
                theTempUfs.Assem.SetWorkPartQuietly(dummyPartTag, dummyTag2) ' then we simply set the dummypart as workpart > but still quite, and not visible for the NX user.....
            End If
            'we are done with the workaround...so far....we also need to close dummy part again, immediately after the dialog is shown for the user in NX GUI....>> see "Public Sub New"...
            '
            '#################################################################################################################################################################
            '##############################################  END SPECIAL HANDLING OF OPENING A DUMMYPART  QUITE #########################################################
            '#################################################################################################################################################################

            Lkl_SGRE_Set_LoadOptions_Favorit = New Lkl_SGRE_Set_LoadOptions_Favorit()
            ' The following method shows the dialog immediately
            Lkl_SGRE_Set_LoadOptions_Favorit.Show()

        Catch ex As Exception

            '---- Enter your exception handling code here -----
            theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
        Finally
            If Lkl_SGRE_Set_LoadOptions_Favorit IsNot Nothing Then
                Lkl_SGRE_Set_LoadOptions_Favorit.Dispose()
                Lkl_SGRE_Set_LoadOptions_Favorit = Nothing
            End If
        End Try
    End Sub
 
0
Reply
Re: Sharing of a method to fire up BlockStyler in NX session without any active parts open (no workp
samwiseh
 samwiseh  Pioneer
Pioneer
I just used this in a project and it was very handy. Here's what I ended up with in my C# implimentation.
 
 
workPart = session.Parts.Work;
var dummyPartTag = Tag.Null;
try
{
  if (workPart == null)
  {
    var dummyPartNumber = "<DUMMY PART NAME>";
    var dummyPartRevision = "<DUMMY REVISION>";
    var dummyPartFiletype = "master";
    var dummyPartFileName = "";
    ufs.Ugmgr.EncodePartFilename(dummyPartNumber, dummyPartRevision, dummyPartFiletype, "", out dummyPartFileName);
    ufs.Part.OpenQuiet(dummyPartFileName, out _, out _);
    dummyPartTag = ufs.Part.AskPartTag(dummyPartFileName);
    ufs.Assem.SetWorkPartContextQuietly(dummyPartTag, out _);
  }
}
catch (Exception ex)
{
  // ---- Enter your exception handling code here -----
  ui.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
}

/*******************************
/* Show Dialog
/******************************/

if (dummyPartTag != Tag.Null)
{
  ufs.Part.Close(dummyPartTag, 0, 1);
}
I check if "workPart" is null, because if it's not then I dont need to worry about loading a dummy part.
 
 
I also changed "SetWorkPartQuietly" to "SetWorkPartContextQuietly" which seems to work just the same in my project. The documentation says that SetWorkPartQuietly was deprecated in NX 5, so probably something to avoid if possible.
 
Thank you for post 

RE: How I can know what is my tc dummypartname

(OP)
Hi
This article was taken from plm forum.
And I don't know how I can get the
Dummy part name in our tc.

Any help.
Thank you.

RE: How I can know what is my tc dummypartname

Hi Ehaviv -

I did write the article on Siemens PLM forum....
Also authored the code…

You can simply create your own "dummy Part" in Tc.
Name it whatever you like....
Then in the code simply change this variabel:

CODE -->

Dim dummyPartNumber As String = "your dummy Part" ' Teamcenter (item) PartNumber 

That's it...

(Lars K)
lklo

RE: How I can know what is my tc dummypartname

(OP)
Hi Lars and thank you very much.
Actually I was worked around this
Issue by creating new part and
Close it immediately after closing
The dialog and the app continue
Processing with the data collected
From ty dialog.

Without saying any part.

And I was thinking that an existing
Dummy part will be good.

But this only works for myself
And no for everyone.

Thank you vy much.

RE: How I can know what is my tc dummypartname

(OP)
I mean if the dummy part is not
A built-in in teamcenter.
Not everyone can use my app.

RE: How I can know what is my tc dummypartname

(OP)
Your trick is awesome.

If we could ensure that a dummy part
that we choose is never exists
in a teamcenter that will be great.

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! Already a Member? Login


Resources

White Paper - Reshoring Prototyping and Production
In this whitepaper, we'll provide insight into why and when it makes sense for U.S. manufacturers to reshore prototyping and production, and how companies can leverage the benefits of working with local design, prototype, and manufacturing partners during the pandemic and beyond. Download Now
Engineering Report - Top 10 Defect Types in Production
This 22-page report from Instrumental identifies the most common production defect types discovered in 2020, showcases trends from 2019 to 2020, and provides insights on how to prevent potential downtime in 2021. Unlike other methods, Instrumental drives correlations between a variety of data sources to help engineers find and fix root causes. Download Now
White Paper - Addressing Tooling and Casting Requirements at the Design Stage
Several of the tooling and casting requirements of a part can be addressed at the design stage. If these requirements are not addressed at the design stage, lot of time is spent in design iteration when the design reaches the die caster. These design issues lead to increase in time and cost of production leading to delay in time to market and reduced profits for the organization. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close