[Bf-python] Scale in object_mode loss edges length

Campbell Barton ideasman42 at gmail.com
Mon Apr 20 03:59:43 CEST 2015


Normally if you want to scale in Python, its more flexible to
matrix-transform the data directly.

::
    scale_mat = mathutils.Matrix.Scale(myscale, 4)
    mesh.transform(scale_mat)

You can construct a matrix transform/rotate/scale, and can operate on
data, without first having to setup edit-mode.

We have this all data types.

http://www.blender.org/api/blender_python_api_2_74_release/bmesh.types.html?highlight=transform#bmesh.types.BMesh.transform

http://www.blender.org/api/blender_python_api_2_74_release/bpy.types.Armature.html?highlight=transform#bpy.types.Armature.transform

http://www.blender.org/api/blender_python_api_2_74_release/bpy.types.Curve.html?highlight=transform#bpy.types.Curve.transform

... do an API search for 'transform' to see all.



On Wed, Apr 15, 2015 at 1:17 AM, Jenny <caretdashcaret at gmail.com> wrote:
> Hi Giuseppe,
>
> I'm not sure if you'd asked a question in your last email, so I didn't
> respond.
> However, I just took a look again, and it seems you have.
>
> I don't think there's a way to invoke the scale helper via the Python API.
> If you want something more custom, you might need to check out the C/C++
> source. https://developer.blender.org/diffusion/B/
>
> If you want to set custom pivots, check out
> http://blender.stackexchange.com/questions/5359/how-to-set-cursor-location-pivot-point-in-script
>
> -Jenny
>
> On Tue, Apr 7, 2015 at 5:33 AM, Giuseppe De Marco <demarcog83 at gmail.com>
> wrote:
>>
>> > From: Jenny <caretdashcaret at gmail.com>
>>
>> > Take a look at `Apply Object transformations`:
>> >
>> > http://wiki.blender.org/index.php/Doc:2.6/Manual/3D_interaction/Transform_Control/Reset_Object_Transformations
>>
>> Thank you, never seen it before ! Very exaustive.
>>
>> > For scaling, after you scale, you can call:
>> > bpy.ops.object.transform_apply(location=False, rotation=False,
>> > scale=True)
>>
>> Ok, this is the method that apply transformation as the UI. I saw in
>> API and tested it in console without knowing conceptually what it
>> really does.
>>
>> > I don't think it's great to intercept keystrokes. I think the reason why
>> > people might be frustrated (why scaling in Object mode doesn't behave as
>> > they expect) comes from a lack of understanding of how the tools work.
>>
>> You're right, together with the possibility that a user could
>> customize his shortcuts in every moment.
>> First of all I learned how to apply the transformation in object mode,
>> this is very important.
>>
>> But, talking in python, if a day there will be the need to know this,
>> how to call, from pycode, the mouse pointer with the pivot point for
>> configuring the desidered value ? ... As the scale UI function does.
>> How to call the scale function, from console, in a way that it's as we
>> called it from UI.
>> _______________________________________________
>> Bf-python mailing list
>> Bf-python at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-python
>
>
>
> _______________________________________________
> Bf-python mailing list
> Bf-python at blender.org
> http://lists.blender.org/mailman/listinfo/bf-python
>



-- 
- Campbell



More information about the Bf-python mailing list