← All ideas
  • Published 8 Aug 2023

When adding new primitives, scale them so they always fit in the viewport

Wanna add a new part to that tiny gun you're working on? Here's cube that's 2x2m!

There should be an option to make newly added primitives scale to the zoom level of your viewport, so you don't have to fiddle around with them every time.

This is how I hacked it thogether in pyton. Take the view_distance of the camera and divide by 10 and set that as the size of the primitive.

view_distance = context.area.spaces.active.region_3d.view_distance

bpy.ops.mesh.primitive_plane_add(size=(view_distance/10), align='CURSOR')

I've also made the primitives align to the rotaton of the 3D cursor, which could also be a nice feature. Although the 3D cursor itself doesn't rotate unless you change your keybind settings, so... yeah.

100%

Development Status: Open

Upvote 6 Downvote 0
tolkfan
8 Aug 2023

10 Comments

Dangry

This would be an amazing feature to have by default! It's something I've wanted for years! I did not know you could do that with Python so easily.

I tested the script, and it works well. However, I don't get the pop-up menu with all the properties like in the video. Could you please share the full script? I would be forever grateful!

1
tolkfan Author

Sure, here you go: pastebin.com/40KcCsP8

I edited Blender/3.6/scripts/startup/bl_ui/space_view3d.py temporarily inside Blender's text editor to get it working. I'm not sure how to get it working properly and permanently (like as an addon that will overwrite VIEW3D_MT_mesh_add ). I guess you could just overwrite space_view3d.py , but that seems like a bad idea.

Play around with the number you divide view_distance by, because I don't think I got the proper proportions for all the primitives.

Remember that you also have to go into your keybindings and change the 3D cursor options to Surface Project and Geometry .

1
Dangry

Thank you so much for taking the time to share it! I really appreciate it! :)

Dangry

I added this feature to the ND Primitive add-on: extensions.blender.org/add-ons/non-destructive-primitives/

Omer-Almadani

When you add primitives there is already an option in the F9 menu to align to 3D cursor.

1
thinsoldier

learn something new every day

TheRedWaxPolice

That's what the add primitives tool is for, no?

If only it worked in sculpt mode... hehehe

1
tolkfan Author

Ok, I kinda forgot that existed... But it seems abandoned, there's no torus, no grid/plane, and each primitive is a separate tool so you waste time switching. I think most people just use the Add menu.

4
thorn

I use the BSMax addon for most primitives, as they all can be readjusted at any time after the initial creation.

Dangry

I just added this functionality to my first addon, its really nice to use! Hope it can be added by default some day. blenderartists.org/t/key-ops-toolkit-open-alpha/1517413