I have a script that I have the math.ceil() instruction working in yet I cannot get math.floor() to work. Does anyone know why? Using a label with the expression I was able to use just floor to get the values I want but when I go to do it in the python script, I am only getting a float value.
def runAction(self):
import math
if self.view.custom.PB < 1:
if temp1 == 0:
i = len(self.props.instances)
while i < math.ceil(self.view.custom.INV * self.view.custom.PB):
instance = {
"INV": int(i+1),
}
self.props.instances.append(instance)
i += 1
elif temp1 > 0:
i = math.floor((self.view.custom.INV*self.view.params.PB)-self.view.custom.INV)
instance = {
"INV" : int(i+1)
}
self.props.instances.append(instance)
What error are you getting? Try adding some logging to print to the log the values the floor function is being passed to see if maybe there's an issue somewhere.
Can you post the data you've got and what result you want. There's probably a simpler way to do it. I think you said before that you're new to Python. (I'm no guru but sometimes I can make things work!)
Then I would say go back and log values and data types as I suspect somewhere a value is being passed as a string instead of a float or integer and causing it all to break. I've seen it happen before.
I have other code that I did not include to avoid further confusion, I know all of that works. The definitions were all included in that chunk of data. I just swapped out the tags for actual values and found out it was the string issue. Everything is now working as expected.