##Plane3PConsCircle3D.py Version 1.02

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

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

"""

/// Given 3 non-collinear points, define three planes and calculate the radius and center point

/// of the circle connecting the points. Add a construction circle and a miscellaneous member object representing the

/// center point and normal unit vector in the current SDS/2 modeling view.

/// User can be in any model orientation.

/// Developed by Bruce Vaughan, BV Detailing & Design, Inc. (September 2006)

/// URL: www.bvdetailing.com

/// Credit Paul Bourke for 'Equation of a plane' (March 1989) and 'Intersection of three planes' (October 2001)

///

///

/// Revision History:

///     Version 1.02 (11/10/06) - Code simplification: 'if pt1 != None and pt2 != None and pt3 != None:' >>> 'if None not in (pt1, pt2, pt3):'

///     Version 1.03 (1/22/07) - Remove 'yes_or_no' add cons line?

"""

def run_script():

# startup code begin

from macrolib.P3D import Plane3D

from param import yes_or_no, Prompt

from member import Member, MemberLocate

from point import Point, PointLocate

from cons_circle import ConsCircle

from rnd_bar import RndBar

# from macrolib.PrintLocals import print_local_namespace

# startup code end

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

while 1:

pt1 = PointLocate("Pick point 1")

pt2 = PointLocate("Pick point 2")

pt3 = PointLocate("Pick point 3")

if None not in (pt1, pt2, pt3):

a = Plane3D(pt1, pt2, pt3)

if a.N_len > 0.0:

a.three_pt_circle()

# print print_local_namespace("Local Variables:\n", locals())

if a.R > 0.0:

cc2 = ConsCircle()

cc2.pt1 = a.M

cc2.pen = "Cyan"

if yes_or_no("Add a miscellaneous member to mark the center point?") == 1:

# Add miscellaneous member at center point

# The length will be one unit and will represent a.N_uv

if yes_or_no("Add offset construction circles?") == 1:

while True:

offset = Prompt(0.0, "Enter offset dimension or '0' if done")

if offset == 0:

break

else:

cc2 = ConsCircle()

cc2.pt1 = a.M

cc2.pen = "Cyan"

else:

Warning("The points selected are collinear which does not define a plane.")

else:

Warning("The 3 points selected must not be collinear.")

break

## end run_script() #########################################################

if __name__ == '__main__':

try:

run_script()

finally:

del run_script