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!

NX Journal ID Symbol GetAssociativity 1

Status
Not open for further replies.

HagenT

Mechanical
Dec 1, 2015
14
Hy at all,

i have a little problem with my Journal.
I have a drawing with a lot of id symbols created by the user manuel. Now i whant to modify the part is associated with the symbol.
There is no Attribute created to the part or somthimg else i can identify it. So i need to get it via the id symbol to create an attribute.


I tried it with the following code but didn´t work.

Code:
 Imports System.Collections
Imports NXOpen
Imports NXOpen.Annotations
Imports NXOpen.UF
Public Class test
	' class members
	Private Shared theSession As Session
	Private Shared theUI As UI
	Private Shared theUfSession As UFSession
	Private Shared lw As ListingWindow

	Public Shared Function Main(args As String()) As Integer
		theSession = Session.GetSession()
		theUI = UI.GetUI()
		theUfSession = UFSession.GetUFSession()
		lw = theSession.ListingWindow

		Try
			Dim idCol As IdSymbolCollection = theSession.Parts.Work.Annotations.IdSymbols
			Dim ids As IdSymbol
			Dim iEnum1 As IEnumerator = idCol.GetEnumerator()
			iEnum1.Reset()
			While iEnum1.MoveNext()
				ids = DirectCast(iEnum1.Current, IdSymbol)
				lw.Open()
				lw.WriteLine(vbLf & "Symbol: " + ids.Tag.ToString())

				Dim idsb As IdSymbolBuilder = idCol.CreateIdSymbolBuilder(ids)
				lw.WriteLine(" Text: " + idsb.UpperText)
				idsb.Destroy()

				lw.WriteLine(" Number of Associativities: " + ids.NumberOfAssociativities)
				For i As Integer = 1 To ids.NumberOfAssociativities
					Dim assoc As Associativity = ids.GetAssociativity(i)
					Dim obj As NXObject = assoc.FirstObject
					lw.WriteLine(" Assoc No." + i + ": " + obj.ToString())
					lw.WriteLine("  Owning Part: " + obj.OwningPart.FullPath)
					If obj.IsOccurrence Then
						lw.WriteLine("  Owning Component: " + obj.OwningComponent.Name)
					End If
				Next
			End While
		Catch ex As NXOpen.NXException
			UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.[Error], ex.Message)
		End Try
		Return 0
	End Function

	Public Shared Function GetUnloadOption(arg As String) As Integer
		Return System.Convert.ToInt32(Session.LibraryUnloadOption.Immediately)
	End Function

End Class

Thanks Hagen
 
Replies continue below

Recommended for you

There is some code here that you may find of interest:

The journal was written to work with "Pre-NX 8.5 Exact" drafting views. If you are using the newer "exact" drafting views, it may give incorrect or unexpected results in some situations (depending on what the ID symbol is attached to).

www.nxjournaling.com
 
Hey cowski,

Sorry I forgot to write the version.

I'm using NX 9 and TC 10.

Now I don't know how to modify the code to get it working.
I started with nx journal a few days before.
It is hard to understand the net.ref.
Can you help me?

Thanks Hagen
 
Hy cowski,

thanks for helping me.

I take the code from nxjournaling and modify it for me.
Now it works fine.

I also tried to get an account on nxjournaling but i never recived a mail. So i can not loggin.

Thanks Hagen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor