Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Assign Part Name To Attributes Using Grip 1

Status
Not open for further replies.

lsl49

Mechanical
Sep 26, 2004
33
What is the code for GRIP to recognize a part name and assign it to the part attributes. The file name is GE81001234.prt. I want the attributes to read Title = Part Name and the Value = 81001234 with no "GE" attached.

Larry Leonard
Designer

Smith-Nephew Orthopaedics
 
Replies continue below

Recommended for you


assatt/part,'PARTNAME',substr(&partname,3,10)

It's all spelled out in the GRIP manuals.



"Wildfires are dangerous, hard to control, and economically catastrophic."
"Fixed in the next release" should replace "Product First" as the PTC slogan.

Ben Loosli
CAD/CAM System Analyst
Ingersoll-Rand
 
Thanks Ben,
Have not been able to put my hands on the GRIP manuals.
I have been looking to get assistance from our support people but decided to go on my own.
Trying to pick up as much as I can from the HELP files.
If you can help me further I would greatly appreciate it.


Larry Leonard
Designer

Smith-Nephew Orthopaedics
 
Just ask away. Been doing GRIP for 18 years.


"Wildfires are dangerous, hard to control, and economically catastrophic."
"Fixed in the next release" should replace "Product First" as the PTC slogan.

Ben Loosli
CAD/CAM System Analyst
Ingersoll-Rand
 
Here is what the completed program would look like:

ASATT/PART,'PartName',SUBSTR(&PNAME,3,10)
HALT

Ben is right in that the help files are a good place to get this from, but sometimes you need a nudge in the right direction. Since this is such a short program I'll explain what is going on.
ASATT/ - this is the key word used to assign attributes
PART - minor word that tells it to assign the attribute to the part rather than an individual entity
'PartName' - this will be the title of your attribute
SUBSTR(&PNAME,3,10) - this will be the value of your attribute, it has 2 parts so let's break it down further
&PNAME - this grip statement will return the current part name, in our case it would be GE81001234.prt
SUBSTR - this is the keyword to extract part of a string. The syntax is SUBSTR('string',<start>,<end>)
So, SUBSTR(&PNAME,3,10) tells it to extract characters 3-10 of the part name (in this case 81001234).

SUBSTR(&PNAME,3,10) will work as long as there are always 2 characters at the beginning that you don't need and you always want the next 8 characters. If the part name lengths are variable then the grip program gets more complicated.
 
1 - How hard would it be to have this happen automatically when a part is created in UG?
2 - How hard would it be to have the TITLE: DESCRIPTION filled in automatically and then have a screen ask for a user entry for the VALUE:__________. (Just less trying for the user)

Larry Leonard
Designer

Smith-Nephew Orthopaedics
 
You have to execute the GRIP program to get iot to do anything. The only way to do it transparently is to use a user exit at file create or file save. Our users haven't seen a standard UG File-Open/Save/Create/SaveAs menu since before I came here 11 years ago. The File-XXXX commands have all been replaced by custom GRIP programs that add the attributes to the part file and check them at save time.

You could do it with a macro/NX3 journal.

GRIP can also ask for a value and then assign the attribute.


"Wildfires are dangerous, hard to control, and economically catastrophic."
"Fixed in the next release" should replace "Product First" as the PTC slogan.

Ben Loosli
CAD/CAM System Analyst
Ingersoll-Rand
 
No problem on the execution.

How do I combine the code:

assatt/part,'P/N',substr(&partname,3,10)
Title: P/N Value: 81001234

popup on the screen will ask the user to input info
Title: DESCRIPTION Value: user input.

Title: MATERIAL Value: ALUMINUM

Title: FINISH Value: ANODIZE

Larry Leonard
Designer

Smith-Nephew Orthopaedics
 
All documentation for UG comes on a CD.

Text/'Enter Value:',valvar1
assatt/part,'title',valvar1

It can get a lot more complicated with error trapping and good value checks.



"Wildfires are dangerous, hard to control, and economically catastrophic."
"Fixed in the next release" should replace "Product First" as the PTC slogan.

Ben Loosli
CAD/CAM System Analyst
Ingersoll-Rand
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor