Page MenuHome

Object alignment dropdown in generic object_add properties
ClosedPublic

Authored by Hans Goudey (HooglyBoogly) on Apr 18 2019, 10:51 PM.
Tokens
"Like" token, awarded by eobet."Love" token, awarded by TheAngerSpecialist."Like" token, awarded by hitrpr."Burninate" token, awarded by DotBow."Like" token, awarded by capnm."Love" token, awarded by kioku."Like" token, awarded by EitanSomething."Like" token, awarded by Way.

Details

Summary


This includes the ability to orient a new object to the 3D cursor, and a Cursor setting for the initial alignment of new objects. The object_add code in C as well as in Python in object_utils.py. There is one change to the API, but it should e sufficient to just change to the alignment property's new name to make the change.

People think this is important! Here are some RCS posts about that ability:

  1. https://blender.community/c/rightclickselect/yWbbbc/ (18 votes)
  2. https://blender.community/c/rightclickselect/zKcbbc/ (27 votes)
  3. https://blender.community/c/rightclickselect/LScbbc/ (28 votes)

I consider this as more of a way to complete the 3D cursor rotation feature than a new feature, which is why I think it's worthwhile to add to 2.80 now.

This was originally D3601 written by @Pablo Dobarro (pablodp606). I added a new option to make it clear when the input rotation is used, cleaned up and updated the diff.

Diff Detail

Repository
rB Blender
Branch
master
Build Status
Buildable 3468
Build 3468: arc lint + arc unit

Event Timeline

Way awarded a token.Apr 19 2019, 2:31 AM

Changed "Input" to "Custom" like Pablo suggested. I found a few other examples of that term used in the UI, it's definitely better. Applies to latest master.

Brecht Van Lommel (brecht) requested changes to this revision.Apr 25 2019, 6:40 PM

Functionality wise seems fine.

This change will need to come along with a bunch of addon updates, since there's many addons use thing the view_align property.

source/blender/editors/object/object_add.c
403–404

Generally you should not need to lookup properties like this, and instead used simpler functions like RNA_struct_property_is_set(op->ptr, "rotation") and RNA_float_get_array(op->ptr, "rotation", rot);.

426–427

These two lines are redundant, only the first one is needed.

428

This is not correct. It's modifying the property type for all operators. To hide elements in the user interface dynamically, and ot->ui callback must be set that manually lays out the interface.

This revision now requires changes to proceed.Apr 25 2019, 6:40 PM

Thanks for looking at this Brecht!

I'm happy to update addons. I've already changed a couple other places where the old view_align prop was used. I'll include them in an update for this patch.

Also, what do you think about adding a USER_ADD_CURSORALIGNED setting for new objects? There are already WORLD and VIEW settings, so it might make sense to add CURSOR for completeness.

source/blender/editors/object/object_add.c
403–404

Cool, I thought it might be worth it to just search for it once and use the pointer afterwards, but I wasn't sure.

428

Alright, so dynamically modifying whether the rotation property is shown is probably not worth it for this patch, as it would require refactoring the property adding (add_generic_props, etc...) to a less generic function just for OBJECT_OT_add.

It's not a big deal to have them hide anyway. I could even see how it would be annoying to have the location of the properties change.

Resolved problems, updated object_utils.py, removed WORLD option

I fixed the problems that Brecht mentioned in his review, and fixed a few other bugs that came up.

  • The new objects view align setting now works
  • Torus alignment now works
  • Converted instances of the old "view_align" property to the "object_align" property.
  • I also removed the WORLD option. I couldn't see anyone selecting it just to have their rotation stuck at 0.

It's very easy to update addons. For Bolt Factory I only had to change align_view to object_align. It looks like that change didn't get included in this patch though.

In the future, it would be nice to have a way to show that the rotation property is locked by the alignment setting (when it's VIEW or CURSOR), but I think that's out of the scope of this patch.

Hans Goudey (HooglyBoogly) marked 3 inline comments as done.May 1 2019, 12:54 AM
release/scripts/modules/bpy_extras/object_utils.py
174

I wasn't quite sure where to define these items, but I think this works well enough.

It's possible that there should be a shared definition between here and object_add.c though.

  • Added Object Add 3D Cursor Align preference to go along with the view align preference.
  • Simplified change in add_object_align_init.
  • object_utils.py object add helper obeys object add view align preference now.
  • Changed Custom to World alignment. It's clear that it's adjustable because it's the default and it's a less confusing word.

Forgot to change CUSTOM to WORLD in two places.

Hi @Brecht Van Lommel (brecht). I wanted to remind you about this patch in case it had fallen off your radar. It would probably be good to get it in sooner rather than later because of the small change to the python API it includes.

I just checked and it still applies fine. If there's any other change to make to it I'd be happy to fix it.

I'll commit this with some tweaks and updated add-ons.

source/blender/editors/object/object_add.c
316

Not sure why skip save was added here, assuming it was not intentional and removed.

This revision is now accepted and ready to land.May 15 2019, 6:10 PM
This revision was automatically updated to reflect the committed changes.

Awesome! Thanks!

Yeah, I didn't mean to keep the skip save in.