Skip to main content
added 182 characters in body
Source Link

This is a year later but I wanted to propose a solution I came across online to this problem. Other solutions here have proposed math calculations to "get around" this issue, but there is actually a solution. (Kinda)

Basically, from my understanding, regardless of what you set the pivot/orient_type to, in EDIT mode Blender will always perform that transformation as Median Point.

What you want to do is override the context, so that it performs the transformation over the cursor (or your specified pivot) instead of this default median point.

Source of where I first came across this solution

Credit to Garrett:

Overriding the context can be done like this:

def get_override(area_type, region_type):
    for area in bpy.context.screen.areas: 
        if area.type == area_type:             
            for region in area.regions:                 
                if region.type == region_type:                    
                    override = {'area': area, 'region': region} 
                    return override
    #error message if the area or region wasn't found
    raise RuntimeError("Wasn't able to find", region_type," in area ", area_type,
                        "\n Make sure it's open while executing script.")


#we need to override the context of our operator    
override = get_override( 'VIEW_3D', 'WINDOW' )
#rotate about the X-axis by 45 degrees
bpy.ops.transform.rotate(override, value=6.283/8, axis=(1,0,0)) 

Then, whatever your transformation is, pass in override as the first argument:

bpy.context.tool_settings.transform_pivot_point = "CURSOR" 
bpy.ops.transform.resize(override,value=(0.95, 0.95, 0.95))

Also, it should be noted that this means that when you run the script, it requires a visible 3D Viewer to be present.

This is a year later but I wanted to propose a solution I came across online to this problem. Other solutions here have proposed math calculations to "get around" this issue, but there is actually a solution. (Kinda)

Basically, from my understanding, regardless of what you set the pivot/orient_type to, in EDIT mode Blender will always perform that transformation as Median Point.

What you want to do is override the context, so that it performs the transformation over the cursor (or your specified pivot) instead of this default median point.

Source of where I first came across this solution

Credit to Garrett:

Overriding the context can be done like this:

def get_override(area_type, region_type):
    for area in bpy.context.screen.areas: 
        if area.type == area_type:             
            for region in area.regions:                 
                if region.type == region_type:                    
                    override = {'area': area, 'region': region} 
                    return override
    #error message if the area or region wasn't found
    raise RuntimeError("Wasn't able to find", region_type," in area ", area_type,
                        "\n Make sure it's open while executing script.")


#we need to override the context of our operator    
override = get_override( 'VIEW_3D', 'WINDOW' )
#rotate about the X-axis by 45 degrees
bpy.ops.transform.rotate(override, value=6.283/8, axis=(1,0,0)) 

Then, whatever your transformation is, pass in override as the first argument:

bpy.ops.transform.resize(override,value=(0.95, 0.95, 0.95))

This is a year later but I wanted to propose a solution I came across online to this problem. Other solutions here have proposed math calculations to "get around" this issue, but there is actually a solution. (Kinda)

Basically, from my understanding, regardless of what you set the pivot/orient_type to, in EDIT mode Blender will always perform that transformation as Median Point.

What you want to do is override the context, so that it performs the transformation over the cursor (or your specified pivot) instead of this default median point.

Source of where I first came across this solution

Credit to Garrett:

Overriding the context can be done like this:

def get_override(area_type, region_type):
    for area in bpy.context.screen.areas: 
        if area.type == area_type:             
            for region in area.regions:                 
                if region.type == region_type:                    
                    override = {'area': area, 'region': region} 
                    return override
    #error message if the area or region wasn't found
    raise RuntimeError("Wasn't able to find", region_type," in area ", area_type,
                        "\n Make sure it's open while executing script.")


#we need to override the context of our operator    
override = get_override( 'VIEW_3D', 'WINDOW' )
#rotate about the X-axis by 45 degrees
bpy.ops.transform.rotate(override, value=6.283/8, axis=(1,0,0)) 

Then, whatever your transformation is, pass in override as the first argument:

bpy.context.tool_settings.transform_pivot_point = "CURSOR" 
bpy.ops.transform.resize(override,value=(0.95, 0.95, 0.95))

Also, it should be noted that this means that when you run the script, it requires a visible 3D Viewer to be present.

added 5 characters in body
Source Link

This is a year later but I wanted to propose a solution I came across online to this problem. Other solutions here have proposed math calculations to "get around" this issue, but there is actually a solution. (Kinda)

Basically, from my understanding, regardless of what you set the pivot/orient_type to, in EDIT mode Blender will always perform that transformation as Median Point.

What you want to do is override the context, so that it performs the transformation over the cursor (or your specified pivot) instead of this default median point.

[Source of where I first came across this solution][1]Source of where I first came across this solution

Credit to [Garrett][2]Garrett:

Overriding the context can be done like this:

def get_override(area_type, region_type):
    for area in bpy.context.screen.areas: 
        if area.type == area_type:             
            for region in area.regions:                 
                if region.type == region_type:                    
                    override = {'area': area, 'region': region} 
                    return override
    #error message if the area or region wasn't found
    raise RuntimeError("Wasn't able to find", region_type," in area ", area_type,
                        "\n Make sure it's open while executing script.")


#we need to override the context of our operator    
override = get_override( 'VIEW_3D', 'WINDOW' )
#rotate about the X-axis by 45 degrees
bpy.ops.transform.rotate(override, value=6.283/8, axis=(1,0,0)) 

Then, whatever your transformation is, pass in override as the first argument:

bpy.ops.transform.resize(override,value=(0.95, 0.95, 0.95))


  [1]: https://blenderartists.org/t/how-to-bpy-ops-transform-resize-in-edit-mode-using-pivot/560381
  [2]: https://blender.stackexchange.com/questions/6969/rotate-object-around-cursor-with-python

This is a year later but I wanted to propose a solution I came across online to this problem. Other solutions here have proposed math calculations to "get around" this issue, but there is actually a solution. (Kinda)

Basically, from my understanding, regardless of what you set the pivot/orient_type to, in EDIT mode Blender will always perform that transformation as Median Point.

What you want to do is override the context, so that it performs the transformation over the cursor (or your specified pivot) instead of this default median point.

[Source of where I first came across this solution][1]

Credit to [Garrett][2]:

Overriding the context can be done like this:

def get_override(area_type, region_type):
    for area in bpy.context.screen.areas: 
        if area.type == area_type:             
            for region in area.regions:                 
                if region.type == region_type:                    
                    override = {'area': area, 'region': region} 
                    return override
    #error message if the area or region wasn't found
    raise RuntimeError("Wasn't able to find", region_type," in area ", area_type,
                        "\n Make sure it's open while executing script.")


#we need to override the context of our operator    
override = get_override( 'VIEW_3D', 'WINDOW' )
#rotate about the X-axis by 45 degrees
bpy.ops.transform.rotate(override, value=6.283/8, axis=(1,0,0)) 

Then, whatever your transformation is, pass in override as the first argument:

bpy.ops.transform.resize(override,value=(0.95, 0.95, 0.95))


  [1]: https://blenderartists.org/t/how-to-bpy-ops-transform-resize-in-edit-mode-using-pivot/560381
  [2]: https://blender.stackexchange.com/questions/6969/rotate-object-around-cursor-with-python

This is a year later but I wanted to propose a solution I came across online to this problem. Other solutions here have proposed math calculations to "get around" this issue, but there is actually a solution. (Kinda)

Basically, from my understanding, regardless of what you set the pivot/orient_type to, in EDIT mode Blender will always perform that transformation as Median Point.

What you want to do is override the context, so that it performs the transformation over the cursor (or your specified pivot) instead of this default median point.

Source of where I first came across this solution

Credit to Garrett:

Overriding the context can be done like this:

def get_override(area_type, region_type):
    for area in bpy.context.screen.areas: 
        if area.type == area_type:             
            for region in area.regions:                 
                if region.type == region_type:                    
                    override = {'area': area, 'region': region} 
                    return override
    #error message if the area or region wasn't found
    raise RuntimeError("Wasn't able to find", region_type," in area ", area_type,
                        "\n Make sure it's open while executing script.")


#we need to override the context of our operator    
override = get_override( 'VIEW_3D', 'WINDOW' )
#rotate about the X-axis by 45 degrees
bpy.ops.transform.rotate(override, value=6.283/8, axis=(1,0,0)) 

Then, whatever your transformation is, pass in override as the first argument:

bpy.ops.transform.resize(override,value=(0.95, 0.95, 0.95))

added 75 characters in body
Source Link

This is a year later but I wanted to propose a solution I came across online to this problem. Other solutions here have proposed math calculations to "get around" this issue, but there is actually a solution. (Kinda)

Basically, from my understanding, regardless of what you set the pivot/orient_type to, in EDIT mode Blender will always perform that transformation as Median Point.

What you want to do is override the context, so that it performs the transformation over the cursor (or your specified pivot) instead of this default median point.

[https://blenderartists.org/t/how-to-bpy-ops-transform-resize-in-edit-mode-using-pivot/560381][Source of where I first came across this solution][1]

Credit to Garrett: [https[Garrett][2]://blender.stackexchange.com/questions/6969/rotate-object-around-cursor-with-python]

Overriding the context can be done like this:

def get_override(area_type, region_type):
    for area in bpy.context.screen.areas: 
        if area.type == area_type:             
            for region in area.regions:                 
                if region.type == region_type:                    
                    override = {'area': area, 'region': region} 
                    return override
    #error message if the area or region wasn't found
    raise RuntimeError("Wasn't able to find", region_type," in area ", area_type,
                        "\n Make sure it's open while executing script.")


#we need to override the context of our operator    
override = get_override( 'VIEW_3D', 'WINDOW' )
#rotate about the X-axis by 45 degrees
bpy.ops.transform.rotate(override, value=6.283/8, axis=(1,0,0)) 

Then, whatever your transformation is, pass in override as the first argument:

bpy.ops.transform.resize(override,value=(0.95, 0.95, 0.95))


  [1]: https://blenderartists.org/t/how-to-bpy-ops-transform-resize-in-edit-mode-using-pivot/560381
  [2]: https://blender.stackexchange.com/questions/6969/rotate-object-around-cursor-with-python

This is a year later but I wanted to propose a solution I came across online to this problem. Other solutions here have proposed math calculations to "get around" this issue, but there is actually a solution. (Kinda)

Basically, from my understanding, regardless of what you set the pivot/orient_type to, in EDIT mode Blender will always perform that transformation as Median Point.

What you want to do is override the context, so that it performs the transformation over the cursor (or your specified pivot) instead of this default median point.

[https://blenderartists.org/t/how-to-bpy-ops-transform-resize-in-edit-mode-using-pivot/560381]

Credit to Garrett: [https://blender.stackexchange.com/questions/6969/rotate-object-around-cursor-with-python]

Overriding the context can be done like this:

def get_override(area_type, region_type):
    for area in bpy.context.screen.areas: 
        if area.type == area_type:             
            for region in area.regions:                 
                if region.type == region_type:                    
                    override = {'area': area, 'region': region} 
                    return override
    #error message if the area or region wasn't found
    raise RuntimeError("Wasn't able to find", region_type," in area ", area_type,
                        "\n Make sure it's open while executing script.")


#we need to override the context of our operator    
override = get_override( 'VIEW_3D', 'WINDOW' )
#rotate about the X-axis by 45 degrees
bpy.ops.transform.rotate(override, value=6.283/8, axis=(1,0,0)) 

Then, whatever your transformation is, pass in override as the first argument:

bpy.ops.transform.resize(override,value=(0.95, 0.95, 0.95))

This is a year later but I wanted to propose a solution I came across online to this problem. Other solutions here have proposed math calculations to "get around" this issue, but there is actually a solution. (Kinda)

Basically, from my understanding, regardless of what you set the pivot/orient_type to, in EDIT mode Blender will always perform that transformation as Median Point.

What you want to do is override the context, so that it performs the transformation over the cursor (or your specified pivot) instead of this default median point.

[Source of where I first came across this solution][1]

Credit to [Garrett][2]:

Overriding the context can be done like this:

def get_override(area_type, region_type):
    for area in bpy.context.screen.areas: 
        if area.type == area_type:             
            for region in area.regions:                 
                if region.type == region_type:                    
                    override = {'area': area, 'region': region} 
                    return override
    #error message if the area or region wasn't found
    raise RuntimeError("Wasn't able to find", region_type," in area ", area_type,
                        "\n Make sure it's open while executing script.")


#we need to override the context of our operator    
override = get_override( 'VIEW_3D', 'WINDOW' )
#rotate about the X-axis by 45 degrees
bpy.ops.transform.rotate(override, value=6.283/8, axis=(1,0,0)) 

Then, whatever your transformation is, pass in override as the first argument:

bpy.ops.transform.resize(override,value=(0.95, 0.95, 0.95))


  [1]: https://blenderartists.org/t/how-to-bpy-ops-transform-resize-in-edit-mode-using-pivot/560381
  [2]: https://blender.stackexchange.com/questions/6969/rotate-object-around-cursor-with-python
Source Link
Loading