From 1d5837400d0bc55862b082065b3594996aa5f4d4 Mon Sep 17 00:00:00 2001 From: Alan Odom Date: Thu, 13 Feb 2020 08:28:29 +0000 Subject: PDT: Add user-requested Tangent Functions (new feature) This Branch is WIP, still in development and not yet suitable for a release. This process will add the ability to draw tangents from a point to an arc, or circle. It will also add the ability to draw tangents, both inner and outer, between two arcs. Arc centres and radii can be manually input into the UI, or set from three vertices that lie on an imaginary arc. Tangent functions have their own PDT Sub-menu. This commit only works in Front view, to get the maths right, later commits will expand this into any view orientation, using existing PDT code. This commit does not contain DocStrings for the new pdt_tangent.py file, these will also follow in a later commit. It is recommended that this commit is not used in a production environment. Once complete, a new version Branch will be added, at this point the code will reach Alpha status and be appropriate for extensive user testing. --- precision_drawing_tools/__init__.py | 28 +++++++++++++++++++++ precision_drawing_tools/pdt_menus.py | 39 ++++++++++++++++++++++++++++++ precision_drawing_tools/pdt_msg_strings.py | 6 +++++ 3 files changed, 73 insertions(+) (limited to 'precision_drawing_tools') diff --git a/precision_drawing_tools/__init__.py b/precision_drawing_tools/__init__.py index b64a164c..298b2d9c 100644 --- a/precision_drawing_tools/__init__.py +++ b/precision_drawing_tools/__init__.py @@ -53,6 +53,7 @@ if "bpy" in locals(): importlib.reload(pdt_xall) importlib.reload(pdt_bix) importlib.reload(pdt_etof) + importlib.reload(pdt_tangent) else: from . import pdt_design from . import pdt_pivot_point @@ -62,6 +63,7 @@ else: from . import pdt_xall from . import pdt_bix from . import pdt_etof + from . import pdt_tangent import bpy import os @@ -108,6 +110,12 @@ from .pdt_msg_strings import ( PDT_DES_TRIM, PDT_DES_VALIDLET, PDT_DES_WORPLANE, + PDT_DES_TANCEN1, + PDT_DES_TANCEN2, + PDT_DES_TANCEN3, + PDT_DES_RADIUS1, + PDT_DES_RADIUS2, + PDT_DES_TPOINT, ) from .pdt_command import command_run from .pdt_functions import scale_set @@ -389,6 +397,22 @@ class PDTSceneProperties(PropertyGroup): fillet_intersect: BoolProperty( name="Intersect", default=False, description=PDT_DES_FILLINT, ) + tangent_point0: FloatVectorProperty( + name="Coordst1", default=(0.0, 0.0, 0.0), subtype="XYZ", description=PDT_DES_TANCEN1 + ) + tangent_point1: FloatVectorProperty( + 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 + ) + tangent_radius1: FloatProperty( + name="Arc Radius 2", min=0.00001, default=1, description=PDT_DES_RADIUS2 + ) + tangent_point2: FloatVectorProperty( + name="Coordst3", default=(0.0, 0.0, 0.0), subtype="XYZ", description=PDT_DES_TANCEN3 + ) + tangent_from_point: BoolProperty(name="From Point", default=False, description=PDT_DES_TPOINT) class PDTPreferences(AddonPreferences): @@ -463,6 +487,7 @@ classes = ( pdt_library.PDT_OT_LibShow, pdt_menus.PDT_PT_PanelDesign, pdt_menus.PDT_PT_PanelTools, + pdt_menus.PDT_PT_PanelTangent, pdt_menus.PDT_PT_PanelCommandLine, pdt_menus.PDT_PT_PanelViewControl, pdt_menus.PDT_PT_PanelPivotPoint, @@ -476,6 +501,9 @@ classes = ( pdt_pivot_point.PDT_OT_PivotOrigin, pdt_pivot_point.PDT_OT_PivotWrite, pdt_pivot_point.PDT_OT_PivotRead, + pdt_tangent.PDT_OT_TangentOperate, + pdt_tangent.PDT_OT_TangentSet1, + pdt_tangent.PDT_OT_TangentSet2, pdt_view.PDT_OT_ViewRot, pdt_view.PDT_OT_ViewRotL, pdt_view.PDT_OT_ViewRotR, diff --git a/precision_drawing_tools/pdt_menus.py b/precision_drawing_tools/pdt_menus.py index 61444d60..1632730c 100644 --- a/precision_drawing_tools/pdt_menus.py +++ b/precision_drawing_tools/pdt_menus.py @@ -414,3 +414,42 @@ class PDT_PT_PanelCommandLine(Panel): row.operator("pdt.command_rerun", text="", icon="LOOP_BACK") row = layout.row() row.prop(pdt_pg, "maths_output", text="Maths Output") + +class PDT_PT_PanelTangent(Panel): + bl_idname = "PDT_PT_PanelTangent" + bl_label = "PDT Tangents" + bl_space_type = "VIEW_3D" + bl_region_type = "UI" + bl_category = "PDT" + bl_options = {'DEFAULT_CLOSED'} + + def draw(self,context): + layout = self.layout + pdt_pg = context.scene.pdt_pg + # First Centre & Radius + row = layout.row() + split = row.split(factor=0.35, align=True) + split.label(text="Centre 1") + split.prop(pdt_pg, "tangent_point0", text="") + row = layout.row() + split = row.split(factor=0.45, align=False) + split.operator("pdt.tangentset1", text="Set From Arc") + split.prop(pdt_pg, "tangent_radius0", text="") + + # Second Centre & Radius + row = layout.row() + split = row.split(factor=0.35, align=True) + split.label(text="Centre 2") + split.prop(pdt_pg, "tangent_point1", text="") + row = layout.row() + split = row.split(factor=0.45, align=False) + split.operator("pdt.tangentset2", text="Set From Arc") + split.prop(pdt_pg, "tangent_radius1", text="") + + row = layout.row() + row.operator("pdt.tangentoperate", text="Execute", icon="NONE") + row.prop(pdt_pg, "tangent_from_point", text="From Point") + row = layout.row() + split = row.split(factor=0.35, align=True) + split.label(text="Tan Point") + split.prop(pdt_pg, "tangent_point2", text="") diff --git a/precision_drawing_tools/pdt_msg_strings.py b/precision_drawing_tools/pdt_msg_strings.py index 8c7b9db2..9eeb08f1 100644 --- a/precision_drawing_tools/pdt_msg_strings.py +++ b/precision_drawing_tools/pdt_msg_strings.py @@ -192,3 +192,9 @@ PDT_DES_FILLETSEG = "Number of Fillet Segments" PDT_DES_FILLETPROF = "Fillet Profile" PDT_DES_FILLETVERTS = "Use Vertices, or Edges, Set to False for Extruded Geometry" PDT_DES_FILLINT = "Intersect & Fillet Two Selected Edges" +PDT_DES_TANCEN1 = "Centre of First Tangent Arc" +PDT_DES_TANCEN2 = "Centre of Second Tangent Arc" +PDT_DES_TANCEN3 = "Tangents From a Point" +PDT_DES_RADIUS1 = "Radius of First Tangent Arc" +PDT_DES_RADIUS2 = "Radius of Second Tangent Arc" +PDT_DES_TPOINT = "Calculate Tangents From Point" -- cgit v1.2.3