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!

NX Open

Status
Not open for further replies.

vitulin

Automotive
Nov 1, 2007
79
Hi,

I wonder if you could help me with following topics:

Lets assume, that I have a part. I want to create following attributes: designer, date and material

Before these attributes, I want to check, if these attributes have already been created and in case that yes, I want to take the values from them.
And this is the problem. In case, that the attributes are not defined, the journal is not working.

I have tried this:

If workpart.GetStringAttribute("material") is nothing Or workpart.GetStringAttribute("material") = "" Then

but it doesnt work.

the second thing is:

if i want to save as... part, it will save it to ugii directory, but I would like to save it to NX work directory...

Thank you

Vit


 
Replies continue below

Recommended for you

You could try using a "TRY"
this attempts do do something. if it fails it doesn't just "bomb out" of the journal you acn program in an appropriate response.
Generaly the journal will fail if you attempt to get an attribute that doesn't exist so if it fails we assume it doesn't exist. The code below the "Catch" Line is used on an faliure of the try.
it try's to get the attribut3e from "DB_DWG_NO" and apply it to a variable "PrevNo". If getting the attribute fails it juat applies a dummy value (you could replace this with a prompt for the user to enter it here)
There is also a varaible of "Attrer" which I have here so I can tell if there have been any faliures getting any attributes quickly ( this is just 0 for no errors and 1 for errors in my prog)

--------------Code-----------------------

Try
PrevNo = thesession.Parts.Work.GetStringAttribute("DB_DWG_NO")
Catch exc As NXException
PrevNo = "XXXXX-XX"
Attrer = 1
End Try

------------------------------------------

Hope that helps,



Mark Benson
Aerodynamic Model Designer
 
Hi,

I have already used the try command, because I wasnt able to find out anything better. But I dont like it. It seems, that the NX library is missing this option. I tried to find it out in the NX open references, but without success.

But with try, it works.

Vita
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor