Back to SDS/2 Parametric Scripts
##Plane3PConsCircle3D.py
Version 1.02
##Copyright (c) 2006
##All rights
reserved.
#############################################################################
"""
/// 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
/// User can be in
any model orientation.
/// Developed by
/// 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 (
/// Version 1.03 (
/// Add construction circle offsets after adding 3 point cons
circle
"""
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:
# Add
construction circle
cc2 = ConsCircle()
cc2.pt1 = a.M
cc2.radius = a.R
cc2.pen = "Cyan"
cc2.add()
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
memadd1 = Member('Misc Round Bar')
memadd1.left.location =
a.M
memadd1.right.location
= a.M + a.N_uv
memadd1.grade =
"A36"
memadd1.centered =
"Yes"
memadd1.bar_diameter =
1
memadd1.work_pt_dist =
1.0
memadd1.mtrl_type =
"Round bar"
memadd1.finish =
"None"
memadd1.ref_pt_offset =
(0, 0, 0)
memadd1.add()
if
yes_or_no("Add offset construction
circles?") == 1:
rad = a.R
while
True:
offset
= Prompt(0.0, "Enter offset dimension or '0' if done")
if
offset == 0:
break
else:
rad += offset
# Add construction circle
cc2 = ConsCircle()
cc2.pt1 = a.M
cc2.radius = rad
cc2.pen =
"Cyan"
cc2.add()
else:
Warning("The
points selected are collinear which does not define a plane.")
else:
Warning("The
3 points selected must not be collinear.")
if yes_or_no("Add additional construction circles?")
== 0:
break
## end run_script()
#########################################################
if __name__ == '__main__':
try:
run_script()
finally: