Continue to Site

Welcome to MCAD Central

Join our MCAD Central community forums, the largest resource for MCAD (Mechanical Computer-Aided Design) professionals, including files, forums, jobs, articles, calendar, and more.

using text in relations

tomh

New member
I have a flat piece of steel. It has a C, B, and a L dimension. I would like to create a relation that lists all of these dimensions in its value.



So the parameter name would be MATERIAL_DESC and its type would be a string.



In the relations area I am entering:

MATERIAL_DESC=C+ x +B+ x +L+ +MATERIAL_TYPE

so that in the value area it will read:

.500 x 2.000 x 12.000 FLAT, HOT ROLLED, A-36



I keep getting an error message though and I think it has to go with the text in the quotes. Can anyone help?



Thanks

Tom
 
You need to convert C, B, and a L dimension values into text first.



C1 = ITOS(C)

B1 = ITOS(B)

L1 = ITOS(L)

MATERIAL_DESC=C1+ x +B1++ +L1+ +MATERIAL_TYPE



Charles
 
That's the ticket Charles, thank you. But, it's converting the dimension values to whole numbers (no decimal places), also the dimensions that are fractional are rounded up.



Any ideas?



Thanks

Tom
 
Yes, there is a way. Of course it gets a little long and complicated.



Following is for C (C1) dim.

X2 = C

Y2 = FLOOR(X2)

Z2 = (X2-Y2)*100

IF Z2 == 0

C1 = ITOS(Y2) + .00

ELSE

C1 = ITOS(Y2) + . + ITOS(Z2)

ENDIF



You can assign any variable for temporary variables 'X2', 'Y2', & 'Z2'.



Good luck,

Charles
 
BTW, I never tried it with fractions and can't think of a way to do it.



I'll try some and post it if I find a way.



Charles
 
Tom,

Here is a way to show fraction for C dimension.





denom_base=8

A2=C

B2=floor(A2)

C2=(A2-B2)*denom_base



if (C2==0)

C1=(itos(floor(B2)))

else

if (((C2/4)-floor(C2/4))==0)

if B2 > 0

C1=(itos(floor(B2))) + - + (itos(floor(C2/4))) + /2

else

C1=(itos(floor(B2))) + (itos(floor(C2/4))) + /2

endif

else

if (((C2/2)-floor(C2/2))==0)

if B2 > 0

C1= (itos(floor(B2))) + - + (itos(floor(C2/2))) + /4

else

C1= (itos(floor(B2))) + (itos(floor(C2/2))) + /4

endif

else

if B2 > 0

C1=(itos(floor(B2))) + - + (itos(floor(C2))) + /8

else

C1=(itos(floor(B2))) + (itos(floor(C2))) + /8

endif

endif

endif

endif



Good luck,

Charles
 
Alright Charles, one last question. After all is said and done the converted dimensions (with a decimal value other than 0) that show up in the MATERIAL_DESC value box only have 2 decimal places (.00). How can I change this to show 4 decimal places (.0000).



Thank you for all your info.



Tom
 
Juse change '100' to '10000' & '.00' to '.0000'



Following is for C (C1) dim.

X2 = C

Y2 = FLOOR(X2)

Z2 = (X2-Y2)*10000

IF Z2 == 0

C1 = ITOS(Y2) + .0000

ELSE

C1 = ITOS(Y2) + . + ITOS(Z2)

ENDIF



Charles
 
It is better tu put all you need in a single note as


&C x&B x&L &MATERIAL_TYPE...


then you can use it by a parameter (as note) that point to the note id


so you can give a lot of parameter via a single parameter (note)


If you want also control the numper of digits you can add [.0] to the parameters as


&C[.0] x&B[.2]





Bye
 

Sponsor

Articles From 3DCAD World

Back
Top