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!

Link Part Name

Status
Not open for further replies.

nmiltner

Bioengineer
Jan 30, 2008
98
I am sure this is an easy one, but I am stumped. I am looking for a way to tie the part name to our title block. Kind of like linking to attributes using <W@attribute>, but where attribute is I would like it to link to the Leaf name. Any help would be appreciated.
We are using NX3, with no Teamcenter.

Thanks
 
Replies continue below

Recommended for you

Ok, I did some searching and was able to make this work using journaling.
I tried running the .vb file with a macro, so I could incorporate it into a toolbar, and it doesn't work. Is there a way to add the .vb to a toolbar button?
 
Using Customize, when you add a 'User Command' to a toolbar, under 'Edit Action', you can link to any of the following 'executables':

Journal Files (.vb)
User Function (.dll)
System Command
User Tools (.utd)
Macros (.macro)
GRIP (.gx)
KF Application (.dfa)


John R. Baker, P.E.
Product 'Evangelist'
NX Design
Siemens PLM Software Inc.
Cypress, CA
 
I got this figured out as well. I just edited a toolbat to link to the .vb instead of the .macro.
 
On this same note,
I have also found a .vb script on this site to make each part of an assembly the work part, and then it writes info about that part to a text window. See link below


also quoted below.
Can anyone provide me with a line of code to add to this in order to add an attribute to each part that is the aprt name, and where I would add it? I have come up with adding:

"part.SetAttribute("FILENAME",prototype.Leaf)" right below the "do stuff here" line in the code below, but that doesn't seem to exactly work. I know this is wordy, but any help would be greatly appreciated once again! Thanks

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.Assemblies
Module NXJournal

Dim Session As Session = Session.GetSession()



Sub Walk(c As Component, level As Integer)
Dim children As Component() = c.GetChildren()
Dim child As Component
Dim prototype As Part
If TypeOf c.Prototype Is Part Then
prototype = CType(c.Prototype, Part)
session.ListingWindow.WriteLine(New String(" "C, level) & prototype.FullPath & " " & prototype.Leaf & " " & c.Name)
msgbox("do stuff here") ' add lines to write to a file or an array

For Each child In children
Walk(child, level + 1)
Next


Else
session.ListingWindow.WriteLine(New String(" "C, level) & c.Name & " is not loaded")
End If
end sub

Sub Main
session.ListingWindow.Open
Dim part1 As Part

part1 = session.Parts.Work
Dim c As ComponentAssembly = part1.ComponentAssembly


Walk(c.RootComponent, 0)
End Sub





End Module
 
Have you tried just adding,

"prototype.SetAttribute("FILENAME",prototype.Leaf)"

Below the do stuff section??



Mark Benson
Aerodynamic Model Designer
 
Thanks Mark,
That seemed to do it.
 
I would also like to add the username of the person creating the drawing to the attributes. Does anyone know how this is referenced?
 
Do you know what the variable is though? For instance session.parts.work.leaf is the leaf name. Session.parts.work.(username) is what?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor