14.6 Defining specific geometry

def draw_corrugated_horn(qwm_doc):

# creating the lists of points

points = [(0,ir),(isl,ir)]

if(dr0!=0):

AddY(points, dr0)

AddX(points, l0)

AddY(points, dr0c+twi)

 

nn=1

while(nn<=ncor):

AddX(points,-cdl);

AddY(points,cwi);

AddX(points,cdh);

AddY(points,twi);

nn+=1

 

AddX(points, (cdh*(-2)) +cdl)

points.append( (isl+l0-cdl-twi*2, ir+dr0c+dr0+cwi+twi*2) )

points.append((0, ir+dr0c+dr0+cwi+twi*2))

 

# creating the sketch

qwm_doc.addObject(’Sketcher::SketchObject’, ’Sketch_horn’)

qwm_doc.Sketch_horn.Placement = FreeCAD.Placement(FreeCAD.Vector(0,0,0),FreeCAD.Rotation(0,0,0,1.0))

sketch_polyline(qwm_doc.Sketch_horn, points)

 

# horn revolve

qwm_doc.addObject("Part::Revolution", "horn")

qwm_doc.horn.Source = FreeCAD.ActiveDocument.Sketch_horn

qwm_doc.horn.Axis = (1.000000000000000,0.000000000000000,0.000000000000000)

qwm_doc.horn.Base = (0.000000000000000,0.000000000000000,0.000000000000000)

qwm_doc.horn.Angle = 360.000000000000000

qwm_doc.horn.Solid = True

qwm_doc.horn.AxisLink = None

qwm_doc.horn.Symmetric = False

FreeCADGui.ActiveDocument.Sketch_horn.Visibility = False

 

Creating Point Lists: In this code segment, a series of points are defined to outline the geometry of a corrugated horn. The coordinates of these points are stored in the points list, forming the basis for the sketch.

Sketch Creation: Once the points list is fully defined, a sketch is created using FreeCAD’s Sketcher::SketchObject. This sketch serves as the foundation for the horn’s geometry. The Placement attribute is set to position the sketch at the origin (0,0,0). The sketch_polyline function is then called to create a polyline sketch based on the points list. Constraints are added to ensure the sketch elements are properly connected, creating a closed profile

Horn Revolution: This step transforms the 2D sketch into a 3D axisymmetrical solid, representing the corrugated horn. In V2D projects, the sketches should be revolved around X axis. The default medium of the obtained solid is PEC.