Macro Recording of Example 3
The CADFEKO macro recorded Lua script for Example 3 is given below.
application = cf.Application.getInstance() -- NewProject project = application:NewProject() -- SetProperties properties = application.Project.ModelAttributes:GetProperties() properties.Unit = cf.Enums.ModelUnitEnum.Millimetres application.Project.ModelAttributes:SetProperties(properties) -- Add properties1 = cf.Variable.GetDefaultProperties() properties1.Expression = "18.8" properties1.Label = "patch_size" patch_size = application.Project.Definitions.Variables:Add(properties1) -- Add properties1.Expression = "4.3" properties1.Label = "chamfer_d" chamfer_d = application.Project.Definitions.Variables:Add(properties1) -- Add properties1.Expression = "-6.4" properties1.Label = "feed_pos" feed_pos = application.Project.Definitions.Variables:Add(properties1) -- Add properties1.Expression = "45" properties1.Label = "substrate_w" substrate_w = application.Project.Definitions.Variables:Add(properties1) -- Add properties1.Expression = "45" properties1.Label = "substrate_d" substrate_d = application.Project.Definitions.Variables:Add(properties1) -- Add properties1.Expression = "5" properties1.Label = "substrate_h" substrate_h = application.Project.Definitions.Variables:Add(properties1) -- Add properties1.Expression = "5.6" properties1.Label = "ceramic_epsR" ceramic_epsR = application.Project.Definitions.Variables:Add(properties1) -- Add properties1.Expression = "0.0041" properties1.Label = "ceramic_tanD" ceramic_tanD = application.Project.Definitions.Variables:Add(properties1) -- CreateGroup group1 = application.Project.Definitions.Variables:CreateGroup() -- MoveIn group1:MoveIn({patch_size, chamfer_d}) -- Setting Label group1.Label = "Patch" -- CreateGroup group11 = application.Project.Definitions.Variables:CreateGroup() -- MoveIn group11:MoveIn({substrate_w, substrate_d, substrate_h}) -- Setting Label group11.Label = "Substrate" -- AddDielectric properties2 = cf.Dielectric.GetDefaultProperties() properties2.DielectricModelling.RelativePermittivity = "ceramic_epsR" properties2.DielectricModelling.LossTangent = "ceramic_tanD" properties2.Label = "Ceramic" ceramic = application.Project.Definitions.Media.Dielectric:AddDielectric(properties2) -- Setting Colour ceramic.Colour = "#aa55ff" -- AddPolygon properties3 = cf.Polygon.GetDefaultProperties() properties3.Corners[1].U = "patch_size" properties3.Corners[1].V = "patch_size" properties3.Corners[1].N = "substrate_h" properties3.Corners[2].U = "-patch_size + chamfer_d" properties3.Corners[2].V = "patch_size" properties3.Corners[2].N = "substrate_h" properties3.Corners[3].U = "-patch_size" properties3.Corners[3].V = "patch_size - chamfer_d" properties3.Corners[3].N = "substrate_h" properties3.Corners[4] = {} properties3.Corners[4].U = "-patch_size" properties3.Corners[4].V = "-patch_size" properties3.Corners[4].N = "substrate_h" properties3.Corners[5] = {} properties3.Corners[5].U = "patch_size - chamfer_d" properties3.Corners[5].V = "-patch_size" properties3.Corners[5].N = "substrate_h" properties3.Corners[6] = {} properties3.Corners[6].U = "patch_size" properties3.Corners[6].V = " -patch_size + chamfer_d" properties3.Corners[6].N = "substrate_h" properties3.LocalWorkplane.WorkplaneDefinitionOption = cf.Enums.LocalWorkplaneDefinitionEnum.UsePredefinedWorkplane globalXY = application.Project.Definitions.Workplanes:Item("Global XY") properties3.LocalWorkplane.ReferencedWorkplane = globalXY properties3.Label = "patch" patch = application.Project.Contents.Geometry:AddPolygon(properties3) -- AddCuboid properties4 = cf.Cuboid.GetDefaultProperties() properties4.Origin.U = "-22.5" properties4.Origin.V = "-22.5" properties4.Width = "substrate_w" properties4.Depth = "substrate_d" properties4.Height = "substrate_h" properties4.LocalWorkplane.WorkplaneDefinitionOption = cf.Enums.LocalWorkplaneDefinitionEnum.UsePredefinedWorkplane properties4.LocalWorkplane.ReferencedWorkplane = globalXY properties4.Label = "substrate" substrate = application.Project.Contents.Geometry:AddCuboid(properties4) -- SetProperties properties5 = substrate.Regions:Item("Region1"):GetProperties() properties5.Medium = ceramic substrate.Regions:Item("Region1"):SetProperties(properties5) -- AddLine properties6 = cf.Line.GetDefaultProperties() properties6.StartPoint.V = "feed_pos" properties6.EndPoint.U = "0" properties6.EndPoint.V = "feed_pos" properties6.EndPoint.N = "substrate_h" properties6.LocalWorkplane.WorkplaneDefinitionOption = cf.Enums.LocalWorkplaneDefinitionEnum.UsePredefinedWorkplane properties6.LocalWorkplane.ReferencedWorkplane = globalXY properties6.Label = "feed_line" feed_line = application.Project.Contents.Geometry:AddLine(properties6) -- AddUnion union1 = application.Project.Contents.Geometry:Union({patch, substrate, feed_line}) -- SetProperties properties7 = union1.Faces:Item("Face8"):GetProperties() perfectElectricConductor = application.Project.Definitions.Media.PerfectElectricConductor properties7.Medium = perfectElectricConductor union1.Faces:Item("Face8"):SetProperties(properties7) -- ToggleVisibility substrate.Faces:Item("Face2"):ToggleVisibility() -- ToggleVisibility substrate.Faces:Item("Face2"):ToggleVisibility() -- SetProperties properties8 = union1.Faces:Item("Face6"):GetProperties() properties8.Medium = perfectElectricConductor union1.Faces:Item("Face6"):SetProperties(properties8) -- AddWirePort properties9 = cf.WirePort.GetDefaultProperties() edge19 = feed_line.Edges:Item("Edge19") properties9.Wire = edge19 properties9.Label = "Port1" port1 = application.Project.Contents.Ports:AddWirePort(properties9) -- AddVoltageSource properties10 = cf.VoltageSource.GetDefaultProperties() properties10.Terminal = port1 properties10.Label = "VoltageSource1" voltageSource1 = application.Project.Contents.SolutionConfigurations.GlobalSources:AddVoltageSource(properties10) -- SetProperties properties11 = application.Project.Contents.SolutionConfigurations.GlobalFrequency:GetProperties() properties11.Start = "1.27e9" properties11.End = "1.85e9" properties11.RangeType = cf.Enums.FrequencyRangeTypeEnum.Continuous application.Project.Contents.SolutionConfigurations.GlobalFrequency:SetProperties(properties11) -- SetProperties properties12 = application.Project.Mesher.Settings:GetProperties() properties12.MeshSizeOption = cf.Enums.MeshSizeOptionEnum.Fine properties12.WireRadius = "07" properties12.Advanced.GrowthRate = 30 properties12.Advanced.RefinementFactor = 80 properties12.Advanced.MinElementSize = 80 application.Project.Mesher.Settings:SetProperties(properties12) -- ToggleVisibility application.Project.Contents.Cutplanes:Item("XZ-Cut"):ToggleVisibility() -- ToggleVisibility application.Project.Contents.Cutplanes:Item("XZ-Cut"):ToggleVisibility() -- SetProperties properties13 = union1.Edges:Item("Edge6"):GetProperties() properties13.LocalMeshSizeEnabled = true properties13.LocalMeshSize = "2" union1.Edges:Item("Edge6"):SetProperties(properties13) -- SetProperties properties14 = union1.Edges:Item("Edge3"):GetProperties() properties14.LocalMeshSizeEnabled = true properties14.LocalMeshSize = "2" union1.Edges:Item("Edge3"):SetProperties(properties14) -- Add properties15 = cf.FarField.GetDefaultProperties() properties15.Theta.End = "180.0" properties15.Theta.Increment = "5.0" properties15.Phi.End = "360.0" properties15.Phi.Increment = "5.0" properties15.Label = "FarField1" properties15.LocalWorkplane.WorkplaneDefinitionOption = cf.Enums.LocalWorkplaneDefinitionEnum.UsePredefinedWorkplane properties15.LocalWorkplane.ReferencedWorkplane = globalXY farField1 = application.Project.Contents.SolutionConfigurations:Item("StandardConfiguration1").FarFields:Add(properties15) -- SaveAs application:SaveAs("C:/Users/eh/Desktop/Example2.CADFEKO")