def getarc(data): "turns an OCA arc definition into a FreeCAD Part Edge" print "found arc ", data c = None if data[0] == "ARC": # 3-points arc pts = data[1:] verts = [] for p in range(len(pts)): if pts[p] == "P": verts.append(getpoint(pts[p : p + 3])) elif pts[p][0] == "P": verts.append(getpoint([pts[p]])) if verts[0] and verts[1] and verts[2]: c = Part.Arc(verts[0], verts[1], verts[2]) elif data[0][0] == "P": # 2-point circle verts = [] rad = None for p in range(len(data)): if data[p] == "P": verts.append(getpoint(data[p : p + 4])) elif data[p][0] == "P": verts.append(getpoint([data[p]])) elif data[p] == "VAL": rad = float(data[p + 1]) elif data[p][0] == "L": lines.append(objects[data[p]]) c = Part.Circle() c.Center = verts[0] if rad: c.Radius = rad else: c.Radius = DraftVecUtils.new(verts[0], verts[1]).Length elif data[0][0] == "L": # 2-lines circle lines = [] rad = None for p in range(len(data)): if data[p] == "VAL": rad = float(data[p + 1]) elif data[p][0] == "L": lines.append(objects[data[p]]) circles = DraftGeomUtils.circleFrom2LinesRadius(lines[0], lines[1], rad) if circles: c = circles[0] if c: return c.toShape()
def getarc(data): "turns an OCA arc definition into a FreeCAD Part Edge" print "found arc ", data c = None if (data[0] == "ARC"): # 3-points arc pts = data[1:] verts = [] for p in range(len(pts)): if (pts[p] == "P"): verts.append(getpoint(pts[p:p + 3])) elif (pts[p][0] == "P"): verts.append(getpoint([pts[p]])) if verts[0] and verts[1] and verts[2]: c = Part.Arc(verts[0], verts[1], verts[2]) elif (data[0][0] == "P"): # 2-point circle verts = [] rad = None for p in range(len(data)): if (data[p] == "P"): verts.append(getpoint(data[p:p + 4])) elif (data[p][0] == "P"): verts.append(getpoint([data[p]])) elif (data[p] == "VAL"): rad = float(data[p + 1]) elif (data[p][0] == "L"): lines.append(objects[data[p]]) c = Part.Circle() c.Center = verts[0] if rad: c.Radius = rad else: c.Radius = DraftVecUtils.new(verts[0], verts[1]).Length elif (data[0][0] == "L"): # 2-lines circle lines = [] rad = None for p in range(len(data)): if (data[p] == "VAL"): rad = float(data[p + 1]) elif (data[p][0] == "L"): lines.append(objects[data[p]]) circles = DraftGeomUtils.circleFrom2LinesRadius( lines[0], lines[1], rad) if circles: c = circles[0] if c: return c.toShape()
def getarc(data): """Turn an OCA arc definition into a FreeCAD Part.Edge. Parameters ---------- data : list Different types of data. Returns ------- Part.Edge An edge object from the points in `data`. """ FCC.PrintMessage("found arc %s \n" % data) c = None if data[0] == "ARC": # 3-points arc pts = data[1:] verts = [] for p in range(len(pts)): if pts[p] == "P": verts.append(getpoint(pts[p:p + 3])) elif pts[p][0] == "P": verts.append(getpoint([pts[p]])) if verts[0] and verts[1] and verts[2]: c = Part.Arc(verts[0], verts[1], verts[2]) elif data[0][0] == "P": # 2-point circle verts = [] rad = None lines = [] for p in range(len(data)): if data[p] == "P": verts.append(getpoint(data[p:p + 4])) elif data[p][0] == "P": verts.append(getpoint([data[p]])) elif data[p] == "VAL": rad = float(data[p + 1]) elif data[p][0] == "L": lines.append(objects[data[p]]) c = Part.Circle() c.Center = verts[0] if rad: c.Radius = rad else: # Error: DraftVecUtils.new() # doesn't exist c.Radius = DraftVecUtils.new(verts[0], verts[1]).Length elif data[0][0] == "L": # 2-lines circle lines = [] rad = None for p in range(len(data)): if data[p] == "VAL": rad = float(data[p + 1]) elif data[p][0] == "L": lines.append(objects[data[p]]) circles = DraftGeomUtils.circleFrom2LinesRadius( lines[0], lines[1], rad) if circles: c = circles[0] if c: return c.toShape()