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

Repeat regions and dimensions

lockarde
7-Bedrock

Repeat regions and dimensions

Hello, 

I'm running into some issues trying to pull part dims into a repeat region. I'm working towards having as much info automatically pulled into the to remove any user error from manually typing information and dimensions. 

 

When I click into the repeat region and select asm->mbr->D1, it correctly pulls that info. The same is true for D2.

I wrote the following relation (with some help from other posts regarding real numbers to string conversion) to put these dims into a string so it shows "Length X Width":

 

 

IF ASM_MBR_D1 > ASM_MBR_D2
	LENGTH = ASM_MBR_D1
	WIDTH = ASM_MBR_D2
IF ASM_MBR_D1 < ASM_MBR_D2
	LENGTH = ASM_MBR_D2
	WIDTH = ASM_MBR_D1
ENDIF
ENDIF

/* CONVERT LENGTH REAL NUMBER TO STRING WITH 2 DECIMALS
LENGTH_STR = ITOS(FLOOR(LENGTH+.0005))+"."+\
	EXTRACT(ITOS(((FLOOR((LENGTH+.0005),2))\
	-FLOOR(FLOOR((LENGTH+.0005),2))+1)*1000),2,2)
WIDTH_STR =ITOS(FLOOR(WIDTH+.0005))+"."+\
	EXTRACT(ITOS(((FLOOR((WIDTH+.0005),2))\
	-FLOOR(FLOOR((WIDTH+.0005),2))+1)*1000),2,2)

/* LIST DIMENSIONS IN ONE STRING
part_dimensions = LENGTH_STR+" X "+WIDTH_STR

 

 

The result is ".00 X .00".  For some reason, I can't get it to grab those D1, D2 dims when I use them in a relation.  Do I need to use the specific part dims sd0, sd1?  If that's the case, can someone help me with syntax, I'm not sure how to call those in a relation. 

 

Any thoughts?  Any and all help is greatly appreciated! I'm pullin my hair out trying to get this to work...

11 REPLIES 11
BenLoosli
23-Emerald II
(To:lockarde)

I would think it would be easier to pull the dimensions and format your description at the part level than mess with repeat region relations.

When you put the object into your assembly and then the drawing, the description will pull into the BOM with no editing of the repeat region.

 

@BenLoosli Thanks for your response!  Can you elaborate a little on this?  I'm very new to Creo (3 mos in) and I don't have a solid handle on how everything is interconnected.  I have columns in my model tree at the part level labeled D1, D2; for now I have manually entered values into these columns, but I believe I can use relations to automate that as well.  I think that's where it was pulling that data from when I add the value to rpt region.  Is this what you're referring to? 

 

Am I over thinking this? Can get this data a much simpler way?

 

So you get an idea of the context - almost all of my parts are extruded rectangles, and I'm trying to get the LxW of these into the table to act as a cut list.  I'm trying to automate this A) because typing the dims manually is time consuming, and B) to avoid any error by mistyping

BenLoosli
23-Emerald II
(To:lockarde)

Overthinking can be as bad as underthinking at times.

You have a bunch of rectangular plates, are you using a family table to create the parts or individual part files?

Either way, you can do a bunch of things with relations and parameters.

When you model the plate, you end up with 3 variable dimensions, length, width and thickness, identified as d1, d2, and d3. These can then be renamed to length, width and thickness for easier manipulation.

Take one of the dimension names and now you have to convert the real number into a string value for use in your note. There is no real to string function in Creo, only integer to string (itos).

 

Multiple methods to do the conversion, but here is one I use.

/** Set the THK Value for the description
THK1F=(floor(THK))
if THK1F==0
THK1S=''
else
THK1S=itos(THK1F)
endif
THK2=((THK-THK1F)*10)
THK2F=floor(THK2)
if THK2F==0
THK2S='0'
else
THK2S=itos(THK2F)
endif
THK3=((THK2-THK2F)*10)
THK3F=floor(THK3)
if THK3F==0
THK3S='0'
else
THK3S=itos(THK3F)
endif
THK4=((THK3-THK3F)*10)
THK4F=floor(THK4)
if THK4F==0
THK4S='0'
else
THK4S=itos(THK4F)
endif
full_thk=thk1s+'.'+thk2s+thk3s+thk4s

full_thk is a 3 decimal place string. You can play with the digits. 

If I have THK = 23.457, then full_thk would be 23.457, but a string so I could do this:

Description3 = 'PART THICKNESS = '+full_thk.

 

Doing this in the part file allows you to create a BOM table that uses Description1, Description2 and Description3 as parameters in a single cell or 3 columns, depending on your format requirements.

 

The PTC Creo Help has a whole chapter on relations that is very useful. They are different from the repeat region relations, but somewhat similar. 

 

I would always drive dimensioning format information from the individual pieces and not try to calculate and form them at the assembly drawing level.

 

Thanks again @BenLoosli for your response and helping me through this - it's greatly appreciated.  I'm going to read through the help, I've also found some lectures on PTC university on relations and parameters.  (I probably should have gone there first, but I hoped there would be a quick syntax answer!). Once I get it dialed in, I'll come back and post my solution in case others have the same question/issue.

 

Your solution on string concatenation is much more straightforward than what I have, thanks for posting that!

 

 

I know you've gotten a lot of good help already but I figured I'd add on. Take a look at this post. It's similar to what you're trying to do. The decimal display can be controlled in the repeat region after the parameters are displayed. 

 

https://community.ptc.com/t5/3D-Part-Assembly-Design/PARMETERS-MAXIMUM-DIMENSIONS/m-p/719344#M118929 

 

Ty

Thanks @Tdaugherty! I'll see how I could apply that to my situation.  If nothing else, I like how you use the MAX and MIN functions to determine which dimension is length width and height.  I'm still toying around, but I successfully got it to display two of my dims (thickness is an easy add on) with the following relations I added to each part:

 

IF d1>d2 
	LENTH = d1 
	WIDTH = d2 
ENDIF 
IF d1<d2 
	LENGTH = d2
	WIDTH = d1 
ENDIF 
len_rem = LENGTH-FLOOR(LENGTH)
len_rem_frac = itos(floor(len_rem*64))+"/64"
IF MOD(FLOOR(len_rem*64),2)<1
	len_rem_frac=itos(floor(len_rem*32))+"/32"
		IF MOD(FLOOR(len_rem*32),2)<1
			len_rem_frac=itos(floor(len_rem*16))+"/16"
				IF MOD(FLOOR(len_rem*16),2)<1
					len_rem_frac=itos(floor(len_rem*8))+"/8"
						IF MOD (FLOOR(len_rem*8),2)<1
							len_rem_frac=itos(floor(len_rem*4))+"/4"
								IF MOD(FLOOR(len_rem*4),2)<1
									len_rem_frac=itos(floor(len_rem*2))+"/2"
								ENDIF
						ENDIF
				ENDIF
		ENDIF
ENDIF
len_dim = itos(floor(LENGTH)) +"-"+len_rem_frac
wid_rem = WIDTH-FLOOR(WIDTH)
wid_rem_frac = itos(floor(wid_rem*64))+"/64"
IF MOD(FLOOR(wid_rem*64),2)<1
   wid_rem_frac=itos(floor(wid_rem*32))+"/32"
      IF MOD(FLOOR(wid_rem*32),2)<1
         wid_rem_frac=itos(floor(wid_rem*16))+"/16"
            IF MOD(FLOOR(wid_rem*16),2)<1
               wid_rem_frac=itos(floor(wid_rem*8))+"/8"
                  IF MOD (FLOOR(wid_rem*8),2)<1
                     wid_rem_frac=itos(floor(wid_rem*4))+"/4"
                        IF MOD(FLOOR(wid_rem*4),2)<1
                           wid_rem_frac=itos(floor(wid_rem*2))+"/2"
                        ENDIF
                  ENDIF
            ENDIF
      ENDIF
ENDIF
wid_dim = itos(floor(WIDTH)) +"-"+wid_rem_frac
DIMENSIONS = len_dim+" X "+wid_dim

 

 

It's probably not as efficient as it could be, so I'll work on getting it dialed in.  This displays my parts dims in the format "20-1/2 X 3-3/8"  in a repeat region by calling out asm->mbr->DIMENSIONS. The nested IF statements apply the correct fraction denominator, thanks @KenFarley for that bit! Thanks again to @BenLoosli and @Tdaugherty for all of your help!

 

One final question - is it possible to have relations embedded in part templates?  That would be the ideal way to go, so I don't have to add them to each new part, it'd be there automatically when I create a new one.

BenLoosli
23-Emerald II
(To:lockarde)

Yes, you can put relations and parameters into your start part templates.

With relations, you need to be careful of your naming, but if you have a dedicated template for rectangular plates, you shouldn't have any issues.

 

TomU
23-Emerald IV
(To:lockarde)

You need to add an equals sign or an ELSE to one of your first two IF statements or you won't properly set LENGTH and WIDTH when the two values are equal to each other.

IF d1>d2 
	LENTH = d1 
	WIDTH = d2 
ELSE
	LENGTH = d2
	WIDTH = d1 
ENDIF

or

IF d1>=d2 
	LENTH = d1 
	WIDTH = d2 
ENDIF 
IF d1<d2 
	LENGTH = d2
	WIDTH = d1 
ENDIF

 

lockarde
7-Bedrock
(To:TomU)

Thank you @TomU !  Nice catch, I'll add that in pronto!

I realized my code doesn't account for whole numbers, below is corrected code for any that need it:

 

IF d1>=d2 
	LENTH = d1 
	WIDTH = d2 
ENDIF 
IF d1<d2 
	LENGTH = d2
	WIDTH = d1 
ENDIF 
len_rem = LENGTH-FLOOR(LENGTH)
len_rem_frac = itos(floor(len_rem*64))+"/64"
IF MOD(FLOOR(len_rem*64),2)<1
	len_rem_frac=itos(floor(len_rem*32))+"/32"
		IF MOD(FLOOR(len_rem*32),2)<1
			len_rem_frac=itos(floor(len_rem*16))+"/16"
				IF MOD(FLOOR(len_rem*16),2)<1
					len_rem_frac=itos(floor(len_rem*8))+"/8"
						IF MOD (FLOOR(len_rem*8),2)<1
							len_rem_frac=itos(floor(len_rem*4))+"/4"
								IF MOD(FLOOR(len_rem*4),2)<1
									len_rem_frac=itos(floor(len_rem*2))+"/2"
								ENDIF
						ENDIF
				ENDIF
		ENDIF
ENDIF

IF FLOOR(LENGTH) == LENGTH
	len_dim = itos(LENGTH)
ELSE
	len_dim = itos(floor(LENGTH)) +"-"+len_rem_frac
ENDIF

wid_rem = WIDTH-FLOOR(WIDTH)
wid_rem_frac = itos(floor(wid_rem*64))+"/64"
IF MOD(FLOOR(wid_rem*64),2)<1
   wid_rem_frac=itos(floor(wid_rem*32))+"/32"
      IF MOD(FLOOR(wid_rem*32),2)<1
         wid_rem_frac=itos(floor(wid_rem*16))+"/16"
            IF MOD(FLOOR(wid_rem*16),2)<1
               wid_rem_frac=itos(floor(wid_rem*8))+"/8"
                  IF MOD (FLOOR(wid_rem*8),2)<1
                     wid_rem_frac=itos(floor(wid_rem*4))+"/4"
                        IF MOD(FLOOR(wid_rem*4),2)<1
                           wid_rem_frac=itos(floor(wid_rem*2))+"/2"
                        ENDIF
                  ENDIF
            ENDIF
      ENDIF
ENDIF
IF FLOOR(WIDTH) == WIDTH
	wid_dim = itos(WIDTH)
ELSE
	wid_dim = itos(floor(WIDTH)) +"-"+wid_rem_frac
ENDIF
DIMENSIONS = len_dim+" X "+wid_dim

 

I am late to this discussion and it seems like you have a solution that will work for you.

 

Still, I would like to offer an alternative to this "description string building" relations logic.

The method is based on using note type parameters.

 

In my opinion, most of the time it is easier to build such descriptive strings using part notes, because dimensions and parameters can be "recalled" in them using the syntax &dimension_id or &param_name[.X]

Also, you can have your dimensions (lets say you called them length and width) defined to be "fractional" in nature.

 

So you build a part note which says something like this:

pausob_0-1619163423560.png

 

 

You can then define a part parameter of type "Note", which value will be the above note's id # (3 in this example)

Lets say this note parameter was called "DESC_NOTE"

 

 

Then you simply call out this note-parameter in the repeat region

(&asm.mbr.desc_note ...) and it will show the note - in its original formatting - in your drawing's table.

Top Tags