FreeCAD Python
|
Shape manipulation utilities for the Draft workbench.
Shapes manipulation utilities
def DraftGeomUtils.arcFrom2Pts | ( | firstPt, | |
lastPt, | |||
center, | |||
axis = None |
|||
) |
Builds an arc with center and 2 points, can be oriented with axis
def DraftGeomUtils.arcFromSpline | ( | edge | ) |
arcFromSpline(edge): turns the given edge into an arc, by taking its first point, midpoint and endpoint. Works best with bspline segments such as those from imported svg files. Use this only if you are sure your edge is really an arc...
def DraftGeomUtils.areColinear | ( | e1, | |
e2 | |||
) |
areColinear(e1,e2): returns True if both edges are colinear
def DraftGeomUtils.bind | ( | w1, | |
w2 | |||
) |
bind(wire1,wire2): binds 2 wires by their endpoints and returns a face
def DraftGeomUtils.calculatePlacement | ( | shape | ) |
calculatePlacement(shape): if the given shape is planar, this function returns a placement located at the center of gravity of the shape, and oriented towards the shape's normal. Otherwise, it returns a null placement.
def DraftGeomUtils.circleFrom3CircleTangents | ( | circle1, | |
circle2, | |||
circle3 | |||
) |
http://en.wikipedia.org/wiki/Problem_of_Apollonius#Inversive_methods http://mathworld.wolfram.com/ApolloniusCircle.html http://mathworld.wolfram.com/ApolloniusProblem.html
def DraftGeomUtils.circleInversion | ( | circle, | |
circle2 | |||
) |
pointInversion(Circle, Circle) Circle inversion of a circle.
def DraftGeomUtils.connect | ( | edges, | |
closed = False |
|||
) |
connects the edges in the given list by their intersections
def DraftGeomUtils.determinant | ( | mat, | |
n | |||
) |
determinant(matrix,int) - Determinat function. Returns the determinant of a n-matrix. It recursively expands the minors.
def DraftGeomUtils.fillet | ( | lEdges, | |
r, | |||
chamfer = False |
|||
) |
fillet(lEdges,r,chamfer=False): Take a list of two Edges & a float as argument, Returns a list of sorted edges describing a round corner
def DraftGeomUtils.filletWire | ( | aWire, | |
r, | |||
chamfer = False |
|||
) |
Fillets each angle of a wire with r as radius value if chamfer is true, a chamfer is made instead and r is the size of the chamfer
def DraftGeomUtils.findClosest | ( | basepoint, | |
pointslist | |||
) |
findClosest(vector,list) in a list of 3d points, finds the closest point to the base point. an index from the list is returned.
def DraftGeomUtils.findDistance | ( | point, | |
edge, | |||
strict = False |
|||
) |
findDistance(vector,edge,[strict]) - Returns a vector from the point to its closest point on the edge. If strict is True, the vector will be returned only if its endpoint lies on the edge. Edge can also be a list of 2 points.
def DraftGeomUtils.findEdge | ( | anEdge, | |
aList | |||
) |
findEdge(anEdge,aList): returns True if anEdge is found in aList of edges
def DraftGeomUtils.findHomotheticCenterOfCircles | ( | circle1, | |
circle2 | |||
) |
findHomotheticCenterOfCircles(circle1, circle2) Calculates the homothetic center(s) of two circles. http://en.wikipedia.org/wiki/Homothetic_center http://mathworld.wolfram.com/HomotheticCenter.html
def DraftGeomUtils.findIntersection | ( | edge1, | |
edge2, | |||
infinite1 = False , |
|||
infinite2 = False , |
|||
ex1 = False , |
|||
ex2 = False , |
|||
dts = True , |
|||
findAll = False |
|||
) |
findIntersection(edge1,edge2,infinite1=False,infinite2=False,dts=True): returns a list containing the intersection point(s) of 2 edges. You can also feed 4 points instead of edge1 and edge2. If dts is used, Shape.distToShape() is used, which can be buggy
def DraftGeomUtils.findPerpendicular | ( | point, | |
edgeslist, | |||
force = None |
|||
) |
findPerpendicular(vector,wire,[force]): finds the shortest perpendicular distance between a point and an edgeslist. If force is specified, only the edge[force] will be considered, and it will be considered infinite. The function will return a list [vector_from_point_to_closest_edge,edge_index] or None if no perpendicular vector could be found.
def DraftGeomUtils.findRadicalAxis | ( | circle1, | |
circle2 | |||
) |
Calculates the radical axis of two circles. On the radical axis (also called power line) of two circles any tangents drawn from a point on the axis to both circles have the same length. http://en.wikipedia.org/wiki/Radical_axis http://mathworld.wolfram.com/RadicalLine.html @sa findRadicalCenter
def DraftGeomUtils.findRadicalCenter | ( | circle1, | |
circle2, | |||
circle3 | |||
) |
findRadicalCenter(circle1, circle2, circle3): Calculates the radical center (also called the power center) of three circles. It is the intersection point of the three radical axes of the pairs of circles. http://en.wikipedia.org/wiki/Power_center_(geometry) http://mathworld.wolfram.com/RadicalCenter.html @sa findRadicalAxis
def DraftGeomUtils.findWiresOld | ( | edges | ) |
finds connected edges in the list, and returns a list of lists containing edges that can be connected
def DraftGeomUtils.findWiresOld2 | ( | edgeslist | ) |
finds connected wires in the given list of edges
def DraftGeomUtils.flattenWire | ( | wire | ) |
flattenWire(wire): forces a wire to get completely flat along its normal.
def DraftGeomUtils.getBoundaryAngles | ( | angle, | |
alist | |||
) |
returns the 2 closest angles from the list that encompass the given angle
def DraftGeomUtils.getCubicDimensions | ( | shape | ) |
getCubicDimensions(shape): returns a list containing the placement, the length, the width and the height of a cubic shape. If not cubic, nothing is returned. The placement point is the lowest corner of the shape.
def DraftGeomUtils.getQuad | ( | face | ) |
getQuad(face): returns a list of 3 vectors (basepoint, Xdir, Ydir) if the face is a quad, or None if not.
def DraftGeomUtils.getRotation | ( | v1, | |
v2 = FreeCAD.Vector(0,0,1) |
|||
) |
Get the rotation Quaternion between 2 vectors
def DraftGeomUtils.getTangent | ( | edge, | |
frompoint = None |
|||
) |
returns the tangent to an edge. If from point is given, it is used to calculate the tangent (only useful for an arc of course).
def DraftGeomUtils.innerSoddyCircle | ( | circle1, | |
circle2, | |||
circle3 | |||
) |
Computes the inner soddy circle for three tightly packed circles.
def DraftGeomUtils.invert | ( | edge | ) |
invert(edge): returns an inverted copy of this edge
def DraftGeomUtils.isClockwise | ( | edge, | |
ref = None |
|||
) |
Returns True if a circle-based edge has a clockwise direction
def DraftGeomUtils.isCubic | ( | shape | ) |
isCubic(shape): verifies if a shape is cubic, that is, has 8 vertices, 6 faces, and all angles are 90 degrees.
def DraftGeomUtils.isNull | ( | something | ) |
isNull(object): returns true if the given shape is null or the given placement is null or if the given vector is (0,0,0)
def DraftGeomUtils.isPtOnEdge | ( | pt, | |
edge | |||
) |
isPtOnEdge(Vector,edge): Tests if a point is on an edge
def DraftGeomUtils.isSameLine | ( | e1, | |
e2 | |||
) |
isSameLine(e1,e2): return True if the 2 edges are lines and have the same points
def DraftGeomUtils.isWideAngle | ( | edge | ) |
returns True if the given edge is an arc with angle > 180 degrees
def DraftGeomUtils.linearFromPoints | ( | p1, | |
p2 | |||
) |
Calculate linear equation from points. Calculate the slope and offset parameters of the linear equation of a line defined by two points. Linear equation: y = m * x + b m = dy / dx m ... Slope b ... Offset (point where the line intersects the y axis) dx/dy ... Delta x and y. Using both as a vector results in a non-offset direction vector.
def DraftGeomUtils.offset | ( | edge, | |
vector, | |||
trim = False |
|||
) |
offset(edge,vector) returns a copy of the edge at a certain (vector) distance if the edge is an arc, the vector will be added at its first point and a complete circle will be returned
def DraftGeomUtils.offsetWire | ( | wire, | |
dvec, | |||
bind = False , |
|||
occ = False |
|||
) |
offsetWire(wire,vector,[bind]): offsets the given wire along the given vector. The vector will be applied at the first vertex of the wire. If bind is True (and the shape is open), the original wire and the offsetted one are bound by 2 edges, forming a face.
def DraftGeomUtils.orientEdge | ( | edge, | |
normal = None , |
|||
make_arc = False |
|||
) |
Re-orients 'edge' such that it is in the x-y plane. If 'normal' is passed, this is used as the basis for the rotation, otherwise the Placement property of 'edge' is used
def DraftGeomUtils.outerSoddyCircle | ( | circle1, | |
circle2, | |||
circle3 | |||
) |
33 to include
Computes the outer soddy circle for three tightly packed circles.
def DraftGeomUtils.pocket2d | ( | shape, | |
offset | |||
) |
pocket2d(shape,offset): return a list of wires obtained from offsetting the wires from the given shape by the given offset, and intersection if needed.
def DraftGeomUtils.pointInversion | ( | circle, | |
point | |||
) |
pointInversion(Circle, Vector) Circle inversion of a point. Will calculate the inversed point an return it. If the given point is equal to the center of the circle "None" will be returned. See also: http://en.wikipedia.org/wiki/Inversive_geometry
def DraftGeomUtils.polarInversion | ( | circle, | |
edge | |||
) |
polarInversion(circle, edge): Returns the inversion pole of a line. edge ... The polar. i.e. The nearest point on the line is inversed. http://mathworld.wolfram.com/InversionPole.html
def DraftGeomUtils.rebaseWire | ( | wire, | |
vidx | |||
) |
rebaseWire(wire,vidx): returns a new wire which is a copy of the current wire, but where the first vertex is the vertex indicated by the given index vidx, starting from 1. 0 will return an exact copy of the wire.
def DraftGeomUtils.removeInterVertices | ( | wire | ) |
removeInterVertices(wire) - remove unneeded vertices (those that are in the middle of a straight line) from a wire, returns a new wire.
def DraftGeomUtils.removeSplitter | ( | shape | ) |
an alternative, shared edge-based version of Part.removeSplitter. Returns a face or None if the operation failed
def DraftGeomUtils.superWire | ( | edgeslist, | |
closed = False |
|||
) |
superWire(edges,[closed]): forces a wire between edges that don't necessarily have coincident endpoints. If closed=True, wire will always be closed
def DraftGeomUtils.tessellateProjection | ( | shape, | |
seglen | |||
) |
Returns projection with BSplines and Ellipses broken into line segments. Useful for exporting projected views to *dxf files.