本文整理汇总了Python中sverchok.data_structure.node_id函数的典型用法代码示例。如果您正苦于以下问题:Python node_id函数的具体用法?Python node_id怎么用?Python node_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了node_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process
def process(self):
if not (self.id_data.sv_show and self.activate):
callback_disable(node_id(self))
return
n_id = node_id(self)
global cache_viewer_baker
vertex_ref = n_id + 'v'
poledg_ref = n_id + 'ep'
matrix_ref = n_id + 'm'
cache_viewer_baker[vertex_ref] = []
cache_viewer_baker[poledg_ref] = []
cache_viewer_baker[matrix_ref] = []
callback_disable(n_id)
# every time you hit a dot, you pay a price, so alias and benefit
inputs = self.inputs
# this should catch accidental connections which otherwise will cause
# an unrecoverable crash. It might even be an idea to have step in between
# new connections and processing, it could auto rewire s->s v->v m->m.
def check_origin(to_socket, socket_type):
sock_string = sock_dict.get(socket_type)
return inputs[to_socket].links[0].from_socket.bl_idname == sock_string
vertex_links = inputs['vertices'].is_linked and check_origin('vertices', 'v')
matrix_links = inputs['matrix'].is_linked and check_origin('matrix', 'm')
edgepol_links = inputs['edg_pol'].is_linked and check_origin('edg_pol', 's')
if (vertex_links or matrix_links):
if vertex_links:
propv = inputs['vertices'].sv_get(deepcopy=False, default=[])
if propv:
verts = dataCorrect(propv)
for v in verts:
if any(l != 3 for l in map(len, v)):
raise ValueError
cache_viewer_baker[vertex_ref] = verts
if edgepol_links:
prope = inputs['edg_pol'].sv_get(deepcopy=False, default=[])
if prope:
cache_viewer_baker[poledg_ref] = dataCorrect(prope)
if matrix_links:
propm = inputs['matrix'].sv_get(deepcopy=False, default=[])
if propm:
cache_viewer_baker[matrix_ref] = dataCorrect(propm)
if cache_viewer_baker[vertex_ref] or cache_viewer_baker[matrix_ref]:
config_options = self.get_options()
callback_enable(n_id, cache_viewer_baker, config_options)
示例2: process
def process(self):
p = self.inputs['Float'].sv_get()
n_id = node_id(self)
# end early
nvBGL2.callback_disable(n_id)
float_out = self.outputs['Float']
easing_func = easing_dict.get(int(self.selected_mode))
if float_out.is_linked:
out = []
for obj in p:
r = []
for i in obj:
r.append(easing_func(i))
out.append(r)
float_out.sv_set(out)
else:
float_out.sv_set([[None]])
if self.activate:
palette = palette_dict.get(self.selected_theme_mode)[:]
x, y = [int(j) for j in (self.location + Vector((self.width + 20, 0)))[:]]
draw_data = {
'tree_name': self.id_data.name[:],
'mode': 'custom_function',
'custom_function': simple_grid_xy,
'loc': (x, y),
'args': (easing_func, palette)
}
nvBGL2.callback_enable(n_id, draw_data)
示例3: update_csv
def update_csv(self):
n_id = node_id(self)
if self.autoreload:
self.reload_csv()
if self.current_text and n_id not in self.csv_data:
self.reload_csv()
if n_id not in self.csv_data:
print("CSV auto reload failed, press update")
self.use_custom_color = True
self.color = FAIL_COLOR
return
self.use_custom_color = True
self.color = READY_COLOR
csv_data = self.csv_data[n_id]
if not self.one_sock:
for name in csv_data.keys():
if name in self.outputs and self.outputs[name].is_linked:
self.outputs[name].sv_set([csv_data[name]])
else:
name = 'one_sock'
self.outputs['one_sock'].sv_set(list(csv_data.values()))
示例4: reload_json
def reload_json(self):
n_id = node_id(self)
self.load_json_data()
if n_id in self.json_data:
self.use_custom_color = True
self.color = READY_COLOR
示例5: load_json
def load_json(self):
n_id = node_id(self)
self.load_json_data()
json_data = self.json_data.get(n_id, [])
if not json_data:
self.current_text = ''
return
socket_order = json_data.get('socket_order')
if socket_order:
# avoid arbitrary socket assignment order
def iterate_socket_order():
for named_socket in socket_order:
data = json_data.get(named_socket)
yield named_socket, data
socket_iterator = iterate_socket_order()
else:
socket_iterator = sorted(json_data.items())
for named_socket, data in socket_iterator:
if len(data) == 2 and data[0] in {'v', 's', 'm'}:
new_output_socket(self, named_socket, data[0])
else:
self.use_custom_color = True
self.color = FAIL_COLOR
return
示例6: free
def free(self):
global cache_viewer_baker
n_id = node_id(self)
callback_disable(n_id)
cache_viewer_baker.pop(n_id + 'v', None)
cache_viewer_baker.pop(n_id + 'ep', None)
cache_viewer_baker.pop(n_id + 'm', None)
示例7: sv_init
def sv_init(self, context):
n_id = node_id(self)
self.width = 400
self.color = (0.5, 0.5, 1)
self.use_custom_color = True
self.inputs.new('StringsSocket', "Text In", "Text In")
self.outputs.new('StringsSocket', "Text Out", "Text Out")
示例8: reset
def reset(self):
n_id = node_id(self)
self.outputs.clear()
self.current_text = ""
self.csv_data.pop(n_id, None)
self.list_data.pop(n_id, None)
self.json_data.pop(n_id, None)
示例9: update_csv
def update_csv(self):
n_id = node_id(self)
if self.reload_on_update:
self.reload_csv()
if self.current_text and n_id not in self.csv_data:
self.reload_csv()
if n_id not in self.csv_data:
print("CSV auto reload failed, press update")
self.use_custom_color = True
self.color = FAIL_COLOR
return
self.use_custom_color = True
self.color = READY_COLOR
csv_data = self.csv_data[n_id]
if not self.one_sock:
for name in csv_data.keys():
if name in self.outputs and self.outputs[name].links:
SvSetSocketAnyType(self, name, [csv_data[name]])
else:
name = 'one_sock'
SvSetSocketAnyType(self, 'one_sock', list(csv_data.values()))
示例10: process
def process(self):
inputs = self.inputs
n_id = node_id(self)
# end early
nvBGL.callback_disable(n_id)
if self.activate and inputs[0].is_linked:
try:
with sv_preferences() as prefs:
scale = prefs.stethoscope_view_scale
location_theta = prefs.render_location_xy_multiplier
except:
# print('did not find preferences - you need to save user preferences')
scale = 1.0
location_theta = 1.0
# gather vertices from input
data = inputs[0].sv_get(deepcopy=False)
self.num_elements = len(data)
if self.selected_mode == 'text-based':
props = lambda: None
props.line_width = self.line_width
props.compact = self.compact
props.depth = self.depth or None
processed_data = nvBGL.parse_socket(
inputs[0],
self.rounding,
self.element_index,
self.view_by_element,
props
)
else:
# # implement another nvBGL parses for gfx
processed_data = data
node_width = (self.width_hidden + 30.0) if self.hide else self.width
# adjust proposed text location in case node is framed.
# take into consideration the hidden state
_x, _y = recursive_framed_location_finder(self, self.location[:])
_x, _y = Vector((_x, _y)) + Vector((node_width + 20, 0))
# this alters location based on DPI/Scale settings.
location = adjust_location(_x, _y, location_theta)
draw_data = {
'tree_name': self.id_data.name[:],
'content': processed_data,
'location': location,
'color': self.text_color[:],
'scale' : float(scale),
'mode': self.selected_mode[:],
'font_id': int(self.font_id)
}
nvBGL.callback_enable(n_id, draw_data)
示例11: update
def update(self):
if not ("matrix" in self.inputs):
return
try:
if not (self.inputs[0].other or self.inputs[2].other):
callback_disable(node_id(self))
except:
print('vdmk2 update holdout')
示例12: update
def update(self):
if not ("Data" in self.inputs):
return
try:
if not self.inputs[0].other:
nvBGL.callback_disable(node_id(self))
except:
print('stethoscope update holdout (not a problem)')
示例13: load_csv
def load_csv(self):
n_id = node_id(self)
self.load_csv_data()
if not n_id in self.csv_data:
print("Error, no data loaded")
else:
for name in self.csv_data[n_id]:
self.outputs.new("StringsSocket", name, name)
示例14: load_sv
def load_sv(self):
n_id = node_id(self)
self.load_sv_data()
if n_id in self.list_data:
name_dict = {"m": "Matrix", "s": "Data", "v": "Vertices"}
typ = self.socket_type
new_output_socket(self, name_dict[typ], typ)
示例15: process
def process(self):
if not (self.id_data.sv_show and self.activate):
callback_disable(node_id(self))
return
n_id = node_id(self)
global cache_viewer_baker
vertex_ref = n_id + 'v'
poledg_ref = n_id + 'ep'
matrix_ref = n_id + 'm'
cache_viewer_baker[vertex_ref] = []
cache_viewer_baker[poledg_ref] = []
cache_viewer_baker[matrix_ref] = []
callback_disable(n_id)
# every time you hit a dot, you pay a price, so alias and benefit
inputs = self.inputs
vertex_links = inputs['vertices'].is_linked
matrix_links = inputs['matrix'].is_linked
edgepol_links = inputs['edg_pol'].is_linked
if vertex_links or matrix_links:
if vertex_links:
propv = inputs['vertices'].sv_get(deepcopy=False, default=[])
if propv:
cache_viewer_baker[vertex_ref] = dataCorrect(propv)
if edgepol_links:
prope = inputs['edg_pol'].sv_get(deepcopy=False, default=[])
if prope:
cache_viewer_baker[poledg_ref] = dataCorrect(prope)
if matrix_links:
propm = inputs['matrix'].sv_get(deepcopy=False, default=[])
if propm:
cache_viewer_baker[matrix_ref] = dataCorrect(propm)
if cache_viewer_baker[vertex_ref] or cache_viewer_baker[matrix_ref]:
config_options = self.get_options()
callback_enable(n_id, cache_viewer_baker, config_options)