Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

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

Status
Not open for further replies.

cubalibre000

Mechanical
Jan 27, 2006
1,070
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
 
Replies continue below

Recommended for you

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.
 
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.
 
i've made this.
if they found some error with number five, they will create the attribute.

Code:
"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:
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
 
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
 
Sorry gmanucci, but your code is not what I asked.

Thank you...

Using NX 8 and PDM RuleDesigner
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor