Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added "Receive From Socar" generator (ext) node #3281

Merged
merged 12 commits into from
Jun 9, 2020

Conversation

aachman98
Copy link
Contributor

@aachman98 aachman98 commented May 25, 2020

Addressed problem description

Addition of a generator node to receive data input from Sorcar node output. This is a dedicated node which presents a one-sided connection between Sverchok & Sorcar where mesh data is transferred from the latter.

Node Name: Receive From Sorcar
Node Category: Generators -> Generators Extended
Class Name: SvReceiveFromSorcarNode

Screenshot from 2020-05-25 19-35-15

image

Solution description

Usage

The node comes with 6 outputs: Vertices, Edges, Faces, VerticesMask, EdgesMask, FacesMask
Each of the socket corresponds to the components of the mesh data being stored in the node properties (namely "verts", "edges", "faces") and the their selection mask.

Default

By default, a simple Sorcar logo mesh is contained. The node behaves as a single-mesh-output node unless paired with Send to Sverchok node in the Sorcar nodetree.

image

Referenced

This node can be referenced inside Sorcar, and the mesh data of the object (passed as input) is transferred to this node. The node properties hold the data (unless modified externally) allowing users to remove/modify Sorcar nodetree or the object in the scene without losing the geometry.

Screenshot from 2020-05-25 19-41-06
Screenshot from 2020-05-25 19-41-12

Parameter updates

This node will update in the same way as expected from all the other Sverchok nodes. Since the mesh data and component masks are stored internally, re-evaluating Sorcar nodetree is not necessary.
In case of any update of parameters in Sorcar, the new mesh will be set in the properties once when the node gets executed, and will act as the new starting point. No further evaluations are required.

In the following examples, I first modify the Sverchok nodetree (added "Unsubdivide" node) and then modify a Sorcar node parameter ("Offset" in Poke node) to demonstrate the seamless non-destructive workflow.

Screenshot from 2020-05-25 19-41-59

Screenshot from 2020-05-25 19-42-21

Video demo: https://www.youtube.com/watch?v=pTIiMj5GpyI

Preflight checklist

  • Code changes complete.
  • Code documentation complete.
  • Documentation for users complete (or not required, if user never sees these changes).
  • Manual testing done.
  • Unit-tests implemented.
  • Ready for merge.

@aachman98 aachman98 requested a review from zeffii May 25, 2020 16:54
Copy link
Collaborator

@zeffii zeffii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nothing to add, it's a straightforward node.

@aachman98
Copy link
Contributor Author

I was a bit skeptical about the default mesh data (takes over 500 lines of code). If required, I'll revert back to a simple cube data (8 v, 12 e, 6 f)

@zeffii
Copy link
Collaborator

zeffii commented May 25, 2020

we can provide a geometry module in sverchok.utils.modules.sorcar_default_geometry don't worry about it.

@nortikin
Copy link
Owner

COOL!

@Durman
Copy link
Collaborator

Durman commented May 26, 2020

I expect that when a new mesh will be set to the node properties Sverchok node tree will be evaluated three times in a row. What is not very cool.

@aachman98
Copy link
Contributor Author

I’ll remove the “update” for verts and edges property. The props are set in this very order, so the update will be called one time only, AFTER the data has been set.

@zeffii
Copy link
Collaborator

zeffii commented May 26, 2020

there's a lot of ways to implement this kind of node, usually only a steady stream of users will show us what they really need

@Durman
Copy link
Collaborator

Durman commented May 26, 2020

I would suggest to remove update function from all properties and add a method to the node, like this:

def set_mesh(self, verts, edges, faces):
    self.verts = verts,
    self.edges = edges
    self.faces = faces
    updateNode(self, None)

It will make setting mesh process more clear.

@aachman98
Copy link
Contributor Author

Nice and clean! Working on it..

@zeffii
Copy link
Collaborator

zeffii commented May 28, 2020

here's that logo compressed into 2D.

import sverchok
from sverchok.nodes.modifier_make.solidify import solidify

def make_sorcar_logo():
    """ makes sorcar 3d - literal data"""
    a = 0.4233
    b = 0.7778
    c = 0.6878
    d = 0.3333
    e = 1.0
    f = 0.9100
    g = 0.8678
    h = 0.2433
    i = 0.6456
    j = 0.5556
    k = 0.4656
    l = 0.2011
    m = 0.1111
    n = 0.0211

    verts_2d = [
        (-a, -b), (-c, -b), (-b, -c), (-b, -d), (-e, -d), (-e, -f), (-f, -e), (-d, -e),
        (-d, -g), (-h, -b), (+h, -b), (+d, -g), (+d, -e), (+f, -e), (+e, -f), (+e, -d),
        (+b, -d), (+b, -c), (+c, -b), (+a, -b), (+d, -c), (+d, -i), (+a, -j), (+k, -j),
        (+j, -k), (+j, -l), (+k, -m), (+a, -m), (+d, -n), (+d, +n), (+h, +m), (-h, +m),
        (-d, +l), (-d, +k), (-h, +j), (+h, +j), (+d, +k), (+d, +a), (+a, +d), (+k, +d),
        (+j, +a), (+j, +k), (+k, +j), (+a, +j), (+d, +i), (+d, +c), (+a, +b), (+c, +b),
        (+b, +c), (+b, +d), (+e, +d), (+e, +f), (+f, +e), (+d, +e), (+d, +g), (+h, +b),
        (-h, +b), (-d, +g), (-d, +e), (-f, +e), (-e, +f), (-e, +d), (-b, +d), (-b, +c),
        (-c, +b), (-a, +b), (-d, +c), (-d, +i), (-a, +j), (-k, +j), (-j, +k), (-j, +l),
        (-k, +m), (-a, +m), (-d, +n), (-d, -n), (-h, -m), (+h, -m), (+d, -l), (+d, -k),
        (+h, -j), (-h, -j), (-d, -k), (-d, -a), (-a, -d), (-k, -d), (-j, -a), (-j, -k),
        (-k, -j), (-a, -j), (-d, -i), (-d, -c)
    ]

    verts_3d = [(v[0], v[1], 0.05) for v in verts_2d]
    face = list(range(len(verts_3d)))
    verts, edges, faces, _ = solidify(verts_3d, [face], [0.1])
    return verts, edges, faces

@nortikin
Copy link
Owner

nortikin commented Jun 7, 2020

can we merge?

@aachman98
Copy link
Contributor Author

I haven’t updated the code yet. Will push the new method with compressed mesh by tomorrow. Also, I was thinking of adding 3 new component mask outputs so that we can retain the selection.

@aachman98 aachman98 requested a review from zeffii June 8, 2020 15:07
@aachman98
Copy link
Contributor Author

image

from sverchok.utils.modules.geom_sorcar import make_sorcar_logo

class SvReceiveFromSorcarNode(bpy.types.Node, SverchCustomTreeNode):
''' Receive Mesh Data From Sorcar '''
Copy link
Collaborator

@zeffii zeffii Jun 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have a useful scheme for this , and it makes tooltips for our menus automatically

    """
    Triggers: sorcar sc receive
    Tooltip: Receive Mesh Data From Sorcar
    
    A short description for reader of node code <---not mandatory, but you could include links of interest.
    """

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
I don't have any links of interest (maybe except for this PR as it has some info on the top), so I'll create a separate small description and add some comments in the code.


verts: StringProperty(name='Vertices',
default=repr([sc_v]),
options={'ANIMATABLE'})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

animatable is redundant. this is the default state of properties.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied the code from generators -> sphere.py when I started, so I thought this was the standard way Sverchok node properties were made. It also has a one-line description.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, but it's not so useful to restate the default. i'm not going to retrospectively remove them, but whenever a node gets added or updated i try to nip that in the bud.



def unregister():
bpy.utils.unregister_class(SvReceiveFromSorcarNode)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a new empty line

verts_3d = [(v[0], v[1], 0.05) for v in verts_2d]
face = list(range(len(verts_3d)))
verts, edges, faces, _ = solidify(verts_3d, [face], [0.1])
return verts, edges, faces
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a new empty line

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other than these things, it seems OK. i'm sure our adventurous users will be happy to have this kind of convenience. glad we can collaborate in this way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for all the effort!

verts_3d = [(v[0], v[1], 0.05) for v in verts_2d]
face = list(range(len(verts_3d)))
verts, edges, faces, _ = solidify(verts_3d, [face], [0.1])
return verts, edges, faces
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other than these things, it seems OK. i'm sure our adventurous users will be happy to have this kind of convenience. glad we can collaborate in this way.

@aachman98 aachman98 requested a review from zeffii June 9, 2020 01:28
Copy link
Collaborator

@zeffii zeffii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at this point it's more useful to have users ride the node than suggesting code changes.

@zeffii zeffii merged commit aa70c65 into nortikin:master Jun 9, 2020
@enzyme69
Copy link
Collaborator

enzyme69 commented Jun 9, 2020

Screen Shot 2020-06-10 at 7 52 55 am

Missing "Send to Sorcar" node in SV

Screen Shot 2020-06-10 at 7 54 14 am

And also getting error when sending to SV from SC.

Error: Traceback (most recent call last):
  File "/Users/jimmygunawan/Library/Application Support/Blender/2.83/scripts/addons/Sorcar-master/operators/ScExecuteNode.py", line 19, in execute
    curr_tree.execute_node()
  File "/Users/jimmygunawan/Library/Application Support/Blender/2.83/scripts/addons/Sorcar-master/tree/ScNodeTree.py", line 58, in execute_node
    if (not n.execute()):
  File "/Users/jimmygunawan/Library/Application Support/Blender/2.83/scripts/addons/Sorcar-master/nodes/_base/node_base.py", line 56, in execute
    self.functionality()
  File "/Users/jimmygunawan/Library/Application Support/Blender/2.83/scripts/addons/Sorcar-master/nodes/utilities/ScSendToSverchok.py", line 46, in functionality
    self.prop_tree.nodes[self.prop_node].set_mesh(repr(v), repr(e), repr(f))
TypeError: set_mesh() missing 3 required positional arguments: 'verts_mask', 'edges_mask', and 'faces_mask'

@enzyme69
Copy link
Collaborator

enzyme69 commented Jun 9, 2020

However SV node remote control confirmed working with SC...

Screen Shot 2020-06-10 at 7 59 20 am

@aachman98
Copy link
Contributor Author

And also getting error when sending to SV from SC.

Sorry, issue from my side. I modified the "Receive From Sorcar" node in the last few commits which allows you to get selection mask as well, but the code for Sorcar node is not yet updated.
Issue created here: aachman98/Sorcar#152
The sverchok node has no issues.

Missing "Send to Sorcar" node in SV

Testing for bugs currently, as selection mask inputs have been added to that node as well. Will be creating a separate PR for it.

@hanoixan
Copy link

@aachman98 Did a separate PR ever get created to add the "Send to Sorcar" node? As of now, it appears to still be missing.

@nortikin
Copy link
Owner

@aachman98 Did a separate PR ever get created to add the "Send to Sorcar" node? As of now, it appears to still be missing.

ATM node remote control to manipulate some values on sorcar. Or use viewer bmesh to create object and use it on any other node system

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants