The point module
- Introduction
- Example
- pt1 = (declaring a point object)
- Point attributes
- Methods (functions)
Also see :
Quick Notes |
Introduction to the point module :
Points identify specific locations in the 3D model with respect to the global coordinate system.
Before you can enter point attributes or use point methods, you need to declare a point object (see pt1 = ).
Attributes and methods (functions) can be assigned to point objects within parametric code.
Points are numeric. This means that you can add, subtract, negate, check for nonzero, and find the absolute value of points.
This is a parametric for testing. It can be used to test whether a point-location formula correctly finds the particular point that you want on a member. When you parametrically add material to a member, the work point of the material must be placed at the correct point on the member. When an SDS2 program Runs or Tests this parametric, the program automatically places a pair of cyan-colored construction lines that intersect at the left end, top flange, near side gage line of the particular member that the user selects. Tip : You can substitute different formulas from the parametric point maps to get this parametric to find different points.
# Adds construction lines at left end, top flange, near side gage line of W member.
from member import MemberLocate
from cons_line import ConsLine
from param import ClearSelection
mem = MemberLocate("Select a member")
var = mem.LeftEnd.Location + mem.TranslateToGlobal(mem.LeftEnd.MinusDimension, 0, mem.FlangeGage*0.5)
# construction line begin
cl1 = ConsLine()
cl1.Point1 = var
cl1.Rotation = 90
cl1.PenNumber = "Cyan"
cl1.Add()
# construction line end
# construction line begin
cl2 = ConsLine()
cl2.Point1 = var
cl2.Rotation = 0
cl2.PenNumber = "Cyan"
cl2.Add()
# construction line end
ClearSelection()
PointLocate( "status string", optional_rubber_band_point ) - when an SDS2 program Runs this script, Locate options are activated, and the user is prompted in the status line with the string (" status string ") that is entered. The user must then left-click ( Locate ) when the point location target is where the user wants the point. The second argument (optional_rubber_band_pt) is optional for second-point location and gives you a "rubber band" to the first point:
# Prints distance between two points. from param import Units, dim_print from point import PointLocate Units("feet") # sets dim_print output to ft-in frac pt1 = PointLocate("Locate 1st point") pt2 = PointLocate("Locate 2nd point", pt1) # pt1 is for "rubber band" dist = pt1.Distance(pt2) print(dim_print(dist))
Point( 0, 180, 0 ) returns global coordinates (in the order of X, Y, Z). Each coordinate listed in parentheses is delimited by a comma. When the parametric macro is Run the point (in this example, point object pt1 ), is placed at 180 units (inches or mm) along the Y axis from the 0, 0, 0 point in the 3D model. Global coordinates are expressed as distances ( floating point numbers ) in mm or inches, depending on the startup code Units(' ... ') .
# Adds construction lines through global origin. Run in a plan view.
from point import Point
from cons_line import ConsLine
origin = Point(0, 0, 0)
# add a vertical construction line
cl1 = ConsLine()
cl1.Point1 = origin
cl1.Rotation = 90
cl1.PenNumber = "Cyan"
cl1.Add()
# add a horizontal construction line
cl2 = ConsLine()
cl2.Point1 = origin
cl2.Rotation = 0
cl2.PenNumber = "Cyan"
cl2.Add()
mem1.LeftEnd.Location ( mem1.member.left_location ) returns a point object that identifies the left-end work point location of mem1 .
# Prints the left-end X, Y and Z of the selected member.
from param import Units, dim_print, ClearSelection
from member import MemberLocate
import member # to catch the exception
Units("feet") # sets dim_print output to ft-in frac
try:
mem1 = MemberLocate("Select a member")
print("X distance from origin =", dim_print(mem1.LeftEnd.Location.X))
print("Y distance from origin =", dim_print(mem1.LeftEnd.Location.Y))
print("Z distance from origin =", dim_print(mem1.LeftEnd.Location.Z))
except member.error:
print("You hit Esc or canceled instead of selecting a member!")
ClearSelection()
mem1.RightEnd.Location ( mem1.member.right_location ) is the same as mem1.LeftEnd.Location , except the point object that is returned identifies the right end work point location of mem1 .
pt1 .X ( pt1.x ) returns the X global coordinate of the point object. The X global coordinate is a floating point number in mm or inches, depending on the startup code Units(' ... ') .
Example: Since in this example pt1 and pt2 are, by definition, 180.0 units apart from one another along the X global axis and pt2.x+180.0 is the first point attribute listed within the parentheses, the result is 360.0, which dim_print() outputs as 30-0 since Unit("feet") are the startup code units. Note that Distance() only accepts one argument; for this reason, double parentheses are used.
# Always prints 30-0 if you locate a point. from param import Units, dim_print from point import PointLocate Units("feet") # sets dim_print output to ft-in frac if pt1: pt1 = PointLocate("Locate 1st point") pt2 = pt1 + (180.0, 0.0, 0.0) var = dim_print(pt1.Distance((pt2.X+180.0, pt2.Y, pt2.Z))) print(var) # output is 30-0 else: print("You returned without locating a point!")
pt1 .Y ( pt1.y ) returns the Y global coordinate of the point object. The Y global coordinate is a floating point number in mm or inches, depending on the startup code Units(' ... ') . Note that if dim_print() had been used like it was in the above script, the printed output would be 30-0 instead of 360.0 .
Example:
# Always prints 360.0 if you locate a point.
from param import Units
from point import PointLocate
Units("feet") # sets output to decimal inches
if pt1:
pt1 = PointLocate("Locate 1st point")
pt2 = pt1 + (0.0, 180.0, 0.0)
var = pt1.Distance((pt2.X, pt2.Y+180.0, pt2.Z))
print(var) # output is 360.0
else:
print("You returned without locating a point!")
pt1 .Z ( pt1.z ) is the Z global coordinate of the point object. The Z global coordinate is a floating point number in mm or inches, depending on the startup code Units(' ... ') .
Example:
# Prints the elevation of the located point.
from param import Units
from point import PointLocate
Units("feet") # sets output to decimal inches
pt1 = PointLocate("Locate a point")
if pt1:
print(pt1.Z) # output is in decimal inches
else:
print("You returned without locating a point!")
pt1 .Distance(obj.Point2) ( pt1.dist(obj.Point2) ) calculates the distance that pt1 is from obj.Point2 , where obj.Point2 returns a point. A distance is a floating point number in mm or inches, depending on the startup code Units(' ... ') . In the following example, mem.LeftEnd.Location returns the left end work point of the selected member while + mem.TranslateToGlobal(mem.Left.MinusDimension, 0, 0) translates that point to the left end of the member's main material.
# Prints the distance from the left end main material to a located point.
from param import Units, dim_print
from point import PointLocate
Units("feet") # sets dim_print output to ft-in frac
mem = MemberLocate("Select a member")
pt1 = mem.LeftEnd.Location + mem.TranslateToGlobal(mem.LeftEnd.MinusDimension, 0, 0)
pt2 = PointLocate("Locate 2nd point")
dist = pt1.Distance(pt2)
print("Actual distance: ", dim_print(dist)) # output in ft-in frac
ClearSelection()
pt1 .Distance(Point(X, Y, Z)) ( dist(Point(x, y, z)) ) calculates the distance that pt1 is from the global coordinate in parenthesis. A distance is a floating point number in mm or inches, depending on the startup code Units(' ... ') .
# Prints distance between the located point and 0, 0, 0.
from param import Units, dim_print
from point import PointLocate, Point
Units("feet") # sets dim_print output to ft-in frac
pt1 = PointLocate("Locate a point")
if pt1:
dist = pt1.Distance(Point (0, 0, 0))
print("X distance from origin =", dim_print(pt1.X))
print("Y distance from origin =", dim_print(pt1.Y))
print("Z distance from origin =", dim_print(pt1.Z))
print("Total distance from origin = ", dim_print(dist))
else:
print("You returned without locating a point!")