×
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

Adding Attributes to Properties with Journal (NX9)

Adding Attributes to Properties with Journal (NX9)

Adding Attributes to Properties with Journal (NX9)

(OP)
Language = Visual Basic
File Format = Unicode

I created a journal to go into Properties of a file and add three attributes. However, it only seems to add the last of the three attributes. If I turn off the lines for the third attribute, it then adds the second attribute.

When doing Drafting Preferences, I could add a bunch of changes to them all in a row and it would do all of them. I figured adding attributes would be the same way but its not working out that way.

Here is what my code looks like.....

Option Strict Off
Imports System
Imports NXOpen
Module NXJournal
Sub Main (ByVal args() As String)
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")
Dim objects3(0) As NXObject
objects3(0) = workPart

Dim attributePropertiesBuilder1 As AttributePropertiesBuilder
attributePropertiesBuilder1 = theSession.AttributeManager.CreateAttributePropertiesBuilder(workPart, objects3, AttributePropertiesBuilder.OperationType.None)

theSession.SetUndoMarkName(markId1, "Displayed Part Properties Dialog")

attributePropertiesBuilder1.Title = "F_ENGR"
attributePropertiesBuilder1.IsArray = False
attributePropertiesBuilder1.StringValue = "JOHN SMITH"

attributePropertiesBuilder1.Title = "F_ENGRPH"
attributePropertiesBuilder1.IsArray = False
attributePropertiesBuilder1.StringValue = "248-555-5555"

attributePropertiesBuilder1.Title = "PROGRAM"
attributePropertiesBuilder1.IsArray = False
attributePropertiesBuilder1.StringValue = "XXXX"

Dim nXObject1 As NXObject
nXObject1 = attributePropertiesBuilder1.Commit()

attributePropertiesBuilder1.Destroy()
' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------
End Sub
End Module


I know the change will be simple but I just dont know Journal well enough yet to see what I need to change or add.
Also, I will likely be adding more attributes in the future, if that makes any difference.
Thanks

RE: Adding Attributes to Properties with Journal (NX9)

(OP)
OOPS.....

Where it says OBJECTS3, used to say OBJECTS1. I changed that hoping to figure this out for myself and forgot to put it back when I posted this. Sorry for any confusion.

RE: Adding Attributes to Properties with Journal (NX9)

Hello kenja824, below is working code with my changes:

CODE

Option Strict Off
Imports System
Imports NXOpen
Module NXJournal

	Sub Main ()

	Dim theSession As Session = Session.GetSession()
	Dim workPart As Part = theSession.Parts.Work
	Dim markId1 As Session.UndoMarkId
	markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")
	Dim objects(0) As NXObject
	objects(0) = workPart

	Dim attributePropertiesBuilder1 As AttributePropertiesBuilder
		attributePropertiesBuilder1 = workpart.PropertiesManager.CreateAttributePropertiesBuilder(objects)

	Dim attributePropertiesBuilder2 As AttributePropertiesBuilder
		attributePropertiesBuilder2 = workpart.PropertiesManager.CreateAttributePropertiesBuilder(objects)

	Dim attributePropertiesBuilder3 As AttributePropertiesBuilder
		attributePropertiesBuilder3 = workpart.PropertiesManager.CreateAttributePropertiesBuilder(objects)


	theSession.SetUndoMarkName(markId1, "Displayed Part Properties Dialog")

		attributePropertiesBuilder1.ObjectPicker = AttributePropertiesBaseBuilder.ObjectOptions.ComponentAsPartAttribute
		attributePropertiesBuilder1.DataType = AttributePropertiesBaseBuilder.DataTypeOptions.String
		attributePropertiesBuilder1.Title = "F_ENGR"
		attributePropertiesBuilder1.IsArray = False
		attributePropertiesBuilder1.StringValue = "JOHN SMITH"

		attributePropertiesBuilder2.ObjectPicker = AttributePropertiesBaseBuilder.ObjectOptions.ComponentAsPartAttribute
		attributePropertiesBuilder2.DataType = AttributePropertiesBaseBuilder.DataTypeOptions.String
		attributePropertiesBuilder2.Title = "F_ENGRPH"
		attributePropertiesBuilder2.IsArray = False
		attributePropertiesBuilder2.StringValue = "248-555-5555"

		attributePropertiesBuilder3.ObjectPicker = AttributePropertiesBaseBuilder.ObjectOptions.ComponentAsPartAttribute
		attributePropertiesBuilder3.DataType = AttributePropertiesBaseBuilder.DataTypeOptions.String
		attributePropertiesBuilder3.Title = "PROGRAM"
		attributePropertiesBuilder3.IsArray = False
		attributePropertiesBuilder3.StringValue = "XXXX"

	Dim nXObject1 As NXObject
		nXObject1 = attributePropertiesBuilder1.Commit()
		attributePropertiesBuilder1.Destroy()

	Dim nXObject2 As NXObject
		nXObject2 = attributePropertiesBuilder2.Commit()
		attributePropertiesBuilder2.Destroy()

	Dim nXObject3 As NXObject
		nXObject3 = attributePropertiesBuilder3.Commit()
		attributePropertiesBuilder3.Destroy()

	End Sub

End Module 



With best regards
Michael

RE: Adding Attributes to Properties with Journal (NX9)

(OP)
Thanks niedzviedz. This worked perfect. Easy to figure out how to add more too.

RE: Adding Attributes to Properties with Journal (NX9)

Hi Niedzviedz,
This is awesome journal, Is it possible to add same attributes in all components in assembly file.


Regards,
Ganesh

RE: Adding Attributes to Properties with Journal (NX9)

Hello gani009, please look at my thread:
http://www.eng-tips.com/viewthread.cfm?qid=375494

some time ago I have similar question, and I solved it in this thread. If You have any questions, don't hesitate to post there Your questions.

With best regards
Michael

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