Skip to content

Commit

Permalink
fixed a bug with datapath - function calls
Browse files Browse the repository at this point in the history
better error handling
  • Loading branch information
maybites committed Feb 7, 2021
1 parent 68a0a98 commit ce28ea8
Show file tree
Hide file tree
Showing 4 changed files with 241 additions and 120 deletions.
Binary file modified help/TestBed.blend
Binary file not shown.
165 changes: 135 additions & 30 deletions help/TestBed.maxpat
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@
"format" : 6,
"id" : "obj-18",
"maxclass" : "flonum",
"maximum" : 2.0,
"minimum" : 0.0,
"numinlets" : 1,
"numoutlets" : 2,
"outlettype" : [ "", "bang" ],
Expand Down Expand Up @@ -157,7 +155,6 @@
}
,
"patching_rect" : [ 85.0, 94.0, 61.0, 22.0 ],
"presentation_linecount" : 2,
"saved_object_attributes" : {
"description" : "",
"digest" : "",
Expand Down Expand Up @@ -265,7 +262,6 @@
}
,
"patching_rect" : [ 243.0, 94.0, 61.0, 22.0 ],
"presentation_linecount" : 2,
"saved_object_attributes" : {
"description" : "",
"digest" : "",
Expand Down Expand Up @@ -295,7 +291,7 @@
}
,
"classnamespace" : "box",
"rect" : [ 0.0, 26.0, 452.0, 356.0 ],
"rect" : [ 954.0, 105.0, 452.0, 356.0 ],
"bglocked" : 0,
"openinpresentation" : 0,
"default_fontsize" : 12.0,
Expand Down Expand Up @@ -325,6 +321,78 @@
"showontab" : 1,
"assistshowspatchername" : 0,
"boxes" : [ {
"box" : {
"id" : "obj-10",
"linecount" : 4,
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 177.0, 24.0, 263.0, 60.0 ],
"text" : "datapath: bpy.data.objects['{0}'].location[{1}]\nformat: args[0], index-1\nargs[idx]: (index)\nrange: 1, length, 1"
}

}
, {
"box" : {
"id" : "obj-2",
"linecount" : 2,
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 143.0, 286.0, 268.0, 33.0 ],
"text" : "datapath: bpy.ops.screen.frame_jump(end={0})\nformat: 'False' if args[0] == 0 else 'True'"
}

}
, {
"box" : {
"id" : "obj-3",
"maxclass" : "toggle",
"numinlets" : 1,
"numoutlets" : 1,
"outlettype" : [ "int" ],
"parameter_enable" : 0,
"patching_rect" : [ 143.0, 191.0, 24.0, 24.0 ]
}

}
, {
"box" : {
"id" : "obj-5",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 278.0, 198.0, 65.0, 22.0 ],
"text" : "end=False"
}

}
, {
"box" : {
"id" : "obj-4",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 214.0, 198.0, 60.0, 22.0 ],
"text" : "end=True"
}

}
, {
"box" : {
"id" : "obj-6",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 143.0, 246.0, 92.0, 22.0 ],
"text" : "/frame_jump $1"
}

}
, {
"box" : {
"comment" : "",
"id" : "obj-26",
Expand All @@ -333,7 +401,7 @@
"numinlets" : 0,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 63.0, 23.0, 30.0, 30.0 ]
"patching_rect" : [ 21.0, 24.0, 30.0, 30.0 ]
}

}
Expand All @@ -344,7 +412,7 @@
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 63.0, 200.0, 244.0, 22.0 ],
"patching_rect" : [ 21.0, 149.0, 244.0, 22.0 ],
"text" : "/objects/Variable/location/xyz Cube $1 $2 $3"
}

Expand All @@ -358,7 +426,7 @@
"numoutlets" : 2,
"outlettype" : [ "", "bang" ],
"parameter_enable" : 0,
"patching_rect" : [ 162.0, 136.0, 44.0, 22.0 ]
"patching_rect" : [ 120.0, 85.0, 44.0, 22.0 ]
}

}
Expand All @@ -371,7 +439,7 @@
"numoutlets" : 2,
"outlettype" : [ "", "bang" ],
"parameter_enable" : 0,
"patching_rect" : [ 112.5, 136.0, 44.0, 22.0 ]
"patching_rect" : [ 70.5, 85.0, 44.0, 22.0 ]
}

}
Expand All @@ -384,7 +452,7 @@
"numoutlets" : 2,
"outlettype" : [ "", "bang" ],
"parameter_enable" : 0,
"patching_rect" : [ 63.0, 136.0, 44.0, 22.0 ]
"patching_rect" : [ 21.0, 85.0, 44.0, 22.0 ]
}

}
Expand All @@ -395,7 +463,7 @@
"numinlets" : 3,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 63.0, 171.0, 118.0, 22.0 ],
"patching_rect" : [ 21.0, 120.0, 118.0, 22.0 ],
"text" : "pak 0. 0. 0."
}

Expand All @@ -408,7 +476,7 @@
"maxclass" : "outlet",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 63.0, 273.0, 30.0, 30.0 ]
"patching_rect" : [ 21.0, 274.0, 30.0, 30.0 ]
}

}
Expand All @@ -433,6 +501,34 @@
"source" : [ "obj-15", 0 ]
}

}
, {
"patchline" : {
"destination" : [ "obj-6", 0 ],
"source" : [ "obj-3", 0 ]
}

}
, {
"patchline" : {
"destination" : [ "obj-6", 0 ],
"source" : [ "obj-4", 0 ]
}

}
, {
"patchline" : {
"destination" : [ "obj-6", 0 ],
"source" : [ "obj-5", 0 ]
}

}
, {
"patchline" : {
"destination" : [ "obj-1", 0 ],
"source" : [ "obj-6", 0 ]
}

}
, {
"patchline" : {
Expand Down Expand Up @@ -481,7 +577,7 @@
}
,
"classnamespace" : "box",
"rect" : [ 954.0, 105.0, 452.0, 356.0 ],
"rect" : [ 0.0, 26.0, 452.0, 356.0 ],
"bglocked" : 0,
"openinpresentation" : 0,
"default_fontsize" : 12.0,
Expand Down Expand Up @@ -511,15 +607,26 @@
"showontab" : 1,
"assistshowspatchername" : 0,
"boxes" : [ {
"box" : {
"id" : "obj-2",
"maxclass" : "newobj",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 370.0, 98.0, 32.0, 22.0 ],
"text" : "print"
}

}
, {
"box" : {
"id" : "obj-28",
"linecount" : 2,
"linecount" : 4,
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 361.0, 131.0, 85.0, 49.0 ],
"text" : "/objects/Text/name Text45\n"
"patching_rect" : [ 347.0, 145.0, 85.0, 62.0 ],
"text" : "/NodeOSC \"Python server started up\""
}

}
Expand All @@ -532,7 +639,7 @@
"numinlets" : 0,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 321.0, 26.0, 30.0, 30.0 ]
"patching_rect" : [ 413.0, 26.0, 30.0, 30.0 ]
}

}
Expand All @@ -543,7 +650,7 @@
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 253.0, 93.0, 121.0, 22.0 ],
"patching_rect" : [ 234.0, 98.0, 121.0, 22.0 ],
"text" : "/objects/Text/body $1"
}

Expand All @@ -556,7 +663,7 @@
"numoutlets" : 2,
"outlettype" : [ "", "float" ],
"parameter_enable" : 0,
"patching_rect" : [ 185.0, 211.0, 174.0, 32.0 ],
"patching_rect" : [ 185.0, 209.0, 174.0, 32.0 ],
"saturation" : 1.0
}

Expand All @@ -569,7 +676,7 @@
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 185.0, 249.0, 184.0, 49.0 ],
"patching_rect" : [ 185.0, 249.0, 185.0, 49.0 ],
"text" : "/materials/Material/nodes/Principled_BSDF/inputs/0/default_value $1 $2 $3 $4"
}

Expand All @@ -593,7 +700,7 @@
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 253.0, 54.0, 31.0, 22.0 ],
"patching_rect" : [ 234.0, 59.0, 31.0, 22.0 ],
"text" : "siter"
}

Expand Down Expand Up @@ -853,13 +960,11 @@
"format" : 6,
"id" : "obj-8",
"maxclass" : "flonum",
"maximum" : 2.0,
"minimum" : 0.0,
"numinlets" : 1,
"numoutlets" : 2,
"outlettype" : [ "", "bang" ],
"parameter_enable" : 0,
"patching_rect" : [ 63.0, 145.0, 44.0, 22.0 ]
"patching_rect" : [ 63.0, 144.0, 44.0, 22.0 ]
}

}
Expand All @@ -870,7 +975,7 @@
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 63.0, 176.0, 102.0, 22.0 ],
"patching_rect" : [ 63.0, 180.0, 102.0, 22.0 ],
"text" : "/cube/property $1"
}

Expand Down Expand Up @@ -944,39 +1049,39 @@
"lines" : [ {
"patchline" : {
"destination" : [ "obj-20", 0 ],
"order" : 0,
"order" : 2,
"source" : [ "obj-1", 0 ]
}

}
, {
"patchline" : {
"destination" : [ "obj-21", 0 ],
"order" : 1,
"order" : 4,
"source" : [ "obj-1", 0 ]
}

}
, {
"patchline" : {
"destination" : [ "obj-22", 0 ],
"order" : 2,
"order" : 0,
"source" : [ "obj-1", 0 ]
}

}
, {
"patchline" : {
"destination" : [ "obj-23", 0 ],
"order" : 3,
"order" : 1,
"source" : [ "obj-1", 0 ]
}

}
, {
"patchline" : {
"destination" : [ "obj-24", 0 ],
"order" : 4,
"order" : 3,
"source" : [ "obj-1", 0 ]
}

Expand Down
12 changes: 8 additions & 4 deletions server/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def OSC_callback_function(address, data_path, prop, attrIdx, oscArgs, oscIndex):
eval(data_path)
except:
if bpy.context.scene.nodeosc_envars.message_monitor == True:
bpy.context.scene.nodeosc_envars.error = "functioncall failed: "+address + " " + obj
bpy.context.scene.nodeosc_envars.error = "functioncall failed: "+address + " " + data_path

# called by the queue execution thread
def OSC_callback_custom(address, data_path, prop, attrIdx, oscArgs, oscIndex):
Expand Down Expand Up @@ -211,7 +211,8 @@ def call_format(address, data_path, prop_ignore, attrIdx, oscArgs, oscIndex, sFo
OSC_callback_IndexedProperty(address, eval(datapath), prop, int(prop_index), oscArgs, f_OscIndex)
elif f_data_path[-1] == ')':
# its a function call
OSC_callback_function(address, eval(f_data_path), prop, attrIdx, oscArgs, f_OscIndex)
prop = ''
OSC_callback_function(address, f_data_path, prop, attrIdx, oscArgs, f_OscIndex)
else:
#without index in brackets
datapath = f_data_path[0:f_data_path.rindex('.')]
Expand All @@ -221,9 +222,12 @@ def call_format(address, data_path, prop_ignore, attrIdx, oscArgs, oscIndex, sFo
except TypeError as err:
if bpy.context.scene.nodeosc_envars.message_monitor == True:
bpy.context.scene.nodeosc_envars.error = "Message attribute invalid: "+address + " " + str(oscArgs) + " " + str(err)
except:
except SyntaxError as err:
if bpy.context.scene.nodeosc_envars.message_monitor == True:
bpy.context.scene.nodeosc_envars.error = "Improper attributes received: "+address + " " + str(oscArgs)
bpy.context.scene.nodeosc_envars.error = "Evaluation error: " + str(err) + " with >" + str(err.text) + "<"
except Exception as err:
if bpy.context.scene.nodeosc_envars.message_monitor == True:
bpy.context.scene.nodeosc_envars.error = "Unknown error: " + str(err)

# method called by the pythonosc library in case of an unmapped message
def OSC_callback_pythonosc_undef(* args):
Expand Down
Loading

0 comments on commit ce28ea8

Please sign in to comment.