Setup sheets: add calculations

Setup sheets: add calculations

Daniel.Reister
Enthusiast Enthusiast
1,305 Views
10 Replies
Message 1 of 11

Setup sheets: add calculations

Daniel.Reister
Enthusiast
Enthusiast

Hi I work commonly with Powermill macros, but not as much with the setup sheet side of things in powermill. I was wondering if there is a way that I could take two parameters that can be used in setup sheets and do some math with them and display the results of that math in the setup sheet. Does anyone know if there is a way to do that? To help explain what I am wanting to do here is an example of two values I want to displayed after they are added together.

 

I want this value...

${Block.Limits.ZLength}

 

Added to this value...

${height_above_model}

 

I then want the result of that displayed on the setup sheet.

 

Thanks,

Daniel

0 Likes
Accepted solutions (1)
1,306 Views
10 Replies
Replies (10)
Message 2 of 11

icse
Advisor
Advisor

try to write it like this:

${Block.Limits.ZLength + height_above_model}
0 Likes
Message 3 of 11

Daniel.Reister
Enthusiast
Enthusiast

I tried it out this morning, and it does not work. Not sure if HTML is capable of doing math. It is like it just adds the two strings together so it takes the value of the first part of the expression and puts it next to the value from the second part of the expression. 

So if...

${Block.Limits.ZLength} = 2.1

and

${height_above_model} = .03

It displays

2.10.03

If it is not possible to do the math in the HTML for the setup sheet is it possible to do the math somewhere else and pass it into the setup sheet?

 

 

0 Likes
Message 4 of 11

icse
Advisor
Advisor

did you tryed to pot it in the same {}?

 

like this:

 

 

${Block.Limits.ZLength + height_above_model}

 

 

 

NOT this:

 

 

${Block.Limits.ZLength} + {height_above_model}

 

 

 

0 Likes
Message 5 of 11

Daniel.Reister
Enthusiast
Enthusiast

I have attempted these different approaches and few others and everything returns simply as different combinations of the string but never with the values calculated together.

0 Likes
Message 6 of 11

icse
Advisor
Advisor

thats odd... for me it seems to work just fine

0 Likes
Message 7 of 11

Daniel.Reister
Enthusiast
Enthusiast

Could you send me a snapshot of what it produces on your setup sheet?

0 Likes
Message 8 of 11

icse
Advisor
Advisor

Youre right... for testing i used an int value that seems to work fine

 

anyway i have another solution attempt for you:

 

 

 

<table>								
		<tr id="result">${height_above_model}|${Block.Limits.ZLength}</tr>

		<script>
			var element = document.getElementById("result");
			var nums = element.innerText.split('|'); 
			element.innerText = parseFloat(nums[0].replace(',','.')) + parseFloat(nums[1].replace(',','.'))
		</script>
</table>

 

 

 

 

Here i write both values splited by '|', then i use JavaSkript to split and parse them,

and finially i write em back.

 

Ugly but it seems to work.

0 Likes
Message 9 of 11

Daniel.Reister
Enthusiast
Enthusiast

That does it. Thanks for your help. I was wondering if it would require some javaskript. I have not done any work with Java so this is a helpful start.

0 Likes
Message 10 of 11

a_bako
Enthusiast
Enthusiast
Accepted solution

Try this on setupsheet page:

${real(Block.Limits.ZLength) + real(height_above_model)}

Message 11 of 11

Daniel.Reister
Enthusiast
Enthusiast

This solution also works and is simple to implement. Thanks for the help.

0 Likes