Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Journal/code to auto populate attributes 2

Status
Not open for further replies.

SiW979

Mechanical
Nov 16, 2007
804
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 ;-)

Cheers

Si.

Best regards

Simon

NX7.5 NX8.5 NX9 NX10 NX11
NX Consultant
 
Replies continue below

Recommended for you

Do you mean a journal to select a body and a dialog
be opened and lets you assigne an attributes to that body.
 
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
 
Is this what you are looking for?

Code:
'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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor