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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

EXTRACTING A PART DESCRIPTION "PREFIX" TO USE IN A REPEAT REGION RELATION

ninehundro
7-Bedrock

EXTRACTING A PART DESCRIPTION "PREFIX" TO USE IN A REPEAT REGION RELATION

I want to automatically set all components in an assembly named with a certain prefix to "REF" for QTY on a drawing BOM.

 

In the drawing BOM repeat region, is there a way to extract the first part of a part's DESCRIPTION parameter value and use it to change its entry in the QTY column?

 

Here is the PTC command line I am using to extract: extract(stringpositionlength)

 

For example:
If param = abcdef, then parameter new will be set to equal bcd by this line: new = extract(param,2,3)

 

Here are the code I am using currently, it doesn't give an error, but it doesn't change the QTY column to "REF" like I need it to:

QTY1=rpt_qty
MEM_PRE=extract(asm_mbr_description,1,4)
IF MEM_PRE=="mem-"
QTY1="REF"
ELSE
QTY1=rpt_qty

ENDIF

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions

Ben,

 

I got it to work.  I deleted all the existing LOCAL PARAMETERS and relations and started over, making sure to verify the relations for errors as they were added and adding LOCAL PARAMETERS if they didn't add automatically below the Relations window.  Here is the code:

 

QTY=rpt_qty

PREFIX=extract(asm_mbr_description,1,4)

IF PREFIX=="DOC-"

QTY="REF"

ENDIF

 

NOTE: DESCRIPTION is a string parameter in parts/models used in this test.

 

-Paul

View solution in original post

3 REPLIES 3
BenLoosli
23-Emerald II
(To:ninehundro)

What is your repeat region Quantity column using for its driving parameter?

Do you have QTY1 defined as a local parameter?

 

Ben, 

 

The repeat region is driven by rpt.rel.QTY1. The DESCRIPTION column is driven by asm.mbr.description.

QTY1 is in the Local Parameters --see attached. Does every parameter used in the relations need to be in the Local Parameters? If so, what is the proper way to add them? I noticed all the Local Parameters that are already there are of type "unknown". 

 

-Paul

Ben,

 

I got it to work.  I deleted all the existing LOCAL PARAMETERS and relations and started over, making sure to verify the relations for errors as they were added and adding LOCAL PARAMETERS if they didn't add automatically below the Relations window.  Here is the code:

 

QTY=rpt_qty

PREFIX=extract(asm_mbr_description,1,4)

IF PREFIX=="DOC-"

QTY="REF"

ENDIF

 

NOTE: DESCRIPTION is a string parameter in parts/models used in this test.

 

-Paul

Top Tags