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 to import assembly into Teamcenter with "Add Suffix"

Status
Not open for further replies.

hovelale

Mechanical
Jun 11, 2012
28
I’m pretty sure some of you are going to know what I’m doing wrong really quickly. I am trying to make a Journal that imports an assembly into Teamcenter, specifically with the Append or Add Suffix Rule Type. Let me explain a little more why I want to use this Rule Type.

I found that AutoTranslate won’t work because of the default naming rules that change the string after the last “_” (underscore) to a revision. For example, with AutoTranslate, model_1.prt and model_2.prt would be renamed to @DB/model/1 and @DB/model/2. So I get same Item, 2 revisions.

I did some “manual” testing by going into File -> Import Assembly into Teamcenter and by changing the Import numbering to Number Rule and changing the Numbering Rule to “Add Suffix”, and type a blank space in the Add String, and once it’s imported into Teamcenter, it keeps the same name, just adds the Revision according to my Revision Rules. So in this case, using the same example as above, model_1.prt and model_2.prt would import as @DB/model_1/A, and @DB/model_2/A (apparently without the blank space), which is 2 items, both on revision “A”. I would have thought that the result would be @DB/model_1 /A (a space in between the 1 and the /). But I was gladly surprised that the result was what I was looking for. Keeping the same “leaf” name if you will, just adding the revision.

So now I’m trying to create a Journal to do this behavior in a more automatic way. I’ve read some of the Programing API Documentation, but I’m not that good a programmer. And the Import Assembly can’t be recorded with the Journal commands so it’s not so simple.

Here is what I have so far. I’ve added commets to explain my reasoning hopefully making it more clear to someone with more experience what or where I’m going wrong.

Code:
Option Strict Off
Imports System
Imports System.IO
Imports NXOpen
Imports NXOpenUI
Imports NXOpen.UF
Imports NXOpen.UI
Imports NXOpen.Utilities
Imports NXOpen.PDM

Module ModuleTC

    Sub Main()
        Dim theSession As Session = Session.GetSession()
        Dim theUI As UI = UI.GetUI()
        Dim ufs As UFSession = UFSession.GetUFSession()

        Dim naming_failures As UFClone.NamingFailures
        Dim naming_technique As UFClone.NamingTechnique
        Dim name_rule As UFClone.NameRuleDef 'Do I need this?
        Dim append As String = " "           'I want to append the blank space

        ufs.Clone.Initialise(UFClone.OperationClass.ImportOperation)
        ufs.Clone.AddPart("C:\temp\model_1.prt")
        ufs.Clone.SetDefAction(UFClone.Action.Overwrite)
        ufs.Clone.SetDefFolder("infodba:Newstuff:IMPORT")
        naming_technique = UFClone.NamingTechnique.NamingRule 'I want to use this rule, but where do I declare what will be appended?
        append = UFClone.NameRuleType.AppendString            'Is this the way to declare the string to be appended?

        '==== Do I need this? ====
        name_rule.base_string = "base string"
        name_rule.new_string = "new string"
        name_rule.type = UFClone.NameRuleType.AppendString
        '==== End Question ====

        naming_failures.n_failures = 0      'No idea what this does
        naming_failures.statuses = {0}      'No idea what this does 
        naming_failures.input_names = {""}  'No idea what this does
        naming_failures.output_names = {""} 'I think this is the output "error message" you'd get in the window if there is a problem

        ufs.Clone.PerformClone(naming_failures)
        ufs.Clone.Terminate()

    End Sub
    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
    End Function

End Module


Any insight on what I might be doing wrong will be greatly appreciated.
Best Regards!
 
Replies continue below

Recommended for you

Status
Not open for further replies.

Part and Inventory Search

Sponsor