def extendTheBeam( beam, target ): #TARGET [working]: make it work when target and beam belong to different App::Parts '''arg1=beam, arg2=target: extend the beam to a plane, normal to its axis, defined by target. If target is a Vertex or a Vector, the plane is the one that includes the point defined by target. If target is a Face, the plane is the one that includes the intersection between the axis of beam and the plane of the face. Else, the plane is the one normal to the axis of beam that includes the CenterOfMass of target''' distBase = distTop = 0 vBase = beam.Placement.Base vBeam = beamAx(beam) h = beam.Height vTop = vBase + vBeam.multiply(h) if type(target) == FreeCAD.Vector: distBase = vBase.distanceToPlane(target, vBeam) distTop = vTop.distanceToPlane(target, vBeam) elif target.ShapeType == "Vertex": distBase = vBase.distanceToPlane(target.Point, vBeam) distTop = vTop.distanceToPlane(target.Point, vBeam) elif target.ShapeType == "Face": if not isOrtho(target, vBeam): from Part import Point Pint = Point( intersectionPlane(beam.Placement.Base, beamAx(beam), target)).toShape() distBase = vBase.distanceToPlane(Pint.Point, vBeam) distTop = vTop.distanceToPlane(Pint.Point, vBeam) elif hasattr(target, "CenterOfMass"): distBase = vBase.distanceToPlane(target.CenterOfMass, vBeam) distTop = vTop.distanceToPlane(target.CenterOfMass, vBeam) if distBase * distTop > 0: if abs(distBase) > abs(distTop): beam.Height += FreeCAD.Units.Quantity(str(abs(distTop)) + "mm") else: beam.Height += FreeCAD.Units.Quantity(str(abs(distBase)) + "mm") vMove = vBeam.normalize().multiply(-distBase) beam.Placement.move(vMove) else: if abs(distBase) > abs(distTop): beam.Height -= FreeCAD.Units.Quantity(str(abs(distTop)) + "mm") else: beam.Height -= FreeCAD.Units.Quantity(str(abs(distBase)) + "mm") vMove = vBeam.normalize().multiply(-distBase) beam.Placement.move(vMove)
def __init__(self, obj,x=0.0,y=0.0,z=0.0): obj.Vector=FreeCAD.Vector(x,y,z) Point.__init__(self,obj.Vector) obj.Proxy = self
def getPoint(self, index, pos): return Point(CENTER)