Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

format and subString functions in NX7.5

Status
Not open for further replies.

IvanNX

Mechanical
Jun 9, 2005
267
hello,

is there any way to use FORMAT function in expressions to extract last two digits in part name (example: part_name_22.prt and i need 22 as result)

or subString function? (i am not sure what this function do anyway)
and when i am in decription of subString function in related functions i have SplitString function, but when i try to find it, there is no such function in my NX, why?
 
Replies continue below

Recommended for you

Hi,
Refer to this thread Truncate an Attribute in a Title Block (thread561-339188).Although it was pointed towards attributes but i guess it might help you too.
Best Regards
Kapil Sharma
 
Thank you kapmnit,

i am bad with coding, so how to edit
Code:
 subString( ug_askPartAttrValue( "[your finish attribute title]" ), 2, 3 )
to refer to part name, and to extract last two digits?
 
Hi,
Kindly find attached an image herewith. I am not sure how can i automate that the part name is extracted directly (rather than manually feeding it).I can do it using KF but that may not suit your case.
Will let you know if i find anything on it.
Best Regards
Kapil Sharma
 
 http://files.engineering.com/getfile.aspx?folder=a62afc59-201d-4442-aebe-61ee77588eae&file=sub_string.jpg
Great!!!

but... i need it to look for name automatically, and i need it to find last two digits on part names that are changing length...
so first i need to get name in name_string expression, then to check how many letters/digits there is in that part name and to put that in name_length expression and then i can use subString(name_string,name_length-1,name_length), this is one approach to this. it is not a problem to have more than one expression to do this, i already have lot of expressions in these parts so few more is not a problem.

it is just that as result i need two digits (XX) that i can compare in other expressions, like: if XX=YY then A=1 else A=2
 
Ivan,
Do you have a KF license with you?
Here is a a dfa code i have written in NX8.0.2 .This will automatically determine your part name..Depending on the value of END (which i take as the number of letters from the last of the part name) it will give you a part attribute with only the last 5 letters of the part name (no matter how big the part name is or chnages to...on save as).
Once a attribute is created you can create an expression taking a reference of the same.
Although i tried creating an automatic expression but this doesn't seem to work in my case (must be something i am missing on expression function)so you will have to craete an expression yourself (if you find some good resource on KF then this will be easy further) and relate it's value to that attribute value.
Best Regards
Kapil Sharma
 
 http://files.engineering.com/getfile.aspx?folder=c8252ac6-740d-4c78-813f-9f8b53664e7c&file=trunc.dfa
Thank you kapmnit, i will try this!

i am just not that good with KF, so I have to talk to my coworkers who are better in it than I am :)

Thank you!
 
By the way...i just managed to get one working...this one will automatically create an attribute and an EXPRESSION as well (the expression name will be fin_tst but you can change it in the code.)
I have made the number of letters you require from the last as an input parameter so you can change it while invoking the code.

Here is the final dfa version...it is very to use just give it a try.

Best Regards
Kapil Sharma
 
 http://files.engineering.com/getfile.aspx?folder=a379b08f-2839-4585-8fe4-56f8b4a10196&file=trunc_fin.dfa
Status
Not open for further replies.

Part and Inventory Search

Sponsor