×
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

seed part issue

seed part issue

seed part issue

(OP)
Hi

This example is for master part.
I need help to modify it to be for non-master part.

Thank you.

CODE -->

Option Strict Off

Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.UI
Imports NXOpenUI
Imports NXOpen.Utilities

Module create_new_nxmanager_part_from_template

   Public s As Session = Session.GetSession()
   Public ufs As UFSession = UFSession.GetUFSession()
   Public lw As ListingWindow = s.ListingWindow

   Sub Main()

      Dim encodedName As String = ""

      Dim encodedTemplateName As String = "@DB/Metric/A"

      Dim partFileName As String = ""
      Dim partTag As NXOpen.Tag = NXOpen.Tag.Null

      Dim partNumber As String = ""
      Dim partRev As String = ""
      Dim partType As String = "Item"

      partNumber = NXInputBox.GetInputString("Part Number:", _
                                     "User Input:", "Part Number")

      partRev = NXInputBox.GetInputString("Revision:", _
                                     "User Input:", "A")

      partType = NXInputBox.GetInputString("Part Type:", _
                                     "User Input:", partType)

      encodedName = "@DB/" + partNumber + "/" + partRev

      ufs.Ugmgr.NewPartFromTemplate(encodedName, partType, _
                                         encodedTemplateName, partTag)

   End Sub

   Public Function GetUnloadOption(ByVal dummy As String) As Integer

      Return Session.LibraryUnloadOption.Immediately

   End Function

End Module 

RE: seed part issue

I do not understand.
Why do you use home made code to create a new part ?


Regards,
Tomas

RE: seed part issue

(OP)
I don't like some company settings.
To mention one.
I like black screen as background.

I Already have a journal for master part seed and now I want to reach the same
for the non master.

Thank you.

RE: seed part issue

Company settings are there for a reason wink

Ronald van den Broek
Senior Application Engineer
Winterthur Gas & Diesel Ltd
NX9 / TC10.1.2

Building new PLM environment from Scratch using NX12 / TC11

RE: seed part issue

(OP)
In general you right.

But things like objects colour
Background style are personal.
No one can force me to work with
Colors that I don't like or interfere
eyes

Thank you.

RE: seed part issue

Im no expert and could be way off here, but it seems to me this would be calling a specific template when it creates a new part file. Isnt that template what dictates whether it is a master or non-master? To create a non-master, you would have to create a non-master template and call that one instead.

Sorry if thats not close. lol

Just food for thought however, we have a similar problem where our customer wants us to use a specific template because they wanted certain settings, but many of the other settings that are not important are not what we like to use. What I did was to create a "SETUP" button that has all of the settings how we like them. When we open a file or start a new file, we just hit that button and it changes everything automatically. So we dont mess with the template our customer expects us to use. This also helps in cases where someone doesnt use the correct template when they create a file. Running the setup button fixes the settings.

I also have buttons to do specific things like change background color etc... So if someone makes it something weird and I have to work on the file next, its a click of a button to change it.

RE: seed part issue

(OP)
Thank you kenja824.

That's was my first thought.
But because there are many preferences
To set programmatically I preferred
To go this way.

RE: seed part issue

Screen background color should be independent of the model.
Object colors where I used to work were also set by the company standards and checked to be sure the user did not change them.

The design belongs to your employer, so they CAN force you to design using their preferred colors.

"Wildfires are dangerous, hard to control, and economically catastrophic."

Ben Loosli

RE: seed part issue

Ehaviv,

(if the original question remains...)

The creation of a non-master would need to be changed from your example

encodedName = "@DB/" + partNumber + "/" + partRev

to include the "specification" for file type and the dataset name (of the non-master).

encodedName = "@DB/" + partNumber + "/" + partRev + "/specification/" + datasetName

The item revision (of the master) must already exist.

HTH, Joe

RE: seed part issue

(OP)
looslib thank you.
In our company its not so close.

RE: seed part issue

(OP)
jpetach thank you.

Your post is the first that is right
to the issue.
I'll edit and test it.

Thank you again.

RE: seed part issue

(OP)
Hi jpetach

I prepared this code according your help.
next week I'll have access to nxmanager to test it.
please can you take a look and note something.
thank you.

CODE -->

Imports System
Imports NXOpen
Imports NXOpen.UF

Module newpartfromtemplate
                           
 Sub Main (ByVal args() As String)

   Dim s As Session = Session.GetSession()
   Dim ufs As UFSession = UFSession.GetUFSession
   Dim displayPart As Part = Nothing

   Dim part_number As String = ""
   Dim part_revision As String = ""
   Dim part_file_type As String = "specification"
   Dim part_file_name As String = "dwg1"

   Dim seed_coded As String = ""
   Dim newEncodedName As String = Nothing
   Dim partTag As NXOpen.Tag = NXOpen.Tag.Null

   displayPart = s.Parts.Display

   part_number = displayPart.FullPath.Split("/")(0)
   part_revision = displayPart.FullPath.Split("/")(1)

   ufs.Ugmgr.EncodePartFilename(part_number, part_revision, part_file_type, part_file_name, newEncodedName)
   msgbox("newEncodedName = " & newEncodedName)

   part_number = "nx11_seed_mm" ' do I need to have 2 seed parts (1 for master, 1 for nonmaster)
                                ' or only 1 for the master and nonmaster

   ufs.Ugmgr.EncodePartFilename(part_number, part_revision, part_file_type, part_file_name, seed_coded)
   msgbox("seed_coded = " & seed_coded)

   ufs.Ugmgr.NewPartFromTemplate(newEncodedName, part_file_type, seed_coded,partTag)
  
 End Sub
'-----------------------------------------------------------------------------------,
 Public Function GetUnloadOption(ByVal dummy As String) As Integer
   GetUnloadOption = UFConstants.UF_UNLOAD_IMMEDIATELY
 End Function

End Module 

RE: seed part issue

(OP)
Hi

These recorded journals work OK in native mode.
Do the will work in managed mode. (with the changes shown in code)

recrded new_master_blank_template journal

CODE -->

' NX 11.0.0.33
'
Imports System
Imports NXOpen
Imports NXOpen.UF

Module NXJournal
Sub Main (ByVal args() As String) 

Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()

Dim fileNew1 As NXOpen.FileNew = Nothing
fileNew1 = theSession.Parts.FileNew()

'fileNew1.TemplateFileName = "Blank"

fileNew1.UseBlankTemplate = True
fileNew1.ApplicationName = "GatewayTemplate"
fileNew1.Units = NXOpen.Part.Units.Millimeters
fileNew1.RelationType = ""
fileNew1.UsesMasterModel = "Yes"
fileNew1.TemplateType = NXOpen.FileNewTemplateType.Item
fileNew1.TemplatePresentationName = ""
fileNew1.ItemType = ""
fileNew1.Specialization = ""
fileNew1.SetCanCreateAltrep(False)

'fileNew1.NewFileName = "C:\_nx11_\parts\" & randNewPartName()  'native
'fileNew1.MasterFileName = "C:\_nx11_\parts\blank.prt"          'native

fileNew1.NewFileName = "@DB/" & randNewPartName() & "/-"        'manage
fileNew1.MasterFileName = "@DB/blank/-"                         'manage

fileNew1.MakeDisplayedPart = True
Dim nXObject1 As NXOpen.NXObject = Nothing
nXObject1 = fileNew1.Commit()
Dim workPart As NXOpen.Part = theSession.Parts.Work
Dim displayPart As NXOpen.Part = theSession.Parts.Display

fileNew1.Destroy()
msgbox(displayPart.FullPath)
theSession.ApplicationSwitchImmediate("UG_APP_GATEWAY")

theSession.ApplicationSwitchImmediate("UG_APP_MODELING")

End Sub 


recrded new_nonmaster_blank_template journal

CODE -->

' NX 11.0.0.33
'
Imports System
Imports NXOpen

Module NXJournal
Sub Main (ByVal args() As String) 

Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
Dim workPart As NXOpen.Part = theSession.Parts.Work
Dim displayPart As NXOpen.Part = theSession.Parts.Display

'   Menu: File->New...

Dim fileNew1 As NXOpen.FileNew = Nothing
fileNew1 = theSession.Parts.FileNew()

'fileNew1.TemplateFileName = "Blank"

fileNew1.UseBlankTemplate = True
fileNew1.ApplicationName = "DrawingTemplate"
fileNew1.Units = NXOpen.Part.Units.Millimeters
fileNew1.RelationType = ""
fileNew1.UsesMasterModel = "Yes"
fileNew1.TemplateType = NXOpen.FileNewTemplateType.Item
fileNew1.TemplatePresentationName = ""
fileNew1.ItemType = ""
fileNew1.Specialization = ""
fileNew1.SetCanCreateAltrep(False)

'fileNew1.NewFileName = workPart.FullPath.Replace(".prt", "_dwg1.prt")       'native
'fileNew1.MasterFileName = workPart.Leaf                                     'native

fileNew1.NewFileName = "@DB/" & workPart.FullPath & "/specification/_dwg1"   'manager
fileNew1.MasterFileName = "@DB/" & workPart.FullPath                         'manager

fileNew1.MakeDisplayedPart = True

Dim nXObject1 As NXOpen.NXObject = Nothing
nXObject1 = fileNew1.Commit()

workPart = theSession.Parts.Work ' model3_dwg1
displayPart = theSession.Parts.Display ' model3_dwg1
fileNew1.Destroy()
theSession.ApplicationSwitchImmediate("UG_APP_DRAFTING")
workPart.Drafting.EnterDraftingApplication()
Dim modelingView1 As NXOpen.ModelingView = _
   CType(workPart.ModelingViews.FindObject("Trimetric"), NXOpen.ModelingView)
modelingView1.UpdateCustomSymbols()
workPart.Drafting.SetTemplateInstantiationIsComplete(True)

End Sub
End Module 

Thank you in advanced.

RE: seed part issue

(OP)
Hi

at last have opportunity to test thes journls in nxmanager platform.
the first journal run OK.

and the second journal throw this error: "object does not exist" on this statement
ufs.Ugmgr.NewPartFromTemplate(encodedName, partType, encodedTemplateName, partTag)

Please help to go out from this error.

Thak you very much.

CODE -->

Option Strict Off

Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.UI
Imports NXOpenUI
Imports NXOpen.Utilities

Module new_master_part_from_template

   Public s As Session = Session.GetSession()
   Public ufs As UFSession = UFSession.GetUFSession()
   Public lw As ListingWindow = s.ListingWindow

   Sub Main()

      Dim encodedName As String = ""
      Dim encodedTemplateName As String = "@DB/nx11_seed_part_mm/-"
      Dim partFileName As String = ""
      Dim partTag As NXOpen.Tag = NXOpen.Tag.Null
      Dim partNumber As String = ""
      Dim partRev As String = ""
      Dim partType As String = "Item"

      s.PdmSession.SetDefaultFolder("")
      partNumber = "my_part_123456"
      partRev = "-"
      encodedName = "@DB/" + partNumber + "/" + partRev

      ufs.Ugmgr.NewPartFromTemplate(encodedName, partType, encodedTemplateName, partTag)

   End Sub

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

End Module 



CODE -->

Option Strict Off

Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.UI
Imports NXOpenUI
Imports NXOpen.Utilities

Module new_nonmaster_part_from_template

   Public s As Session = Session.GetSession()
   Public ufs As UFSession = UFSession.GetUFSession()
   Public lw As ListingWindow = s.ListingWindow

   Sub Main()

      Dim workPart As Part = s.Parts.Work
      Dim encodedName As String = ""
      Dim encodedTemplateName As String = "@DB/nx11_seed_part_mm/-"

      Dim partFileName As String = ""
      Dim partTag As NXOpen.Tag = NXOpen.Tag.Null

      Dim partNumber As String = ""
      Dim partRev As String = ""
      Dim partType As String = "specification"

      partNumber = workPart.FullPath.Split("/")(0)
      partRev = workPart.FullPath.Split("/")(1)

      encodedName = "@DB/" + partNumber + "/" + partRev + "/specification/" + partNumber + "d00"

      ufs.Ugmgr.NewPartFromTemplate(encodedName, partType, encodedTemplateName, partTag)

   End Sub

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

End Module 

RE: seed part issue

(OP)
Hi

I run this journal to check these variables:
itemId , revId, specName, partType

and the output is fit the above journals.
so Iwonder why the second journal not run.

Please can someone put a finger on the problem point.
Thank you.

CODE -->

Imports System

Imports NXOpen
Imports NXOpen.UF

Module ugmgr_decode_part_File_name

  Sub Main ()

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

      Dim partName As String
      Dim itemId As String
      Dim revId As String
      Dim specName As String
      Dim partType As String

      Dim tWrk As Tag = ufs.Assem.AskWorkPart()
      ufs.Part.AskPartName(tWrk, partName)
      
      ufs.Ugmgr.DecodePartFileName(partName, itemId, revId, partType, specName)
      lw.WriteLine("itemId = " & itemId)
      lw.WriteLine("revId = " & revId)
      lw.WriteLine("partType = " & partType)
      lw.WriteLine("specName = " & specName)

  End Sub

End Module

'-------------------------------------------
'
' Output of this journal on my system is:
'
' On master part
'
'     itemId    = 123456
'      revId    = - 
'      partType = master 
'      specName = 
'
' On non-master part

'     itemId    = 123456
'      revId    = -
'      partType = specification 
'      specName = 123456d00 

RE: seed part issue

There are 2 other solutions to this issue, if it's only the colors you want to change.
instead of creating you own template.

1) create a Visualisation template.
A visualisation template will simply change the colors in the active file when used.
The bad is that you will have to apply the V.T on every file you open /edit / create. ( one click each.)
The good is that you do not have to make sure that your own template is up to date with possible changes done by your admin team.

"
There is a interactive method that requires no programming at all smile
1)Open a part file in which you like the color settings.
2) Open the "Roles palette"
3) RMB in the "whitespace" in the roles palette, -"new palette". The result is a new , empty, palette.
4) in the new palette : RMB- New entry - Visualization template, a new dialog will open, DESELECT all options except the "backgrounds".
IF you enable all options in this dialog, the visualization template will push ALL these settings into your next part, include current zoom/rotation etc.
also note that you can change the colors in this dialog.
OK

5) open the part where you like to change the background. Click the visualization template. Done. ( even simpler than running a program smile
"
From : https://www.eng-tips.com/viewthread.cfm?qid=408605

2) set a personal color palette that will be active when You on this computer loads any file.
See my last post on this :
https://www.eng-tips.com/viewthread.cfm?qid=428596


Regards,
Tomas

RE: seed part issue

(OP)
Tomas Thank you.
I'm already achieved a solution with a journal that save as my seed part
to a new part.

But now I am stacked with a mind
problem why the above Journal not
working.

RE: seed part issue

Ehaviv,

For the second journal to work the master part revision must already exist.

Was a "save part" performed after the first journal(and before the second journal)?

HTH,
Joe

RE: seed part issue

(OP)
Hi jpetach and thank you.
Yes.
After running the first journal
I perform a manual save.
And then running the second journal.

RE: seed part issue

(OP)

This journal work ok.(built by recording a save as of a seed part)
but is generate the ugmaster and the ugpart at once.

I want to get a separate steps 1 ugmaster and 2 ugpart.


CODE -->

Imports System
Imports NXOpen
Imports NXOpen.UF

Module new_part_by_part_from_part_builder

 Sub Main (ByVal args() As String)
 
   Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()

   Dim workPart As NXOpen.Part =   Nothing
   Dim displayPart As NXOpen.Part =  Nothing
   Dim basePart1 As NXOpen.BasePart = Nothing
   Dim partLoadStatus1 As NXOpen.PartLoadStatus = Nothing
   Dim partFromPartBuilder1 As NXOpen.PDM.PartFromPartBuilder = Nothing
   Dim newname As String = Nothing
   Dim seedPart As String = Nothing

   seedPart = "@DB/nx11_seed_part_mm/-"
   newname = CreateNewName() ' this only generate randomaly a name

   theSession.Parts.SetNonmasterSeedPartData(seedPart)
   basePart1 = theSession.Parts.OpenBaseDisplay(seedPart, partLoadStatus1)
   workPart = theSession.Parts.Work
   displayPart = theSession.Parts.Display
   partLoadStatus1.Dispose()
   theSession.ApplicationSwitchImmediate("UG_APP_GATEWAY")
   theSession.ApplicationSwitchImmediate("UG_APP_MODELING")

   partFromPartBuilder1 = theSession.Parts.PDMPartManager.NewPartFromPartBuilder()
   theSession.PdmSession.SetDefaultFolder("")   
   partFromPartBuilder1.CreatePartSpec("External", newname, "-", "master", "")
   partFromPartBuilder1.CreateNonmasterList()
   partFromPartBuilder1.NonmasterSaveAsOption = NXOpen.PDM.PartFromPartBuilder.FileSaveAs.All
   partFromPartBuilder1.Commit()
   partFromPartBuilder1.Dispose()

 End Sub 

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

eBook - Efficient and Effective Production Support with 3D Printed Jigs and Fixtures
Jigs and fixtures offer manufacturers a reliable process for delivering accurate, high-quality outcomes, whether for a specific part or feature, or for consistency across multiples of parts. Although the methodologies and materials for producing jigs and fixtures have evolved beyond the conventional metal tooling of years past, their position as a manufacturing staple remains constant due to the benefits they offer. Download Now
Overcoming Cutting Tool Challenges in Aerospace Machining
Aerospace manufacturing has always been on the cutting edge, from materials to production techniques. However, these two aspects of aerospace machining can conflict, as manufacturers strive to maintain machining efficiency with new materials by using new methods and cutting tools. 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