×
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

Journal to find file that doesn't contain a part attribute

Journal to find file that doesn't contain a part attribute

Journal to find file that doesn't contain a part attribute

(OP)
Hi,
someone has a journal that scan a folder with NX parts and find parts that doesn't contain a specific attribute ?

Thank you...

Using NX 8 and PDM RuleDesigner

RE: Journal to find file that doesn't contain a part attribute

Are you talking about a specific 'Part' attribute? I could probably write a simple GRIP program to do that, but it would have to wait until after PLM World since I'm still prepping for that and we're still doing the beta testing this week for the next version of NX.

John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:

To an Engineer, the glass is twice as big as it needs to be.

RE: Journal to find file that doesn't contain a part attribute

If you are trying to find a specific attribute try this, replacing 'Your_attribute' with the attribute name you are checking for

Dim theSession As Session = Session.GetSession()
Dim workpart As Part = theSession.Parts.Work
Dim check_string As String
Try
check_string = workpart.GetUserAttribute("Your_attribute", NXObject.AttributeType.String, 0).StringValue
Catch exc As nxexception
'set a boolean=false or whatever action you want if the attribute doesn't exist
End Try

Mark Benson
Aerodynamic Model Designer

To a Designer, the glass was right on CAD.

RE: Journal to find file that doesn't contain a part attribute

i've made this.
if they found some error with number five, they will create the attribute.

CODE --> VB

"on error goto asd"
your code here

asd:
if err.number = 5 then
workPart.SetAttribute("YOUR ATTRIBUTE", "VALUE OF ATTRIBUTE")
resume
else
msgbox(err.number & vbcrlf & err.description, title:="Error")
end if 

CODE --> vb

Option Strict Off
Imports System
Imports NXOpen

Module NXJournal
public nome, pn, user, desc as string

Sub Main
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim printPDFBuilder1 As PrintPDFBuilder
printPDFBuilder1 = workPart.PlotManager.CreatePrintPdfbuilder()
dim msgtxt as string
msgtxt = "PROCESSO - GMP MARCATTO"
call setuser

on error goto asd
'workPart.SetAttribute("UGS_BR_NEW", "0")
if workPart.GetStringAttribute("UGS_BR_NEW") = 0 THEN

nome = inputbox("Programador:", "PROGRAMAÇÃO - GMP MARCATTO", user)
if nome = "" then 
msgbox("Variável Não definida. Rotina encerrada.", title:=msgtxt)
exit sub
end if
pn = inputbox("Part Number:", "PROGRAMAÇÃO - GMP MARCATTO")
if pn = "" then 
msgbox("Variável Não definida. Rotina encerrada.", title:=msgtxt)
exit sub
end if
desc = ucase(inputbox("Descrição do item:", "PROGRAMAÇÃO - GMP MARCATTO"))
if desc = "" then 
msgbox("Variável Não definida. Rotina encerrada.", title:=msgtxt)
exit sub
end if

'DEFINE ATRIBUTOS------------------------------
workPart.SetAttribute("ELABORADO", nome)
workPart.SetAttribute("UGSBR_PROG", nome)
workPart.SetAttribute("UGSBR_DESENHO", pn)
workPart.SetAttribute("PN", pn)
workPart.SetAttribute("NOME", desc)
workPart.SetAttribute("UGSBR_REV", "01")
workPart.SetAttribute("UGS_BR_NEW", "1")

'MSG SUCESSO -----------------------------------
msgbox("Cadastro realizado com sucesso." & vbcrlf & _ 
"Programador: " & workPart.GetStringAttribute("ELABORADO") & VBCRLF & _
"PN: " & workPart.GetStringAttribute("PN"), title:=msgtxt)

ELSE
msgbox("Cadastro já foi realizado." & vbcrlf & "Caso queira executar novamente, mude a propriedade ""UGS_BR_NEW"" para ""0"" e execute a ferramenta novamente.", title:=msgtxt)
end if

exit sub

asd:
if err.number = 5 then
workPart.SetAttribute("UGS_BR_NEW", "0")
resume
else
msgbox(err.number & vbcrlf & err.description, title:="Erro")
end if
End Sub 

RE: Journal to find file that doesn't contain a part attribute

extending the question,
can I read attribute from a file without opening the partfile.
Workpart will have an open file, I just like to know if and what attributes exist.

sorry new in NX
regards
Erwin

RE: Journal to find file that doesn't contain a part attribute

(OP)
Sorry gmanucci, but your code is not what I asked.

Thank you...

Using NX 8 and PDM RuleDesigner

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