def angleShapes( self, shape1, shape2 ):
if shape1.isValid() and shape2.isValid():
# get the direction of the shape
dir1 = self.getDir(shape1)
dir2 = self.getDir(shape2)
if dir1 and dir2:
angle = dir1.getAngle(dir2)*180./math.pi
...
# figure out the direction of a shape, be it a line, a surface or a circle
def getDir( self, shape ):
direction = None
# for a segment, it's the normalized vector along the segment
if self.isSegment(shape):
line = shape
pt1 = line.Vertexes[0].Point
pt2 = line.Vertexes[1].Point
vect = (pt2.sub(pt1))
if vect.Length != 0:
direction = vect / vect.Length
# for another line (like Datum::Line) it's the Z vector multiplied by the Line's Placement
elif self.isLine(shape):
direction = shape.Placement.Rotation.multVec(App.Vector(0,0,1))
# for a Circle it's the circle's axis
elif self.isCircle(shape):
direction = shape.Curve.Axis
# for a flt face it's the normal
elif self.isFlatFace(shape):
direction = shape.normalAt(0,0)
return direction
@easyw-fc@Zolko
About caliper, could be useful to have an parametric measurement. With an option, values could be move inside End and Start x,y,z. When changing the edge, measurement will follow
Zolko wrote: ↑Wed Sep 28, 2022 6:37 pm
you can do this to measure angles between 2 shapes :
yes, but how to draw it? currently I use "App::MeasureDistance" FreeCAD object for that, and I don't see similar thing for angle drawing
the "App::MeasureDistance" works with cut-list so you can create your own custom measurements list...
Yes, this is how I would like to calculate the angle in the future. But the biggest problem is to draw beautifly the angle I guess there is no function at FreeCAD for that? and this may not be easy, so this needs to create own function for draw the angle. So I postpone this feature for later. Also I have to make support for irregular non-rectangle shapes, what probably will take some time