Skip to content
Snippets Groups Projects
Commit 7580e19b authored by lijenstina's avatar lijenstina
Browse files

Add Advanced Objects: Fix pixelate properties error

Bumped the Menu to 1.1.5
Fixed the ommission during the refactor
Scene properties cannot be used inside an Operator
replaced them with the self ones
Removed the pixelate properties from init as not needed
Fix the error related to moving drop to ground to a
separate add-on - if it is not enabled it will error out
No need for a duplicate entry
parent c81a6e1b
No related branches found
No related tags found
No related merge requests found
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
bl_info = { bl_info = {
"name": "Add Advanced Objects", "name": "Add Advanced Objects",
"author": "Meta Androcto", "author": "Meta Androcto",
"version": (0, 1, 4), "version": (0, 1, 5),
"blender": (2, 78, 0), "blender": (2, 78, 0),
"location": "View3D > Add ", "location": "View3D > Add ",
"description": "Add Object & Camera extras", "description": "Add Object & Camera extras",
...@@ -179,8 +179,7 @@ class INFO_MT_Physics_tools_add(Menu): ...@@ -179,8 +179,7 @@ class INFO_MT_Physics_tools_add(Menu):
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN' layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator("object.drop_on_active",
text="Drop To Ground", icon="SORTSIZE")
layout.operator("ball.rope", layout.operator("ball.rope",
text="Wrecking Ball", icon='PHYSICS') text="Wrecking Ball", icon='PHYSICS')
layout.operator("clot.rope", layout.operator("clot.rope",
...@@ -249,7 +248,7 @@ class AdvancedObjPreferences(AddonPreferences): ...@@ -249,7 +248,7 @@ class AdvancedObjPreferences(AddonPreferences):
box.label(text="Panels located in 3D View Tools Region > Create", box.label(text="Panels located in 3D View Tools Region > Create",
icon="LAYER_ACTIVE") icon="LAYER_ACTIVE")
box.label(text="CubeSter", icon="LAYER_USED") box.label(text="CubeSter", icon="LAYER_USED")
box.label(text="Duplicate on Curve (Shown if an Active Curve Object is it the 3D View)", box.label(text="Arrange on Curve (Shown if an Active Curve Object is it the 3D View)",
icon="LAYER_USED") icon="LAYER_USED")
...@@ -498,26 +497,6 @@ class AdvancedObjProperties(PropertyGroup): ...@@ -498,26 +497,6 @@ class AdvancedObjProperties(PropertyGroup):
default=0.25 default=0.25
) )
# pixelate_3d properties
pixelate_3d_size = FloatProperty(
name="Size",
min=.05, max=5,
default=.25,
description="Size of the cube / grid"
)
pixelate_3d_gap = IntProperty(
name="Gap",
min=0, max=90,
default=10,
subtype='PERCENTAGE',
description="Separation - percent of size"
)
pixelate_3d_smooth = FloatProperty(
name="Smooth",
min=0, max=1,
default=.0,
description="Smooth factor when subdividing mesh"
)
# arrange_on_curve # arrange_on_curve
arrange_c_use_selected = BoolProperty( arrange_c_use_selected = BoolProperty(
name="Use Selected", name="Use Selected",
......
...@@ -4,22 +4,25 @@ ...@@ -4,22 +4,25 @@
bl_info = { bl_info = {
"name": "3D Pixelate", "name": "3D Pixelate",
"author": "liero", "author": "liero",
"version": (0, 5, 2), "version": (0, 5, 3),
"blender": (2, 74, 0), "blender": (2, 74, 0),
"location": "View3D > Tool Shelf", "location": "View3D > Tool Shelf",
"description": "Creates a 3d pixelated version of the object", "description": "Creates a 3d pixelated version of the object",
"category": "Object"} "category": "Object"}
# Note: winmgr properties are moved into __init__ # Note: winmgr properties are moved to the operator
# search for patterns advanced_objects and adv_obj
import bpy import bpy
from bpy.types import Operator from bpy.types import Operator
from bpy.props import (
FloatProperty,
IntProperty,
)
def pix(obj): def pix(self, obj):
sce = bpy.context.scene sce = bpy.context.scene
props = sce.advanced_objects
obj.hide = obj.hide_render = True obj.hide = obj.hide_render = True
mes = obj.to_mesh(sce, True, 'RENDER') mes = obj.to_mesh(sce, True, 'RENDER')
mes.transform(obj.matrix_world) mes.transform(obj.matrix_world)
...@@ -34,12 +37,12 @@ def pix(obj): ...@@ -34,12 +37,12 @@ def pix(obj):
fin = True fin = True
for i in dup.data.edges: for i in dup.data.edges:
d = ver[i.vertices[0]].co - ver[i.vertices[1]].co d = ver[i.vertices[0]].co - ver[i.vertices[1]].co
if d.length > props.pixelate_3d_size: if d.length > self.size:
ver[i.vertices[0]].select = True ver[i.vertices[0]].select = True
ver[i.vertices[1]].select = True ver[i.vertices[1]].select = True
fin = False fin = False
bpy.ops.object.editmode_toggle() bpy.ops.object.editmode_toggle()
bpy.ops.mesh.subdivide(number_cuts=1, smoothness=props.pixelate_3d_smooth) bpy.ops.mesh.subdivide(number_cuts=1, smoothness=self.smooth)
bpy.ops.mesh.select_all(action='DESELECT') bpy.ops.mesh.select_all(action='DESELECT')
bpy.ops.object.editmode_toggle() bpy.ops.object.editmode_toggle()
if fin: if fin:
...@@ -47,14 +50,14 @@ def pix(obj): ...@@ -47,14 +50,14 @@ def pix(obj):
for i in ver: for i in ver:
for n in range(3): for n in range(3):
i.co[n] -= (.001 + i.co[n]) % props.pixelate_3d_size i.co[n] -= (.001 + i.co[n]) % self.size
bpy.ops.object.mode_set(mode='EDIT', toggle=False) bpy.ops.object.mode_set(mode='EDIT', toggle=False)
bpy.ops.mesh.select_all(action='SELECT') bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.mesh.remove_doubles(threshold=0.0001) bpy.ops.mesh.remove_doubles(threshold=0.0001)
bpy.ops.mesh.delete(type='EDGE_FACE') bpy.ops.mesh.delete(type='EDGE_FACE')
bpy.ops.object.mode_set() bpy.ops.object.mode_set()
sca = props.pixelate_3d_size * (100 - props.pixelate_3d_gap) * .005 sca = self.size * (100 - self.gap) * .005
bpy.ops.mesh.primitive_cube_add(layers=[True] + [False] * 19) bpy.ops.mesh.primitive_cube_add(layers=[True] + [False] * 19)
bpy.ops.transform.resize(value=[sca] * 3) bpy.ops.transform.resize(value=[sca] * 3)
bpy.context.scene.objects.active = dup bpy.context.scene.objects.active = dup
...@@ -70,6 +73,27 @@ class Pixelate(Operator): ...@@ -70,6 +73,27 @@ class Pixelate(Operator):
"Needs an existing Active Mesh Object") "Needs an existing Active Mesh Object")
bl_options = {'REGISTER', 'UNDO'} bl_options = {'REGISTER', 'UNDO'}
size = FloatProperty(
name="Size",
min=.05, max=5,
default=.25,
description="Size of the cube / grid \n"
"Small values (below 0.1) can create a high polygon count"
)
gap = IntProperty(
name="Gap",
min=0, max=90,
default=10,
subtype='PERCENTAGE',
description="Separation - percent of size"
)
smooth = FloatProperty(
name="Smooth",
min=0, max=1,
default=.0,
description="Smooth factor when subdividing mesh"
)
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return (context.active_object and return (context.active_object and
...@@ -78,17 +102,16 @@ class Pixelate(Operator): ...@@ -78,17 +102,16 @@ class Pixelate(Operator):
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
adv_obj = context.scene.advanced_objects
col = layout.column(align=True) col = layout.column(align=True)
col.prop(adv_obj, "pixelate_size") col.prop(self, "size")
col.prop(adv_obj, "pixelate_gap") col.prop(self, "gap")
layout.prop(adv_obj, "pixelate_smooth") layout.prop(self, "smooth")
def execute(self, context): def execute(self, context):
objeto = context.active_object objeto = bpy.context.object
try: try:
pix(objeto) pix(self, objeto)
except Exception as e: except Exception as e:
self.report({'WARNING'}, self.report({'WARNING'},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment