mirror of
https://github.com/justUmen/Bjornulf_custom_nodes.git
synced 2026-03-21 20:52:11 -03:00
0.65
This commit is contained in:
28
anything_to_float.py
Normal file
28
anything_to_float.py
Normal file
@@ -0,0 +1,28 @@
|
||||
class Everything(str):
|
||||
def __ne__(self, __value: object) -> bool:
|
||||
return False
|
||||
|
||||
class AnythingToFloat:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {
|
||||
"required": {
|
||||
"anything": (Everything("*"), {"forceInput": True}),
|
||||
},
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def VALIDATE_INPUTS(s, input_types):
|
||||
return True
|
||||
|
||||
RETURN_TYPES = ("FLOAT",)
|
||||
RETURN_NAMES = ("float",)
|
||||
FUNCTION = "any_to_float"
|
||||
CATEGORY = "Bjornulf"
|
||||
|
||||
def any_to_float(self, anything):
|
||||
try:
|
||||
return (float(anything),)
|
||||
except (ValueError, TypeError):
|
||||
# Return 0.0 if conversion fails
|
||||
return (0.0,)
|
||||
Reference in New Issue
Block a user