How can I correctly write this simple line of code?

How can I correctly write this simple line of code?

chris
Advisor Advisor
828 Views
8 Replies
Message 1 of 9

How can I correctly write this simple line of code?

chris
Advisor
Advisor

I have a line of code that uses some user-defined parameters to create the stock number, however, one of them is an "angle" that is giving me a 'double" error in the code. Is there a way to convert the dimension parameter to just regular text without the unit string and that will also convert the dimension up or down to the nearest degree?

 

iProperties.Value("Project", "Stock Number") = Cat + PSize + P_Ang + Weld + SCH + Mat1

 

chris_1-1722542398333.pngchris_2-1722542414512.png

 

 

0 Likes
Accepted solutions (1)
829 Views
8 Replies
Replies (8)
Message 2 of 9

Curtis_Waguespack
Consultant
Consultant

@chris I think it is just trying to sum the values because you are using the plus sign to concatenate, try using & instead

 

post back if that's not the issue ( I didn't test it) 

iProperties.Value("Project", "Stock Number") = Cat & P_Ang & Weld & SCH & Mat1

 

EESignature

0 Likes
Message 3 of 9

chris
Advisor
Advisor

@Curtis_Waguespack yep that worked... duh, I'm a dork, thanks for making that public knowledge, LOL

Message 4 of 9

Curtis_Waguespack
Consultant
Consultant

@chris wrote:

@Curtis_Waguespack yep that worked... duh, I'm a dork, thanks for making that public knowledge, LOL


 

lol, well to be fair I've probably done that same exact thing a dozen times.

 

you know how it goes, it impossible to see that stuff when it's your code, but it jumps right out if it's someone else's

 

Curtis_Waguespack_0-1722547152349.png

 

EESignature

0 Likes
Message 5 of 9

chris
Advisor
Advisor

Agreed!

0 Likes
Message 6 of 9

chris
Advisor
Advisor

@Curtis_Waguespack How can I format this parameter to show up in iLogic as the formatting example shows (with no zero in front of the decimal). The reason I am trying to format it this way is because this is how this particular company formats this "stock number". When I concatenate with iLogic, it for some reason adds the zero?

 

Also, how can I get the thickness dim to show up as a 1/16 precision inch fraction in the description?

chris_1-1722577644338.png

 

 

chris_0-1722577515664.png

 

0 Likes
Message 7 of 9

AndrewHumiston
Advocate
Advocate
Chris,

You could try using a split function with a "." as the delineator and then drop the first value if its a zero.

oNewString = Split(Thk,".")
oNewValue = oNewString(ubound(oNewString))

something like that.
Message 8 of 9

Curtis_Waguespack
Consultant
Consultant
Accepted solution

@chris, in addition to AndrewHumiston's suggestion you could pull from the custom iproperty rather than the parameter.

 

When we set the Custom Property Format for a parameter, we're doing all of that in the parameter editor, but it formats the resulting custom iproperty, not the parameter.

Curtis_Waguespack_0-1722605258007.png Curtis_Waguespack_1-1722605280232.png

 

So using something like the example below should pull it in as formatted without the leading zero.

 

ThkProp = iProperties.Value("Custom", "Thk")

iProperties.Value("Project", "Stock Number") = Cat & ThkProp & Weld & SCH & Mat1

 

EESignature

0 Likes
Message 9 of 9

chris
Advisor
Advisor

@Curtis_Waguespack As always, that worked perfect! 

chris_0-1722609721122.png