1
$\begingroup$

I notice that Blender only logs certain things in the "Info" panel. Is there some other place that they log data(such as if one were to have 3 vertices selected, where would they store that data for later use if someone were to move them)? Another way to phrase this would be: if I am scripting, where can I access the current selected vertices?

$\endgroup$
1
  • 2
    $\begingroup$ Hi. Please only ask one question at a time. You are welcome to ask multiple questions but as separate posts. I suggest editing your question down to just one question (by using the edit link below it) and asking the other one separately. Thanks. $\endgroup$ – Ray Mairlot Aug 7 '20 at 22:52
2
$\begingroup$

The info is mainly explicit defined and call from operator :

class mesh_OT_someops(byp.types.Operator):
    def pseudo_excute(self):
        self.report({'INFO'},"This is an Info Output")

It can be arbitrary thing and most of the time, the final output log is been emitted. And for sure, Blender and all other programming language will not automatically "Saved Log" for anything. Unless that is a state machine, which, seems to far away from the topic.

So, if you are scripting, you will always have to dig out the data from the Blender module bpy. For your mesh selected vertices, it will be something like this:

selected_vertices = [i for i in bmesh.from_edit_mesh(obj.data).verts if i.select]

It is not easy when you are not familiar with program, especially pointer-based programming since most of the Blender object you call is reference. And also, using Blender scripting need a certain degree of Python knowledge, which might be hard to learn, despite Python claims for easy to learn.

$\endgroup$
0
0
$\begingroup$

Writing scripts based on INFO area reports is not the way to go

Since it appears you are new to blender scripting, thought I'd add somewhat of an answer re getting started, INFO area and selected verts, not so much or

Find I very rarely have the INFO area open. It is IMO not going to provide that much useful info for anything but the simplest script. Operators provide an interface between the User and the data. They use context as input, require the correct context to run and the results are reflected via context.

It is quite often the case that using an API method is a more practical way of coding directly.

a = bpy.ops.object.empty_add()
b = bpy.data.objects.new("Empty", None)

after running a is {'FINISHED'} ie the operator completed, the newly operator created empty is now the context.object. b is a ref a newly created empty object.

Developer Extras

There is some assistance via developer extras. Pretty well covered here:

Displaying vertex indices in Blender 2.8 using debug mode

ie can view the vertex indices via an overlay, and the operator associated with an action via tooltip.

bmesh module

Recommend usage of the bmesh module for investigating and editing meshes. Will see nowt about its use in the INFO area. Perhaps there could be more, but will find a number of fantastic examples dotted thru the API manual. This one creates a couple of chain links.

https://docs.blender.org/api/current/bmesh.ops.html#operator-example

There are a number of bmesh operators with similar names to bpy.ops.mesh operators. Beauty of bmesh is pick a mode to work in , create a bmesh and not have to bother again with context and mode toggling.

May notice some recommend not using, or avoiding, operators. Would clarify this somewhat to don't over use, particularly don't loop and call

see Python performance with Blender operators

Python Console

Use the python console as an interactive way to "nut out" scripts.

With a mesh in edit mode. In the console C = bpy.context and D = bpy.data

>>> import bmesh
>>> C.mode
'EDIT_MESH'

Create a bmesh representation of the edit mesh

>>> bm = bmesh.from_edit_mesh(C.object.data)

Similarly to example in the other answer re getting selected verts by attribute from all can look at the select history. Example below have 3 verts selected, index 14, 17 and 19

>>> for e in bm.select_history:
...     type(e), e.index, e
...     
(<class 'BMVert'>, 14, <BMVert(0x7fe2fd006320), index=14>)
(<class 'BMVert'>, 17, <BMVert(0x7fe2fd0063c8), index=17>)
(<class 'BMVert'>, 19, <BMVert(0x7fe2fd006438), index=19>)

Autocomplete, for 2.8 this is the TAB key. Typing just C.objTAB will expand to C.object or a narrowed down list of matches.

The up and down arrows for history.

Related

Saving/loading the location(x,y,z) of selected vertices

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.