PDT: Merge branch 'blender-v2.93-release'

This commit is contained in:
Rune Morling 2021-05-17 19:45:01 +02:00
commit 4e86d98e38
8 changed files with 189 additions and 63 deletions

View File

@ -1403,15 +1403,15 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties):
bl_idname = "wm.blenderkit_asset_popup"
bl_label = "BlenderKit asset popup"
width = 700
width = 800
@classmethod
def poll(cls, context):
return True
def draw_menu(self, context, layout):
col = layout.column()
draw_asset_context_menu(col, context, self.asset_data, from_panel=False)
# layout = layout.column()
draw_asset_context_menu(layout, context, self.asset_data, from_panel=False)
def draw_property(self, layout, left, right, icon=None, icon_value=None, url='', tooltip=''):
right = str(right)
@ -1442,6 +1442,13 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties):
parameter = f"{parameter:,.1f}"
self.draw_property(layout, pretext, parameter)
def draw_description(self, layout, width = 250):
if len(self.asset_data['description']) > 0:
box = layout.box()
box.scale_y = 0.8
box.label(text='Description')
utils.label_multiline(box, self.asset_data['description'], width=width)
def draw_properties(self, layout, width=250):
if type(self.asset_data['parameters']) == list:
@ -1449,13 +1456,6 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties):
else:
mparams = self.asset_data['parameters']
layout = layout.column()
if len(self.asset_data['description']) > 0:
box = layout.box()
box.scale_y = 0.8
box.label(text='Description')
utils.label_multiline(box, self.asset_data['description'], width=width)
pcoll = icons.icon_collections["main"]
box = layout.box()
@ -1644,7 +1644,7 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties):
utils.label_multiline(col, text=a['tooltip'], width=text_width)
# check if author didn't fill any data about himself and prompt him if that's the case
if upload.user_is_owner(asset_data=self.asset_data) and a.get('aboutMe') is not None and len(
if utils.user_is_owner(asset_data=self.asset_data) and a.get('aboutMe') is not None and len(
a.get('aboutMe', '')) == 0:
row = col.row()
row.enabled = False
@ -1673,14 +1673,13 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties):
op.keywords = ''
op.author_id = self.asset_data['author']['id']
def draw_thumbnail_box(self, layout):
def draw_thumbnail_box(self, layout, width = 250):
layout.emboss = 'NORMAL'
box_thumbnail = layout.box()
box_thumbnail.scale_y = .4
box_thumbnail.template_icon(icon_value=self.img.preview.icon_id, scale=34.0)
box_thumbnail.template_icon(icon_value=self.img.preview.icon_id, scale=width*.12)
# row = box_thumbnail.row()
# row.scale_y = 3
@ -1738,16 +1737,36 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties):
# left - tooltip & params
row = box.row()
split_factor = 0.7
split_left_left = row.split(factor=split_factor)
self.draw_properties(split_left_left, width=int(width * split_factor))
split_left = row.split(factor=split_factor)
col = split_left.column()
width_left = int(width * split_factor)
self.draw_description(col, width=width_left)
self.draw_properties(col, width=width_left)
# right - menu
col1 = split_left_left.split()
self.draw_menu(context, col1)
split_right = split_left.split()
col = split_right.column()
self.draw_menu(context, col)
# author
self.draw_author_area(context, box, width=width)
# self.draw_author_area(context, box, width=width)
#
# col = box.column_flow(columns=2)
# self.draw_menu(context, col)
#
#
# # self.draw_description(box, width=int(width))
# self.draw_properties(box, width=int(width))
def draw(self, context):
ui_props = context.scene.blenderkitUI
@ -1765,17 +1784,22 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties):
# left side
row = layout.row(align=True)
split_ratio = 0.5
split_left = row.split(factor=0.5)
self.draw_thumbnail_box(split_left)
split_ratio = 0.45
split_left = row.split(factor=split_ratio)
left_column = split_left.column()
self.draw_thumbnail_box(left_column, width = int(self.width * split_ratio))
# self.draw_description(left_column, width = int(self.width*split_ratio))
# right split
split_right = split_left.split()
self.draw_menu_desc_author(context, split_right, width=int(self.width * split_ratio))
self.draw_menu_desc_author(context, split_right, width=int(self.width * (1-split_ratio)))
ratings_box = layout.box()
if not utils.user_is_owner(asset_data=asset_data):
#Draw ratings, but not for owners of assets - doesn't make sense.
ratings_box = layout.box()
ratings.draw_ratings_menu(self, context, ratings_box)
# else:
# ratings_box.label('Here you should find ratings, but you can not rate your own assets ;)')
ratings.draw_ratings_menu(self, context, ratings_box)
tip_box = layout.box()
tip_box.label(text=self.tip)

View File

@ -567,14 +567,6 @@ def update_free_full(self, context):
" based on our fair share system. " \
"Part of subscription is sent to artists based on usage by paying users.")
def user_is_owner(asset_data=None):
'''Checks if the current logged in user is owner of the asset'''
profile = bpy.context.window_manager.get('bkit profile')
if profile is None:
return False
if int(asset_data['author']['id']) == int(profile['user']['id']):
return True
return False
def can_edit_asset(active_index=-1, asset_data=None):
if active_index < 0 and not asset_data:

View File

@ -784,6 +784,14 @@ def profile_is_validator():
return True
return False
def user_is_owner(asset_data=None):
'''Checks if the current logged in user is owner of the asset'''
profile = bpy.context.window_manager.get('bkit profile')
if profile is None:
return False
if int(asset_data['author']['id']) == int(profile['user']['id']):
return True
return False
def guard_from_crash():
'''

View File

@ -29,8 +29,8 @@
bl_info = {
"name": "Precision Drawing Tools (PDT)",
"author": "Alan Odom (Clockmender), Rune Morling (ermo)",
"version": (1, 4, 0),
"blender": (2, 83, 0),
"version": (1, 5, 0),
"blender": (2, 90, 0),
"location": "View3D > UI > PDT",
"description": "Precision Drawing Tools for Acccurate Modelling",
"warning": "",
@ -430,7 +430,7 @@ class PDTSceneProperties(PropertyGroup):
# Was filletrad
fillet_radius: FloatProperty(
name="Fillet Radius", min=0.0, default=1.0, description=PDT_DES_FILLETRAD
name="Fillet Radius", min=0.0, default=1.0, unit="LENGTH", description=PDT_DES_FILLETRAD
)
# Was filletnum
fillet_segments: IntProperty(
@ -454,10 +454,10 @@ class PDTSceneProperties(PropertyGroup):
name="Coordst2", default=(0.0, 0.0, 0.0), subtype="XYZ", description=PDT_DES_TANCEN2
)
tangent_radius0: FloatProperty(
name="Arc Radius 1", min=0.00001, default=1, description=PDT_DES_RADIUS1
name="Arc Radius 1", min=0.00001, default=1, unit="LENGTH", description=PDT_DES_RADIUS1
)
tangent_radius1: FloatProperty(
name="Arc Radius 2", min=0.00001, default=1, description=PDT_DES_RADIUS2
name="Arc Radius 2", min=0.00001, default=1, unit="LENGTH", description=PDT_DES_RADIUS2
)
tangent_point2: FloatVectorProperty(
name="Coordst3", default=(0.0, 0.0, 0.0), subtype="XYZ", description=PDT_DES_TANCEN3
@ -520,6 +520,7 @@ classes = (
pdt_design.PDT_OT_PlacementAbs,
pdt_design.PDT_OT_PlacementDelta,
pdt_design.PDT_OT_PlacementDis,
pdt_design.PDT_OT_PlacementView,
pdt_design.PDT_OT_PlacementCen,
pdt_design.PDT_OT_PlacementPer,
pdt_design.PDT_OT_PlacementNormal,

View File

@ -220,9 +220,9 @@ def command_run(self, context):
mode = command[1].lower()
if (
(operation == "F" and mode not in {"v", "e", "i"})
or (operation in {"D", "E"} and mode not in {"d", "i"})
or (operation in {"D", "E"} and mode not in {"d", "i", "v"}) #new
or (operation == "M" and mode not in {"a", "d", "i", "p", "o", "x", "y", "z"})
or (operation not in {"D", "E", "F", "M"} and mode not in {"a", "d", "i", "p"})
or (operation not in {"D", "E", "F", "M"} and mode not in {"a", "d", "i", "p", "v"}) #new
):
pg.error = f"'{mode}' {PDT_ERR_NON_VALID} '{operation}'"
context.window_manager.popup_menu(oops, title="Error", icon="ERROR")
@ -322,15 +322,15 @@ def pdt_help(self, context):
label = self.layout.label
label(text="Primary Letters (Available Secondary Letters):")
label(text="")
label(text="C: Cursor (a, d, i, p)")
label(text="D: Duplicate Geometry (d, i)")
label(text="E: Extrude Geometry (d, i)")
label(text="C: Cursor (a, d, i, p, v)")
label(text="D: Duplicate Geometry (d, i, v)")
label(text="E: Extrude Geometry (d, i, v)")
label(text="F: Fillet (v, e, i)")
label(text="G: Grab (Move) (a, d, i, p)")
label(text="N: New Vertex (a, d, i, p)")
label(text="G: Grab (Move) (a, d, i, p, v)")
label(text="N: New Vertex (a, d, i, p, v)")
label(text="M: Maths Functions (a, d, p, o, x, y, z)")
label(text="P: Pivot Point (a, d, i, p)")
label(text="V: Extrude Vertice Only (a, d, i, p)")
label(text="P: Pivot Point (a, d, i, p, v)")
label(text="V: Extrude Vertice Only (a, d, i, p, v)")
label(text="S: Split Edges (a, d, i, p)")
label(text="?: Quick Help")
label(text="")
@ -341,6 +341,8 @@ def pdt_help(self, context):
label(text="d: Delta (Relative) Coordinates, e.g. 0.5,0,1.2")
label(text="i: Directional (Polar) Coordinates e.g. 2.6,45")
label(text="p: Percent e.g. 67.5")
label(text="v: Work in View Normal Axis")
label(text="")
label(text="- Fillet Options:")
label(text="v: Fillet Vertices")
label(text="e: Fillet Edges")
@ -438,6 +440,19 @@ def command_parse(context):
except ValueError:
values[ind] = "0.0"
ind = ind + 1
if mode == "v":
# View relative mode
if pg.plane == "XZ":
values = [0.0, values[0], 0.0]
elif pg.plane == "YZ":
values = [values[0], 0.0, 0.0]
elif pg.plane == "XY":
values = [0.0, 0.0, values[0]]
else:
if "-" in values[0]:
values = [0.0, 0.0, values[0][1:]]
else:
values = [0.0, 0.0, f"-{values[0]}"]
# Apply System Rounding
decimal_places = context.preferences.addons[__package__].preferences.pdt_input_round
values_out = [str(round(float(v), decimal_places)) for v in values]
@ -507,7 +522,7 @@ def move_cursor_pivot(context, pg, operation, mode, obj, verts, values):
"""
# Absolute/Global Coordinates, or Delta/Relative Coordinates
if mode in {"a", "d"}:
if mode in {"a", "d", "v"}:
try:
vector_delta = vector_build(context, pg, obj, operation, values, 3)
except:
@ -537,8 +552,8 @@ def move_cursor_pivot(context, pg, operation, mode, obj, verts, values):
scene.cursor.location = vector_delta
elif operation == "P":
pg.pivot_loc = vector_delta
elif mode in {"d", "i"}:
if pg.plane == "LO" and mode == "d":
elif mode in {"d", "i", "v"}:
if pg.plane == "LO" and mode in {"d", "v"}:
vector_delta = view_coords(vector_delta.x, vector_delta.y, vector_delta.z)
elif pg.plane == "LO" and mode == "i":
vector_delta = view_dir(pg.distance, pg.angle)
@ -598,7 +613,7 @@ def move_entities(context, pg, operation, mode, obj, bm, verts, values):
except:
raise PDT_InvalidVector
if obj.mode == "EDIT":
for v in verts:
for v in [v for v in bm.verts if v.select]:
v.co = vector_delta - obj_loc
bmesh.ops.remove_doubles(
bm, verts=[v for v in bm.verts if v.select], dist=0.0001
@ -607,8 +622,8 @@ def move_entities(context, pg, operation, mode, obj, bm, verts, values):
for ob in context.view_layer.objects.selected:
ob.location = vector_delta
elif mode in {"d", "i"}:
if mode == "d":
elif mode in {"d", "i", "v"}:
if mode in {"d", "v"}:
# Delta/Relative Coordinates
try:
vector_delta = vector_build(context, pg, obj, operation, values, 3)
@ -621,7 +636,7 @@ def move_entities(context, pg, operation, mode, obj, bm, verts, values):
except:
raise PDT_InvalidVector
if pg.plane == "LO" and mode == "d":
if pg.plane == "LO" and mode in {"d", "v"}:
vector_delta = view_coords(vector_delta.x, vector_delta.y, vector_delta.z)
elif pg.plane == "LO" and mode == "i":
vector_delta = view_dir(pg.distance, pg.angle)
@ -678,7 +693,7 @@ def add_new_vertex(context, pg, operation, mode, obj, bm, verts, values):
raise PDT_InvalidVector
new_vertex = bm.verts.new(vector_delta - obj_loc)
# Delta/Relative Coordinates
elif mode == "d":
elif mode in {"d", "v"}:
try:
vector_delta = vector_build(context, pg, obj, operation, values, 3)
except:
@ -852,7 +867,7 @@ def extrude_vertices(context, pg, operation, mode, obj, obj_loc, bm, verts, valu
bm, verts=[v for v in bm.verts if v.select], dist=0.0001
)
# Delta/Relative Coordinates
elif mode == "d":
elif mode in {"d", "v"}:
try:
vector_delta = vector_build(context, pg, obj, operation, values, 3)
except:
@ -920,7 +935,7 @@ def extrude_geometry(context, pg, operation, mode, obj, bm, values):
context.window_manager.popup_menu(oops, title="Error", icon="ERROR")
return
# Delta/Relative Coordinates
if mode == "d":
if mode in {"d", "v"}:
try:
vector_delta = vector_build(context, pg, obj, operation, values, 3)
except:
@ -947,7 +962,7 @@ def extrude_geometry(context, pg, operation, mode, obj, bm, values):
faces_extr = [f for f in geom_extr if isinstance(f, bmesh.types.BMFace)]
del ret
if pg.plane == "LO" and mode == "d":
if pg.plane == "LO" and mode in {"d", "v"}:
vector_delta = view_coords(vector_delta.x, vector_delta.y, vector_delta.z)
elif pg.plane == "LO" and mode == "i":
vector_delta = view_dir(pg.distance, pg.angle)
@ -979,7 +994,7 @@ def duplicate_geometry(context, pg, operation, mode, obj, bm, values):
context.window_manager.popup_menu(oops, title="Error", icon="ERROR")
return
# Delta/Relative Coordinates
if mode == "d":
if mode in {"d", "v"}:
try:
vector_delta = vector_build(context, pg, obj, operation, values, 3)
except:
@ -1006,7 +1021,7 @@ def duplicate_geometry(context, pg, operation, mode, obj, bm, values):
faces_dupe = [f for f in geom_dupe if isinstance(f, bmesh.types.BMFace)]
del ret
if pg.plane == "LO" and mode == "d":
if pg.plane == "LO" and mode in {"d", "v"}:
vector_delta = view_coords(vector_delta.x, vector_delta.y, vector_delta.z)
elif pg.plane == "LO" and mode == "i":
vector_delta = view_dir(pg.distance, pg.angle)

View File

@ -299,6 +299,82 @@ class PDT_OT_PlacementDis(Operator):
return {"FINISHED"}
class PDT_OT_PlacementView(Operator):
"""Use Distance Input for View Normal Axis Operations"""
bl_idname = "pdt.view_axis"
bl_label = "View Normal Axis Mode"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
"""Manipulates Geometry, or Objects by View Normal Axis Offset (Increment).
Note:
- Reads pg.operation from Operation Mode Selector as 'operation'
- Reads pg.select, pg.plane, pg.cartesian_coords scene variables to:
-- set position of CUrsor (CU)
-- set position of Pivot Point (PP)
-- MoVe geometry/objects (MV)
-- Extrude Vertices (EV)
-- Split Edges (SE)
-- add a New Vertex (NV)
-- Duplicate Geometry (DG)
-- Extrude Geometry (EG)
Invalid Options result in self.report Error.
Args:
context: Blender bpy.context instance.
Returns:
Status Set.
"""
pg = context.scene.pdt_pg
operation = pg.operation
decimal_places = context.preferences.addons[__package__].preferences.pdt_input_round
if operation == "CU":
# Cursor
pg.command = (
f"cv{str(round(pg.distance, decimal_places))}"
)
elif operation == "PP":
# Pivot Point
pg.command = (
f"pv{str(round(pg.distance, decimal_places))}"
)
elif operation == "MV":
# Move Entities
pg.command = (
f"gv{str(round(pg.distance, decimal_places))}"
)
elif operation == "NV":
# New Vertex
pg.command = (
f"nv{str(round(pg.distance, decimal_places))}"
)
elif operation == "EV":
# Extrue Vertices
pg.command = (
f"vv{str(round(pg.distance, decimal_places))}"
)
elif operation == "DG":
# Duplicate Entities
pg.command = (
f"dv{str(round(pg.distance, decimal_places))}"
)
elif operation == "EG":
# Extrue Geometry
pg.command = (
f"ev{str(round(pg.distance, decimal_places))}"
)
else:
error_message = f"{operation} {PDT_ERR_NON_VALID} {PDT_LAB_DEL}"
self.report({"ERROR"}, error_message)
return {"FINISHED"}
class PDT_OT_PlacementPer(Operator):
"""Use Percentage Placement"""
@ -703,3 +779,9 @@ class PDT_OT_Taper(Operator):
pg = context.scene.pdt_pg
pg.command = f"tap"
return {"FINISHED"}
#class PDT_Extrude_Modal(Operator):
# """Extrude Modal Plane Along Normal Axis"""
# bl_idname = "pdt.extrude_modal"
# bl_label = "Extrude Modal Normal"
# bl_options = {"REGISTER", "UNDO"}

View File

@ -62,7 +62,8 @@ from .pdt_msg_strings import (
PDT_LAB_TAPERAXES,
PDT_LAB_TOOLS,
PDT_LAB_USEVERTS,
PDT_LAB_VARIABLES
PDT_LAB_VARIABLES,
PDT_LAB_VIEW
)
def ui_width():
@ -148,6 +149,8 @@ class PDT_PT_PanelDesign(Panel):
row.prop(pdt_pg, "angle", text=PDT_LAB_ANGLEVALUE)
row = box.row()
row.operator("pdt.distance", icon="EMPTY_AXIS", text=f"{PDT_LAB_DIR} »")
row.operator("pdt.view_axis", icon="EMPTY_AXIS", text=f"{PDT_LAB_VIEW} »")
row = box.row()
row.prop(pdt_pg, "flip_angle", text=PDT_LAB_FLIPANGLE)
# ---------------------
@ -437,7 +440,7 @@ class PDT_PT_PanelTangent(Panel):
row.label(text=f"Working {PDT_LAB_PLANE}:")
row.prop(pdt_pg, "plane", text="")
row = layout.row()
row.label(text="Tan Mode")
row.label(text="Tangent Mode")
row.prop(pdt_pg, "tangent_mode", text="")
row = layout.row()
row.operator("pdt.tangentoperatesel", text="Tangents from Selection", icon="NONE")
@ -448,7 +451,7 @@ class PDT_PT_PanelTangent(Panel):
box = layout.box()
row = box.row()
split = row.split(factor=0.35, align=True)
split.label(text="Tan Point")
split.label(text="Tangent Point")
split.prop(pdt_pg, "tangent_point2", text="")
row = box.row()
row.operator("pdt.tangentset3", text="from Cursor")

View File

@ -80,6 +80,7 @@ PDT_LAB_PIVOTWIDTH = "" # Intentionally left blank
PDT_LAB_PIVOTALPHA = "" # Intentionally left blank
PDT_LAB_PIVOTLOC = "" # Intentionally left blank
PDT_LAB_PIVOTLOCH = "Location"
PDT_LAB_VIEW = "View Normal Axis"
#
# Error Message
#