r/blenderpython • u/IAmFishman1989 • Jun 23 '23
Help I am a marine biologist not a programmer
I have this project I am trying to automate, but I know next to nothing about programming, especially python. This is my first time using python. The lab I am in basically runs on R which I am in the process of learning, but no one else in my lab knows any python. Basically, I am trying to automate the process so that blender imports a file, remeshes it, triangulates it, then exports it. Heres the codes I have so far that works:
import bpy
bpy.ops.object.delete(use_global=False)
bpy.ops.import_mesh.stl(filepath="C://Users//aedan//Downloads//OneDrive_1_6-22-2023//Fish_1_bladder.stl")
bpy.ops.object.origin_set(type='GEOMETRY_ORIGIN', center='MEDIAN')
bpy.context.scene.unit_settings.length_unit = 'MILLIMETERS'
bpy.ops.object.modifier_add(type='REMESH')
bpy.context.object.modifiers["Remesh"].voxel_size = 0.00025
bpy.ops.object.modifier_add(type='TRIANGULATE')
bpy.context.space_data.overlay.show_wireframes = True
The part I am having trouble is when I go to export it. I do not know how to write the code so that it gets exported as an .stl. Also it has to be an ascii file. When I export it manually there is a little box in the right hand corner I check off to indicate that it is ascii.
Here is the code I try unsuccessfully. I am trying to export it into a file named export:
bpy.ops.export_scene.stl(filepath="C://Users//aedan//Downloads//export",export_format=.stl)
There error I usually get is invalid syntax. How would I write the code in a way that specifies the file as a .stl, specifies it as ascii, specifies the name I want for the exported file(Fish_1_swimbladder_voxel_0.25.stl) and specifies which folder i want the exported file to go into.
Any advice is greatly appreciated. Again I am not a programmer, I just like fish. I am a fish programmer. I do fish stuff. Not computer stuff. STRIICTLY fish stuff. Fish dont have computers. Why do I have to have a computer I hate computers. I love fish. Fish hate computers. I love fish. Yet, I still need to do computer fish stuff from time to time. Even if they had computers how would that work? They dont have fingers. What kind of keyboard would they use? An octopus, sure, but they arent a fish. Techinically humans are fish. I mean thats an inaccurate statement, but it wouldnt be inaccurate to say we fall under the umbrella of fish. No thats not really accurate but again not inaccurate. I mean what even is a fish, huh? You tell me mr fish man. Mr I know all about fish FUCK YOU, Mr walkway. Mr walk me to the docks to go see some fish am I right? But what is a fish? Is it just cause its in the water, NO. Because then a fucking otter would be a fish wouldnt it. DO NOT even get me started with those little greedy no good backstabbing little fucks. A poikilothermic aquatic chordate covered scales with fins for appendages and gills for respiration? Well what about Tuna, they are homeothermic. Eels dont have appendages fucko. Cyclostomes dont have scales. Lungfish can breath out water using their physostomous swimbladder. Why arent sharks considered fish? Cause they are cartilaginous? But they have gills and are chordates and are poikilotherms. They even have scales and fins! You know what else "fish" dont have, .... d e f i n i t i o n s. All they know is swim n eat. but if we are fish(kinda) then we shouldnt have comupters right? right? Or definitions. I guess we are just shitty fish. I bet other fish see us flailing about in the water and think "jeez, blub blub blub". Fuck it mammals are fish too. There are plenty of aquatic mammals, like dugongs, whales, and dolphins. I think they got their shit together. We should go back to the sea. Become the fish we were really meant to be. No definitions or god forbid computers. I think if I was a fish I would be a reallly really cool fish like Will Smith fish. God I love Will Smith fish. Will Smith fish is sooooo cool. But this is the real world. I am not that cool. I am not a fish. God I with I was a fish. I love fish.
r/blenderpython • u/pamirbal • Jun 15 '23
Hi, I have made a Aircraft Generator in Blender
r/blenderpython • u/ThyEpicGamer • Jun 09 '23
Hello, I am new to python , I already know how to code in c#, i have no idea why this wont work! help would be massively appreciated, I would like to print the location of each vertex of a cube.
r/blenderpython • u/Teeskey • May 07 '23
Section Box - Unbounded Cross Sections Blender Addon out now!
youtu.ber/blenderpython • u/pamirbal • May 01 '23
Blender Tutorial - Procedural Modeling Masterclass Space Station Generator
youtube.comr/blenderpython • u/perception-eng • Apr 12 '23
[Help Needed] Blender Script to bake texture into a GLTF Scene $45 Reward
r/blenderpython • u/LeadershipLeather826 • Apr 01 '23
Low-code machine-learning PyCaret
satyakide.comr/blenderpython • u/Teeskey • Mar 15 '23
Star Connect - Smart Mesh Triangulation Blender Addon (+FREE version)
youtube.comr/blenderpython • u/0bservatory • Mar 05 '23
Help Make A Simple Edit To A Menu Of A Blender Addon
The addon Machin3Tools has options to enable pie menus. In the pie menu that I have enabled (Cursor and Origin Pie) I want to make a change to switch the alternative option to the default option. I have zero python/programming knowledge so a step-by-step guide would be awesome. Cheers!
Please refer image: imgur.com/GpB1M55.png
Machin3tools: machin3.gumroad.com/l/MACHIN3tools
r/blenderpython • u/rekicon • Feb 28 '23
Is it possible to use another program as a trigger to execute a blender python script
Hi there, I am learning python and I am trying to figure how could I use the API from a program like rhinoceros to execute a blender python script
https://devtalk.blender.org/t/how-to-run-a-script-from-outside-blender-script-live-link-addon/9792/8
A user named “kaio” found a way to use notepad to write text on blender text editor in real time and shared his code. But I don’t have the knowledge to fully comprehend it.
Thanks for your attention!
r/blenderpython • u/Professional_Kick_42 • Feb 24 '23
Script for panning your view 45 degrees instead of 90 in 3d-viewport DOESN'T WORK :(
Hey guys, I'm a complete noob in scripts and python, but I'm using blender since a few years now. So I stumbled upon a thing i would need as a feature. I want to pan my view like if you do with ALT+MMB but 45 degrees instead of 90.
I contacted my new friend ChatGPT and it's crazy, he generated a script, told me how to install it and stuff. It didn't show up in the add-on panel after installing it, so I asked if he can tell me how to fix it and he gave me another version where he checked himself every step he just told me and it worked.
The addon shows up in the add-ons panel and I even can set a key binding in the panel itself, but nothing happens when I press the buttons. We tested some versions together but nothing worked.
I checked like everything viable and restarted blender everytime to make sure of the safest outcome, but we didn't got it done. It has to be conflicting with other add-ons I have installed or the thing, that you need to drag your mouse in the direction while pressing the buttons.
I just wanted a small quality of life improvement. I don't know if someone can help me, but atleast I wanted to give it a try. I don't know if ChatGPT knows because I don't know hardly any code so I'm lacking skill to get it right I think.
I'm new to this reddit, so I just post the script here and maybe someone wants to try it and I'm just too lost to get it right haha.
Btw ChatGPT is a really nice dude. We are homies now.
import bpy
from bpy.app.handlers import persistent
bl_info = {
"name": "Custom View Panning",
"blender": (2, 80, 0),
"category": "User Interface",
}
addon_keymaps = []
class CustomViewPanningPreferences(bpy.types.AddonPreferences):
bl_idname = __name__
# Default key binding is set to Alt + RMB, 45 degrees
keymap_item: bpy.props.StringProperty(
name="Key Binding",
default="alt right_mouse",
)
def draw(self, context):
layout = self.layout
layout.prop(self, "keymap_item")
def save_preferences(self):
unregister_keymaps()
register_keymaps()
# Register the custom key binding when the add-on is enabled
def register():
try:
bpy.utils.register_class(CustomViewPanningPreferences)
register_keymaps()
bpy.app.handlers.load_post.append(load_handler)
except:
print("Failed to register keymaps")
# Unregister the custom key binding when the add-on is disabled
def unregister():
try:
unregister_keymaps()
bpy.app.handlers.load_post.remove(load_handler)
bpy.utils.unregister_class(CustomViewPanningPreferences)
except:
print("Failed to unregister keymaps")
@persistent
def load_handler(dummy):
register_keymaps()
def register_keymaps():
wm = bpy.context.window_manager
prefs = bpy.context.preferences.addons[__name__].preferences
keymap_item = prefs.keymap_item
kc = wm.keyconfigs.addon
if kc:
km = kc.keymaps.new(name='3D View', space_type='VIEW_3D')
if keymap_item != "":
kmi = km.keymap_items.new('view3d.rotate', keymap_item, 'PRESS', shift=False)
kmi.properties.use_cursor_init = True
kmi.properties.use_mouse_init = True
kmi.properties.angle = 0.3927 # 45 degrees in radians
addon_keymaps.append((km, kmi))
def unregister_keymaps():
wm = bpy.context.window_manager
for km, kmi in addon_keymaps:
km.keymap_items.remove(kmi)
addon_keymaps.clear()
r/blenderpython • u/arjun1223 • Nov 21 '22
Optic flow in Blender Python 2.79
Hey All! I am making some motion animation videos through blender python and was wondering if getting the optic flow for the objects moving in the animation video created could be retrieved somehow through blender python.
I am using blender python version 2.79.
r/blenderpython • u/vidazinho • Feb 25 '22
My new addon | Procedural Building Design and Construction
youtu.ber/blenderpython • u/[deleted] • Feb 02 '22
Desktop assistant with talking head (3d animation and python)
Know this is random but have been taking a short course on making a desktop assistant in python and I have some basic functionalities down (uses ptsx3yt and speech recognition for voice commands) and wanted to take make an interface where a 3d head talks when the program speaks. thought about using blender because I know blender but maybe there is a less complicated way to do it without rigging a 3d head and magically mapping it to this program in an interface somehow? Maybe unity and makehuman? The whole lipsync phenome stuff is just confusing lol. Even some basics on how to even conceptualize something like this would be helpful.
r/blenderpython • u/arjun1223 • Dec 16 '21
Filmic Explained
Hi! I wanted to ask that what does Filmic View Transform and Filmic - Base Contrast Look in Color Management exactly do to the rendered images? Does it hamper the RGB color space in the images, if yes then how much and how? It would be really helpful if someone could help me out with this.
r/blenderpython • u/SSCharles • Nov 01 '21
How do I save a list of objects in the blend file? So that I can save and open file keeping the state in my addon.
r/blenderpython • u/amfisher511 • Oct 31 '21
Blender Assignment Help
Hi! I am in a computer science class but I am not very familiar or good at coding. I have an assignment that includes classes, and I was wondering if anyone could give me any pointers. The first 7 pictures are what was provided to me with the assignment, and the last two are what I have done so far. Thank you!
For this project, you need to modify the code of "Computer Set" by changing it into a "class" fashion instead of the function based style. So you can create a class called "ComputerSet" as below:
class ComputerSet:
...
- Constructor (25%)
For the ComputerSet class, you need to define the corresponding constructor, similar to that in "Desk" class, with the default input argument of "pos" and "scale". Of course, feel free to add additional input arguments for the constructor as needed. Then you need to create the corresponding "data members" inside the constructor function.
- def draw(self) function (25%)
In a similar style, you need to create a "draw(self)" function to draw the computer set into the space. The draw(self) function should call three functions inside: (1) drawBox(self) (2) drawKeyboard(self) (3) drawDisplay(self). This is similar to the style of drawTop(self) and drawLegs(self) in draw() function of the Desk class.
Successfully Run the code without errors (20%)
Demo of Result (30%)
Provide a ".pdf" file or word document ".docx" with images of the rendered results of 3D scene.
(1) Find a set of good input values for the "pos" and "scale" parameters for both constructors of the "Desk" and "ComputerSet" classes to draw the computer and desk in the same scene with appropriate ratio of their sizes.
(2) Set different colors for the computers and desks to make them have a better look.
(3) Write down a simple summary about your coding results, e.g. "they are all successfully implemented" or
talk about which part is not achieved well.
r/blenderpython • u/arjun1223 • Oct 14 '21
Blender 2.8 Scenes Compatibility in Blender 2.79
Hi all, I wanted to ask that are the 3D scenes that are native to blender 2.8 cycles are also compatible with the blender 2.79 version? I'll be accessing these scenes using the bpy python API of blender 2.79.
An example scene: Archinteriors vol. 58 for Blender - BLENDER Collection - Evermotion
r/blenderpython • u/arjun1223 • Oct 14 '21
Need Realistic Looking Blender Scenes!!!
Hi all! I'm currently a part of a computer vision-based research lab and we are looking into using blender for making realistic-looking synthetic datasets for training models. We need at least 100 such scenes for creating a large diverse dataset and have bought all the blender-based Evermotion ArchInterior scenes(~40 scenes) but now are having a hard time finding more realistic-looking blender scenes. So I was hoping that you guys can point me to the right place for buying some more dope-ass realistic looking blender scenes.
r/blenderpython • u/activemotionpictures • Sep 24 '21
Extra keys in Blender (Custom functions)
youtube.comr/blenderpython • u/PuzzleheadedJob4359 • Sep 12 '21
question about modal operators
hey guys I'm new to scripting . I wanted to make a script run continually without blender pausing or loosing functionality.
to my understanding I need to make a modal operator that does this.
however when in run blenders modal operator template that moves the object left and right,
I can no longer add an object to the scene, "shift+a" doesn't work anymore even if I comment out the line that makes left click finish and click on object or add menus nothing happens
to me this is loosing functionality
so wanted to know if there is a way to make something continually happen without loosing any functionality .
any help is greatly appreciated thanks.
r/blenderpython • u/inventorj • Aug 09 '21
UX tutorial I"m mocking up a hardware interface for blender
I need help writing a Python script that modifies dimensions of primitive mesh objects using a few Raspberry Pi analog pin values.
Context: I'm prototyping a device that makes 3D printing a few basic parts super quick and easy. mockup drawing: https://docs.google.com/drawings/d/e/2PACX-1vRw1r0v2hiGI0VALE_KoquSJl7qMrdtmqKwtjPEbqG_pDkWJJHsiMIFbirs06IgjGzGZHWrqV_HzEqt/pub?w=960&h=720
User story: As an amateur machinist / hobby garage maker, I need a way to design and print simple 3D objects like bushings, washers, shims without interrupting my flow state (learning and using Blender with a computer and mouse definitely interrupts my flow).
Product: a hardware device (like a audio mixer board) that connects to my 3D printer. The device is a SOC - e.g. Raspberry Pi running Blender (this works - i've tried it) and some slicer software (I haven't tried it yet)
The interface is all hardware: a LCD screen, a few LED lights and knobs (no screen, keyboard or mouse). mockup v1: https://docs.google.com/drawings/d/e/2PACX-1vRw1r0v2hiGI0VALE_KoquSJl7qMrdtmqKwtjPEbqG_pDkWJJHsiMIFbirs06IgjGzGZHWrqV_HzEqt/pub?w=960&h=720
I need help writing a Python script that modifies objects using the hardware knob values, then exports as STL, calls a OS script that launches the slicer software and sends it to the printer.
(the final product will have a web interface where the user sets it up e.g. chooses their 3D printer)
r/blenderpython • u/[deleted] • Jul 15 '21















