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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Relation in Drawing

manjunathrv
17-Peridot

Relation in Drawing

My requirement is something like below in the drawing:

 

IF PTC_WM_LIFECYCLE_STATE == "Prototype Released"

PART_NUMBER = PART_NUMBER "X"

ENDIF

 

Ex: If state = Prototype Released then Part number is 12345678X

Else 12345678

 

Iam not able to make this work.

Is this possible? Anybody to help me?

ACCEPTED SOLUTION

Accepted Solutions
BenLoosli
23-Emerald II
(To:manjunathrv)

Every regen recalculates the relations, so the extra 'X' will get added.

Try this syntax:

IF PTC_WM_LIFECYCLE_STATE == "Prototype Released"

New_part_number = Part_number +'X'

else

new_part_number = Part_number

endif

View solution in original post

7 REPLIES 7

Now I tried the below:

IF PTC_WM_LIFECYCLE_STATE == "Prototype Released"

PART_NUMBER = PART_NUMBER + "X"

ENDIF

Now the funny thing is every time the drawing or model regenerates it adds one X at the end of part number.

Now my part number looks like 12345678XXXXXXXXXXXXX

mender
12-Amethyst
(To:manjunathrv)

Perhaps try 'if it is prototype released, and the part number does not end in X, then add X'?  As I recall, you use string length and extract to check 'ends in X'

The problem is Iam not able to build a working syntax....

How do I use string length in relations?

mender
12-Amethyst
(To:manjunathrv)

Ben's approach will also remove the X if the state is no longer prototype released.  If this is desired, use that.  If you want to flag but not unflag, I had originally been suggesting

if (extract(part_number, string_length(part_number), 1) != "X")

but looking at the dialog to find the precise syntax, I noticed

if (string_ends(part_number, "X"))

which is easier to read.

The part number should have X only for Proto state. for rest of the state its just the part number.

I will try your suggestion too.

Thank You.

BenLoosli
23-Emerald II
(To:manjunathrv)

Every regen recalculates the relations, so the extra 'X' will get added.

Try this syntax:

IF PTC_WM_LIFECYCLE_STATE == "Prototype Released"

New_part_number = Part_number +'X'

else

new_part_number = Part_number

endif

Thanks Ben. You got it.

I just changed this to :

IF PTC_WM_LIFECYCLE_STATE == "Prototype Released"

part_number = New_part_number +'X'

else

part_number = New_part_number

endif

This works for me.

Thanks for your time.

Announcements
NEW Creo+ Topics: Real-time Collaboration


Top Tags