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.

Jobs

Journal/code to auto populate attributes

Journal/code to auto populate attributes

(OP)
Hi all,

Would anyone be able to help me out with some code that I could assign to a button that when pressed would open a menu/text entry box that would allow me to populate some attributes in the model such as project number and client name? Cowski, I'm looking in your direction winky smile

Cheers

Si.

Best regards

Simon

NX7.5 NX8.5 NX9 NX10 NX11
NX Consultant
www.team-eng.com

RE: Journal/code to auto populate attributes

Do you mean a journal to select a body and a dialog
be opened and lets you assigne an attributes to that body.

RE: Journal/code to auto populate attributes

(OP)
Not to assign attributes to the body, but to the part file itself so when I create a custom drawing border the fields will auto populate. So the workflow would look something like this..

1. create a model
2. Assign a material (standard library)
3. The seed part would have some additional attribute (Project number and client and perhaps a couple more)
4. I would then want to press a button and have a menu appear with two (or more) entry fields (project and client) I would manually type these values in and when I press OK the attribute would now be populated.
5. I then create a drawing and populate the title box but the fields in the title box for project and client would be locked and automatically populated based on the attributes that were assigned in the model.

cheers

Si

Best regards

Simon

NX7.5 NX8.5 NX9 NX10 NX11
NX Consultant
www.team-eng.com

RE: Journal/code to auto populate attributes

Is this what you are looking for?

CODE --> vb

'Created By Jeremy Shooks 08-11-2017
Option Strict Off  
Imports System  
Imports System.Collections.Generic  
Imports System.Windows.Forms
Imports NXOpen
Imports NXOpenUI

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

Dim theSession As Session = Session.GetSession()
Dim theUI As UI = UI.GetUI()



'Insert code here

Dim cur_MM_ProjectNumber As String
Dim MM_ProjectNumber As String

Dim cur_MM_ClientName As String
Dim MM_ClientName As String

	MM_ProjectNumber:
	Try
	cur_MM_ProjectNumber = thesession.Parts.Work.GetStringAttribute("MM_ProjectNumber")
	Catch exc As NXException
	MM_ProjectNumber = NXInputBox.GetInputString("Enter ProjectNumber Number", "Enter ProjectNumber Number","Number")
	MM_ProjectNumber = MM_ProjectNumber.ToUpper()
	theSession.Parts.Work.SetAttribute("MM_ProjectNumber", MM_ProjectNumber)
	goto Client_Name
	End Try
	MM_ProjectNumber = NXInputBox.GetInputString("Enter ProjectNumber Numbe", "Enter ProjectNumber Number",cur_MM_ProjectNumber)
	MM_ProjectNumber = MM_ProjectNumber.ToUpper()
	theSession.Parts.Work.SetAttribute("MM_ProjectNumber", MM_ProjectNumber)

	Client_Name:
	
		Try
	cur_MM_ClientName = thesession.Parts.Work.GetStringAttribute("MM_ClientName")
	Catch exc As NXException
	MM_ClientName = NXInputBox.GetInputString("Enter ClientName Number", "Enter ClientName Number","Name")
	MM_ClientName = MM_ClientName.ToUpper()
	theSession.Parts.Work.SetAttribute("MM_ClientName", MM_ClientName)
	goto Last
	End Try
	MM_ClientName = NXInputBox.GetInputString("Enter ClientName Numbe", "Enter ClientName Number",cur_MM_ClientName)
	MM_ClientName = MM_ClientName.ToUpper()
	theSession.Parts.Work.SetAttribute("MM_ClientName", MM_ClientName)

	Last:

End Sub
End Module 

RE: Journal/code to auto populate attributes

(OP)
Brilliant, thank you all.

Best regards

Simon

NX7.5 NX8.5 NX9 NX10 NX11
NX Consultant
www.team-eng.com

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


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