cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

how to add custom parameters to BOM (global), truncate Part name

aburger
1-Newbie

how to add custom parameters to BOM (global), truncate Part name

Hi,

I've started to work with automatic BOMs and I'm struggling to list part name and part number.

our components are named as follows:

P00XXXX_PartName

Now, by adding the following relation in the assembly drawing (repeat region, relations):

Part_number = EXTRACT(asm_mbr_name,1,7)

I was able to add Part_number under a part number column to just get the P00XXXX portion (rpt > rel.. > user defined)

I then added 2 more relations:

actual_length = STRING_LENGTH(asm_mbr_name)

Part_name = EXTRACT(asm_mbr_name,8,actual_length)

and then tried to add Part_name to a part name column (rpt > rel.. > user defined) but that then everything disappears in the table.

Also, this just seems to add it locally, to the current drawing. how can I add relations/parameters that can be used in all drawings etc?

Any hints are greatly appreciated.

Thanks,

Andreas


This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
6 REPLIES 6
Chris3
21-Topaz I
(To:aburger)

This happens because some of your parts have numbers that are shorter than 7 or 8 characters.

For:

Part_name = EXTRACT(asm_mbr_name,8,actual_length)

If the number of characters is less than 8 it returns a NULL in the code (there is no visual warning for this) and it just stops running, screwing up your results.

To correct for this, you first need to test the number of characters:

if string_length(asm_mbr_name)>7

Part_name = EXTRACT(asm_mbr_name,8,actual_length)

else

Part_name = asm_mbr_name

endif

Andreas,

just couple of notes ...

1.) length argument in extract(string, position, length)

---

relation for 1st part of the name is:

name1=extract("P00XXXX_PartName", 1, 7)

/* name1="P00XXXX"

---

relation for 2nd part of the name is:

length2=string_length("P00XXXX_PartName")-8

name2=extract("P00XXXX_PartName", 9, length2)

/* name2="PartName"

2.) you can define your relations in model and call them in repeat region in the drawing.

Martin Hanak


Martin Hanák

If you always use an underscore in your part number, you could parse for that

/*****REPLACE OR REMOVE UNDERSCORE*****
/* ASSIGN THE MODEL NAME TO A PARAMETER
old_name = asm_mbr_name

/* ASSIGN THE LENGTH OF THE STRING TO A PARAMETER
len = STRING_LENGTH(OLD_NAME)

/* SEARCH FOR THE FIRST UNDERSCORE AND ASSIGN ITS POSITION TO PARAMETER
pos = SEARCH(OLD_NAME, '_')

/* SEARCH() RETURNS ZERO IF NOTHING FOUND SO...
IF pos > 0
  /* EXTRACT THE ORIGINAL NAME UP TO THE UNDERSCORE
  Part_number = EXTRACT(old_name, 1, POS-1)
  /* EXTRACT THE REMAINING STRING
  rem = EXTRACT(old_name, pos+1, len-pos)
  /* ADD THE DECIMAL POINT AND THE REMAINING STRING
  /*Part_number = Part_number + '.' + rem
ENDIF

/* SINCE WE CANNOT WRITE ANY LOOP STATEMENTS
/* REPEAT THE CODE BELOW FOR THE MAX NUMBER
/* OF UNDERSCORES AS IS NECESSARY.
/* THE IF STATEMENT PREVENTS UNECESSARY
/* NUMBER CRUNCHING
/* EX: ABC_DEF_GHI_JKL HAS 3 UNDERSCORES
/* THE SECTION BELOW NEEDS TO EXIST TWICE

old_name = Part_number
pos = SEARCH(old_name, '_')
IF pos > 0
  Part_number = EXTRACT(old_name, 1, pos-1)
  rem = EXTRACT(old_name, pos+1, len-pos)
  Part_number = Part_number + '.' + rem
ENDIF

This way you don't have to concern yourself with the part number length.

(I tweeked mine to fit yours, hope I got it all)

Ron

HI thanks everyone!

very helpful.  So if I have to define these relations at the part level?

And do it for each part? 

There isn't a way to define this globally (just like the native Creo parameters such as asm_mbr_name).
So if I go into repeat regions, I always have it available, without having to redefine it each time?

Thanks!

Andreas

These are at the assembly.

You can create a bom table with the defaults you have established to a file

you can then insert the table from this file location each time you wish to have a drawing with an assembly bom.

You could even go as far as having a drawing format specifically for assemblies with a bom.

The list of different possibilities and scenarios is only limited to ones imagination.

ron

You do not have to do them in the part or the assembly. You can do them in the repeat region.

Table-> Repeat Region -> Relations

Top Tags