1
$\begingroup$

I'm using an add-on (latex2blender).

enter image description here

If I change one parameter, it will show me in the console how it was done it was done in python. Here I am changing the input to "$ x $":

enter image description here

Now I know I can use that in python, i.e. writing:

import bpy
bpy.context.scene.my_tool.latex_code = "$ x $ "

But how can I use python to click the button "Compile as grease Pencil"?

The console just spams custom commands the plguin is using. I was hoping it was possible to do something like "scene.my_tool.button_x_click = True" or something.

Do you have any idea?

$\endgroup$

1 Answer 1

1
$\begingroup$

First, add to your imports import latex2blender so you can have access to all of the classes of the add-on. After setting the LaTeX code, you can then use latex2blender.classes[5].execute(latex2blender, bpy.context) to compile your LaTeX as a grease pencil. Using classes[4] would compile as mesh and classes[3] would be as a curve.

If you open the latex2blender add-on by right clicking it, going to "show more options", and then "edit with IDLE", you can explore the add-on and see where this all comes from. My file path to the add-on is C:\Users\myUsername\AppData\Roaming\Blender Foundation\Blender\3.2\scripts\addons and I had to go to View -> Show -> Hidden items in my file explorer to get AppData to appear.

Her're those classes in the add-on: enter image description here

It's unfortunate that these buttons don't appear under scene.my_tool.. I think there could be a way to modify the add-on if you really want them to appear there.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .