FreeCAD Python
Functions
DraftGeomUtils

Detailed Description

Shape manipulation utilities for the Draft workbench.

Shapes manipulation utilities

Functions

def DraftGeomUtils.isNull (something)
 
def DraftGeomUtils.isPtOnEdge (pt, edge)
 
def DraftGeomUtils.getQuad (face)
 
def DraftGeomUtils.areColinear (e1, e2)
 
def DraftGeomUtils.findEdge (anEdge, aList)
 
def DraftGeomUtils.findIntersection (edge1, edge2, infinite1=False, infinite2=False, ex1=False, ex2=False, dts=True, findAll=False)
 
def DraftGeomUtils.pocket2d (shape, offset)
 
def DraftGeomUtils.orientEdge (edge, normal=None, make_arc=False)
 
def DraftGeomUtils.isClockwise (edge, ref=None)
 
def DraftGeomUtils.isSameLine (e1, e2)
 
def DraftGeomUtils.isWideAngle (edge)
 
def DraftGeomUtils.findClosest (basepoint, pointslist)
 
def DraftGeomUtils.invert (edge)
 
def DraftGeomUtils.flattenWire (wire)
 
def DraftGeomUtils.findWiresOld2 (edgeslist)
 
def DraftGeomUtils.superWire (edgeslist, closed=False)
 
def DraftGeomUtils.findPerpendicular (point, edgeslist, force=None)
 
def DraftGeomUtils.offset (edge, vector, trim=False)
 
def DraftGeomUtils.getRotation (v1, v2=FreeCAD.Vector(0, 0, 1))
 
def DraftGeomUtils.calculatePlacement (shape)
 
def DraftGeomUtils.offsetWire (wire, dvec, bind=False, occ=False)
 
def DraftGeomUtils.connect (edges, closed=False)
 
def DraftGeomUtils.findDistance (point, edge, strict=False)
 
def DraftGeomUtils.findWiresOld (edges)
 
def DraftGeomUtils.getTangent (edge, frompoint=None)
 
def DraftGeomUtils.bind (w1, w2)
 
def DraftGeomUtils.isCubic (shape)
 
def DraftGeomUtils.getCubicDimensions (shape)
 
def DraftGeomUtils.removeInterVertices (wire)
 
def DraftGeomUtils.arcFromSpline (edge)
 
def DraftGeomUtils.fillet (lEdges, r, chamfer=False)
 
def DraftGeomUtils.filletWire (aWire, r, chamfer=False)
 
def DraftGeomUtils.tessellateProjection (shape, seglen)
 
def DraftGeomUtils.rebaseWire (wire, vidx)
 
def DraftGeomUtils.removeSplitter (shape)
 
def DraftGeomUtils.getBoundaryAngles (angle, alist)
 
def DraftGeomUtils.arcFrom2Pts (firstPt, lastPt, center, axis=None)
 
def DraftGeomUtils.outerSoddyCircle (circle1, circle2, circle3)
 33 to include More...
 
def DraftGeomUtils.innerSoddyCircle (circle1, circle2, circle3)
 
def DraftGeomUtils.circleFrom3CircleTangents (circle1, circle2, circle3)
 
def DraftGeomUtils.linearFromPoints (p1, p2)
 
def DraftGeomUtils.determinant (mat, n)
 
def DraftGeomUtils.findHomotheticCenterOfCircles (circle1, circle2)
 
def DraftGeomUtils.findRadicalAxis (circle1, circle2)
 
def DraftGeomUtils.findRadicalCenter (circle1, circle2, circle3)
 
def DraftGeomUtils.pointInversion (circle, point)
 
def DraftGeomUtils.polarInversion (circle, edge)
 
def DraftGeomUtils.circleInversion (circle, circle2)
 

Function Documentation

◆ arcFrom2Pts()

def DraftGeomUtils.arcFrom2Pts (   firstPt,
  lastPt,
  center,
  axis = None 
)
Builds an arc with center and 2 points, can be oriented with axis

◆ arcFromSpline()

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...

◆ areColinear()

def DraftGeomUtils.areColinear (   e1,
  e2 
)
areColinear(e1,e2): returns True if both edges are colinear

◆ bind()

def DraftGeomUtils.bind (   w1,
  w2 
)
bind(wire1,wire2): binds 2 wires by their endpoints and
returns a face

◆ calculatePlacement()

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.

◆ circleFrom3CircleTangents()

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

◆ circleInversion()

def DraftGeomUtils.circleInversion (   circle,
  circle2 
)
pointInversion(Circle, Circle)

Circle inversion of a circle.

◆ connect()

def DraftGeomUtils.connect (   edges,
  closed = False 
)
connects the edges in the given list by their intersections

◆ determinant()

def DraftGeomUtils.determinant (   mat,
  n 
)
determinant(matrix,int) - Determinat function. Returns the determinant
of a n-matrix. It recursively expands the minors.

◆ fillet()

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

◆ filletWire()

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

◆ findClosest()

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.

◆ findDistance()

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.

◆ findEdge()

def DraftGeomUtils.findEdge (   anEdge,
  aList 
)
findEdge(anEdge,aList): returns True if anEdge is found in aList of edges

◆ findHomotheticCenterOfCircles()

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

◆ findIntersection()

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

◆ findPerpendicular()

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.

◆ findRadicalAxis()

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

◆ 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

◆ findWiresOld()

def DraftGeomUtils.findWiresOld (   edges)
finds connected edges in the list, and returns a list of lists containing edges
that can be connected

◆ findWiresOld2()

def DraftGeomUtils.findWiresOld2 (   edgeslist)
finds connected wires in the given list of edges

◆ flattenWire()

def DraftGeomUtils.flattenWire (   wire)
flattenWire(wire): forces a wire to get completely flat
along its normal.

◆ getBoundaryAngles()

def DraftGeomUtils.getBoundaryAngles (   angle,
  alist 
)
returns the 2 closest angles from the list that
encompass the given angle

◆ getCubicDimensions()

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.

◆ getQuad()

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.

◆ getRotation()

def DraftGeomUtils.getRotation (   v1,
  v2 = FreeCAD.Vector(0,0,1) 
)
Get the rotation Quaternion between 2 vectors

◆ getTangent()

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).

◆ innerSoddyCircle()

def DraftGeomUtils.innerSoddyCircle (   circle1,
  circle2,
  circle3 
)
Computes the inner soddy circle for three tightly packed circles.

◆ invert()

def DraftGeomUtils.invert (   edge)
invert(edge): returns an inverted copy of this edge

◆ isClockwise()

def DraftGeomUtils.isClockwise (   edge,
  ref = None 
)
Returns True if a circle-based edge has a clockwise direction

◆ isCubic()

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.

◆ isNull()

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)

◆ isPtOnEdge()

def DraftGeomUtils.isPtOnEdge (   pt,
  edge 
)
isPtOnEdge(Vector,edge): Tests if a point is on an edge

◆ isSameLine()

def DraftGeomUtils.isSameLine (   e1,
  e2 
)
isSameLine(e1,e2): return True if the 2 edges are lines and have the same
points

◆ isWideAngle()

def DraftGeomUtils.isWideAngle (   edge)
returns True if the given edge is an arc with angle > 180 degrees

◆ linearFromPoints()

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.

◆ offset()

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

◆ offsetWire()

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.

◆ orientEdge()

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

◆ outerSoddyCircle()

def DraftGeomUtils.outerSoddyCircle (   circle1,
  circle2,
  circle3 
)

33 to include

Computes the outer soddy circle for three tightly packed circles.

◆ pocket2d()

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.

◆ pointInversion()

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

◆ polarInversion()

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

◆ rebaseWire()

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.

◆ removeInterVertices()

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.

◆ removeSplitter()

def DraftGeomUtils.removeSplitter (   shape)
an alternative, shared edge-based version of Part.removeSplitter. Returns a
face or None if the operation failed

◆ superWire()

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

◆ tessellateProjection()

def DraftGeomUtils.tessellateProjection (   shape,
  seglen 
)
Returns projection with BSplines and Ellipses broken into line segments.
    Useful for exporting projected views to *dxf files.