add new node ScSelectVertexByConnections#88
add new node ScSelectVertexByConnections#88aachman98 merged 2 commits intoaachman98:masterfrom zebus3d:development
Conversation
aachman98
left a comment
There was a problem hiding this comment.
I've added a few changes which can improve the code. It will be very useful once merged though.
There is also a simpler implementation for this:

where b is bmesh.from_edit_mesh(self.inputs["Object"].default_value.data) and comparison of length can be done with self.inputs["Connections"].default_value
Then the resulting array can be traversed and corresponding indices can be set to selected.
If you want me to change it accordingly, then let me know. I'll merge the PR and edit it before the next release.
| bl_label = "Select Vertex By Connections" | ||
|
|
||
| in_connections: IntProperty(default=1, min=0, update=ScNode.update_value) | ||
| in_extend: BoolProperty(default=True, update=ScNode.update_value) |
| self.inputs.new("ScNodeSocketBool", "Extend").init("in_extend") | ||
| # work in vertex mode: | ||
| # With this it is not necessary to manually force the mode to vertices mode: | ||
| self.in_selection_type = {'VERT'} |
There was a problem hiding this comment.
Don't set variables directly in init() function because it will call ScNode.update_value() and execute the nodetree for every variable. Either set their default values (like in in_extend above) or simply add an error condition.
| # work in vertex mode: | ||
| # With this it is not necessary to manually force the mode to vertices mode: | ||
| self.in_selection_type = {'VERT'} | ||
| self.in_extend = False |
| super().error_condition() | ||
| or int(self.inputs["Connections"].default_value) < 0 | ||
| # prevent other modes: | ||
| or self.in_selection_type != {'VERT'} |
There was a problem hiding this comment.
Since the in_selection_type is an input socket which can contain multiple values (set), the correct condition would be:
or (not 'VERT' in self.inputs["Selection Type"].default_value)
| ) | ||
|
|
||
| def functionality(self): | ||
| print(self) |
There was a problem hiding this comment.
No further need for debug logs
|
|
||
| def functionality(self): | ||
| print(self) | ||
| connections = int(self.inputs["Connections"].default_value) |
There was a problem hiding this comment.
Avoid initialising extra variables unless you want to use them multiple times
| def functionality(self): | ||
| print(self) | ||
| connections = int(self.inputs["Connections"].default_value) | ||
| obj = self.inputs["Object"].default_value |
| connections = int(self.inputs["Connections"].default_value) | ||
| obj = self.inputs["Object"].default_value | ||
|
|
||
| mode = bpy.context.mode |
| obj = self.inputs["Object"].default_value | ||
|
|
||
| mode = bpy.context.mode | ||
| if mode != 'EDIT': |
There was a problem hiding this comment.
This is never required because the object will be selected AND in the edit mode before calling functionality().
See pre_execute() of parent class ScSelectionNode
aachman98
left a comment
There was a problem hiding this comment.
Good enough. I'll add a few lines of code from other selection nodes to improve on the deselect & extend feature.
Thanks!
|
I don't control github depth. I made most of the changes, however you can change whatever you want after you accept the change. I used a while to keep the first match and then look for similar ones, because I think that way the performance will be better, since you don't have to go through all the vertexs. |
But it is only useful if |
I guess select_similar is written in c or c++ and the performance will be better than in python, but these are just assumptions. |
No description provided.