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 ?
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
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
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
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 ifCODE --> 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 SubRE: Journal to find file that doesn't contain a part attribute
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
Thank you...
Using NX 8 and PDM RuleDesigner