Back to SDS/2 Parametric Scripts

 

from point import Point, PointLocate

from param import Prompt

##  ConsMidPt.py Version 1.00

##  Copyright (c) 2006 Bruce Vaughan, BV Detailing & Design, Inc.

##  All rights reserved.

##  NOT FOR SALE. The software is provided "as is" without any warranty.

############################################################################

"""

Add two perpendicular construction lines at the true midpoint between two points

"""

from cons_line import ConsLine

 

def midpt(p1, p2):

    return Point((p2.x-p1.x)/2+p1.x, (p2.y-p1.y)/2+p1.y, (p2.z-p1.z)/2+p1.z)

 

def gridAdd(pt, r, cons_color="Cyan"):

    # construction line begin

    cl2 = ConsLine()

    cl2.pt1 = pt

    cl2.angle = r

    cl2.pen = cons_color

    cl2.add()

    # construction line end

 

while True:

    pt1 = PointLocate("Pick First Point for Midpoint")

    if not pt1:

        break

    else:

        pt2 = PointLocate("Pick Second Point for Midpoint")

        r = Prompt(0.0, "Enter Cons Line Angle")

        gridAdd(midpt(pt1, pt2), r)

        gridAdd(midpt(pt1, pt2), r+90.0)