Electronics Desktop Wizard

The extension Wizard Demo contains a target product wizard for Electronics Desktop that has the same name as the extension. This simple two-step wizard enables the creation of two geometries from three dimension properties and the addition of two boundary conditions.

XML Extension Definition File

Definitions follow for codes blocks in the XML extension definition file WizardDemo.xml.

Extension Definition

The <extension> block is the top-most level in the hierarchy.

  • The attributes name and version specify the extension name and version.

  • The attribute icon specifies the image file to display as the icon for the extension. You specify the location of the images folder for all images used by the extension in the <interface> block.

Guid Definition

The <guid> block specifies a unique identifier for the extension.

Script Definition

The <script> block specifies the IronPython script that is referenced by the extension. This extension references callbacks.py.

Wizard Interface Definition

The <interface> block defines the user interface for the wizard.

  • The attribute context is set to ElectronicsDesktop because the extension runs from ANSYS Electronics Desktop.

  • The attribute images specifies the images folder for all images that the extension is to use. You use the attribute icon for the extension, wizard, step, and so on to specify an image file in this folder to use as an icon.

Wizard Definition

The wizard Wizard Demo and its steps are defined in the <wizard> block named Wizard Demo.

  • The attributes name and version specify the wizard name and version.

  • The attribute context specifies the ANSYS product in which the wizard is executed. Because the wizard runs from Electronic Desktop, context is set to ElectronicsDesktop.

  • The attribute icon specifies the filename of the image to display as the icon for the wizard:antimage. The file antimage.png is stored in the folder specified for the attribute images in the <interface> block.

  • The attribute description specifies the text to display in the About window for the extension when it is accessed from the Extension Manager and in the About window for the wizard when it is accessed from the Wizards page.

Step Definition

The <step> blocks define the steps of the wizard. This wizard has two steps: Step1 and Step2. For each step:

  • The attributes name, version, and caption define the step name, version, and display text for the step. These are shown in the About window for the wizard when it is accessed from the Wizards page.

  • The attribute context specifies the ANSYS product in which the specific step is executed. You only need to set the context for the step if it differs from the context for the wizard.

  • The attribute HelpFile specifies the HTML file to display as the custom help for the step.

  • The <propertygroup> blocks specify groupings of properties within the step. Any <property> blocks specify properties and property attributes.

  • The <callbacks> blocks specify callbacks to functions defined in the script callbacks.py. These are discussed in more detail in Reviewing the Analysis.

The XML extension definition file WizardDemo.xml follows.

<extension name="Wizard Demo" version="1">
  <author>ANSYS Inc.</author>
  <guid shortid="ElectronicsWizard">819d1fd2-17c2-493a-ad6a-ee608356229a</guid>
  <script src="callbacks.py" />
  
  <interface context="ElectronicsDesktop">
    <images>images</images>
  </interface>
  
  <wizard name="Wizard Demo" caption="Wizard Demo" version="1" context="ElectronicsDesktop" icon="antImage">
    <description>Simple example of a wizard in Electronics Desktop</description>
	
    <step name="Step1" version="1" caption="Design">
	  <description>Create geometry</description>
	  
      <propertygroup name="dim" caption="Dimensions (mm)" persistent="False" parameterizable="False">
        <property control="float" name="width" caption="Width" persistent="False" parameterizable="False" 
default="0.4" />
        <property control="float" name="height" caption="Height" persistent="False" parameterizable="False" 
default="1.7" />
      </propertygroup>
	  
      <propertygroup name="offset" caption="Offset for duplication (mm)" persistent="False" 
parameterizable="False">
        <property control="float" name="offset" caption="Offset" persistent="False" parameterizable="False" 
default="0.3" />
      </propertygroup>
	  
      <callbacks>
        <onupdate>OnUpdate1</onupdate>
        <onreset>OnReset1</onreset>
      </callbacks>
      
    </step>
	
    <step name="Step2" version="1" caption="Setup">
	  <description>Define boundary conditions</description>
	  
      <propertygroup name="bc" caption="Boundary Conditions (Ohm)" persistent="False" 
parameterizable="False">
        <property control="float" name="resistance" caption="Full Resistance" persistent="False" 
parameterizable="False" default="50." />
        <property control="float" name="reactance" caption="Full Reactance" persistent="False" 
parameterizable="False" default="0." />
      </propertygroup>
	  
      <callbacks>
        <onupdate>OnUpdate2</onupdate>
      </callbacks>
      
    </step>
	
  </wizard>
</extension>

IronPython Script

The IronPython script callbacks.py follows. This script defines all functions executed by the callbacks in the XML extension definition file.

# ----------------------------------------------
# Callbacks
# ----------------------------------------------
    
oDesign = None
oProject = None   
    
def OnUpdate1(step):
    global oDesign, oProject
    oProject = oDesktop.NewProject()
    oProject.InsertDesign("HFSS", "HFSSDesign1", "DrivenModal", "")
    oDesign = oProject.SetActiveDesign("HFSSDesign1")
    oEditor = oDesign.SetActiveEditor("3D Modeler")
    
    width = step.Properties["dim/width"].Value
    height = step.Properties["dim/height"].Value
    offset = step.Properties["offset/offset"].Value

    oEditor.CreateRectangle(
        [
            "NAME:RectangleParameters",
            "IsCovered:="       , True,
            "XStart:="      , "0mm",
            "YStart:="      , "0mm",
            "ZStart:="      , "0mm",
            "Width:="       , str(width)+"mm",
            "Height:="      , str(height)+"mm",
            "WhichAxis:="       , "Z"
        ], 
        [
            "NAME:Attributes",
            "Name:="        , "Rectangle1",
            "Flags:="       , "",
            "Color:="       , "(128 255 255)",
            "Transparency:="    , 0.800000011920929,
            "PartCoordinateSystem:=", "Global",
            "UDMId:="       , "",
            "MaterialValue:="   , "\"vacuum\"",
            "SolveInside:="     , True
        ])
    oEditor.DuplicateAlongLine(
        [
            "NAME:Selections",
            "Selections:="      , "Rectangle1",
            "NewPartsModelFlag:="   , "Model"
        ], 
        [
            "NAME:DuplicateToAlongLineParameters",
            "CreateNewObjects:="    , True,
            "XComponent:="      , "0mm",
            "YComponent:="      , str(height+offset)+"mm",
            "ZComponent:="      , "0mm",
            "NumClones:="       , "2"
        ], 
        [
            "NAME:Options",
            "DuplicateAssignments:=", False
        ])
 
def OnReset1(step):
    global oProject
    oDesktop.CloseProject(oProject.GetName())
 
def OnUpdate2(step):
    global oDesign
    oModule = oDesign.GetModule("BoundarySetup")

    width = step.PreviousStep.Properties["dim/width"].Value
    height = step.PreviousStep.Properties["dim/height"].Value
    offset = step.PreviousStep.Properties["offset/offset"].Value
    
    resistance = step.Properties["bc/resistance"].Value
    reactance = step.Properties["bc/reactance"].Value
    
    oModule.AssignPerfectE(
        [
            "NAME:PerfE1",
            "Objects:="     , ["Rectangle1_1","Rectangle1"],
            "InfGroundPlane:="  , False
        ])
    oEditor = oDesign.SetActiveEditor("3D Modeler")
    oEditor.CreateRectangle(
        [
            "NAME:RectangleParameters",
            "IsCovered:="       , True,
            "XStart:="      , "0mm",
            "YStart:="      , str(height)+"mm",
            "ZStart:="      , "0mm",
            "Width:="       , str(width)+"mm",
            "Height:="      , str(offset)+"mm",
            "WhichAxis:="       , "Z"
        ], 
        [
            "NAME:Attributes",
            "Name:="        , "Rectangle2",
            "Flags:="       , "",
            "Color:="       , "(128 255 255)",
            "Transparency:="    , 0.800000011920929,
            "PartCoordinateSystem:=", "Global",
            "UDMId:="       , "",
            "MaterialValue:="   , "\"vacuum\"",
            "SolveInside:="     , True
        ])
    oModule.AssignLumpedPort(
        [
            "NAME:1",
            "Objects:="     , ["Rectangle2"],
            "RenormalizeAllTerminals:=", True,
            "DoDeembed:="       , False,
            [
                "NAME:Modes",
                [
                    "NAME:Mode1",
                    "ModeNum:="     , 1,
                    "UseIntLine:="      , True,
                    [
                        "NAME:IntLine",
                        "Start:="       , [str(width/2.)+"mm",str(height)+"mm","0mm"],
                        "End:="         , [str(width/2.)+"mm",str(height+offset)+"mm","0mm"]
                    ],
                    "AlignmentGroup:="  , 0,
                    "CharImp:="     , "Zpi",
                    "RenormImp:="       , "50ohm"
                ]
            ],
            "ShowReporterFilter:="  , False,
            "ReporterFilter:="  , [True],
            "FullResistance:="  , str(resistance)+"ohm",
            "FullReactance:="   , str(reactance)+"ohm"
        ])

Reviewing the Analysis

This section reviews the wizard interface and the processes performed in each step of the wizard Wizard Demo.

The first step is Design, which defines the geometries.

 

In this step:

  • The two <propertygroup> blocks define the three dimension properties.

    • The first block defines the property group Dimensions to include the properties Width and Height for creating the first rectangle.

    • The second block defines the property Offset for duplication to use for duplicating the first rectangle.

  • The <callbacks> block defines the following callbacks:

    • The callback <onupdate> invokes the function OnUpdate1 when the Next button is clicked. This function creates the new project, creates the first rectangle based on the entered dimensions, and then creates the second rectangle via duplication and offset according to the entered offset value.

    • The callback <onreset> is invoked when the Back button on the next step is clicked. The Back button is enabled only if the callback <onreset> has been defined.

The next step is Setup, which defines and applies the boundary conditions.

 

In this step:

  • The <propertygroup> block defines two boundary condition properties: resistance and reactance. The attribute caption for these two properties are Full Resistance and Full Reactance.

  • The callback <onupdate> invokes the function OnUpdate2 when the Next button is clicked. This function applies the boundary conditions to both rectangles.

Once the wizard has completed, the boundary conditions can be viewed by selecting them in the Electronics Desktop Project Manager tree.

 


Release 18.2 - © ANSYS, Inc. All rights reserved.