-
Notifications
You must be signed in to change notification settings - Fork 113
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
add new node ScSelectVertexByConnections #88
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set default=False
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same goes for this
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same goes for this
connections = int(self.inputs["Connections"].default_value) | ||
obj = self.inputs["Object"].default_value | ||
|
||
mode = bpy.context.mode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this
obj = self.inputs["Object"].default_value | ||
|
||
mode = bpy.context.mode | ||
if mode != 'EDIT': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.