Example #1
0
def move(oEditor, partlist, x, y, z, NewPartsModelFlag="Model"):
    """
    Move specified parts.
    
    Parameters
    ----------
    oEditor : pywin32 COMObject
        The HFSS editor in which the operation will be performed.
    partlist : list
        List of part name strings to be mirrored.
    x : float
        x displacement in Cartesian coordinates.
    y : float
        y displacement in Cartesian coordinates.
    z : float
        z displacement in Cartesian coordinates.
        
    Returns
    -------
    None
    """
    selectionsarray = [
        "NAME:Selections", "Selections:=", ','.join(partlist),
        "NewPartsModelFlag:=", NewPartsModelFlag
    ]

    moveparametersarray = [
        "NAME:TranslateParameters", "TranslateVectorX:=",
        str(Ex(x).expr), "TranslateVectorY:=",
        str(Ex(y).expr), "TranslateVectorZ:=",
        str(Ex(z).expr)
    ]

    oEditor.Move(selectionsarray, moveparametersarray)
Example #2
0
def get_face_by_position(oEditor, bodyname, x, y, z):
    """
    Get the face of a given body that lies at a given position.
    
    Parameters
    ----------
    oEditor : pywin32 COMObject
        The HFSS editor in which the operation will be performed.
    bodyname : str
        Name of the body whose face will be returned
    x : float
        x position of the face
    y : float
        y position of the face
    z : float
        z position of the face
        
    Returns
    -------
    faceid : int
        Id number of the face.
    """
    positionparameters = [
        "NAME:Parameters", "BodyName:=", bodyname, "Xposition:=",
        Ex(x).expr, "YPosition:=",
        Ex(y).expr, "ZPosition:=",
        Ex(z).expr
    ]

    faceid = oEditor.GetFaceByPosition(positionparameters)

    return faceid
Example #3
0
def rotate(oEditor, partlist, axis, angle):
    """
    Rotate specified parts.
    
    Parameters
    ----------
    oEditor : pywin32 COMObject
        The HFSS editor in which the operation will be performed.
    partlist : list
        List of part name strings to be rotated.
    axis : str
        Rotation axis.
    angle : float
        Rotation angle in radians
   
    Returns
    -------
    None
    """
    selectionsarray = [
        "NAME:Selections", "Selections:=", ','.join(partlist),
        "NewPartsModelFlag:=", "Model"
    ]

    rotateparametersarray = [
        "NAME:RotateParameters", "RotateAxis:=", axis, "RotateAngle:=",
        Ex(angle).expr
    ]

    oEditor.Rotate(selectionsarray, rotateparametersarray)
Example #4
0
def fillet(oEditor, partlist, edgelist, radius, vertexlist=[], setback=0):
    """
    Create fillets on the given edges.
    
    Parameters
    ----------
    oEditor : pywin32 COMObject
        The HFSS editor in which the operation will be performed.
    partlist : list of strings
        List of part name strings to be filleted.
    edgelist : list of ints
        List of edge indexes to be filleted.
    radius : float
        Radius of the fillet.
    vertexlist : list
        List of vertices to chamfer
    setback : float
        The setback distance.  See the HFSS help for an explanation of this 
        parameter.
    
    Returns
    -------
    None
    
    Examples
    --------
    >>> import Hyphasis as hfss
    >>> [oAnsoftApp, oDesktop] = hfss.setup_interface()
    >>> oProject = hfss.new_project(oDesktop)
    >>> oDesign = hfss.insert_design(oProject, "HFSSDesign1", "DrivenModal")
    >>> oEditor = hfss.set_active_editor(oDesign, "3D Modeler")
    >>> box1 = hfss.create_box(oEditor, 1, 1, 1, 0, 0, 0)
    >>> edge1 = hfss.get_edge_by_position(oEditor, box1, 0.5, 0, 0)
    >>> hfss.fillet(oEditor, [box1], [edge1], 0.25)
    
    """
    selectionsarray = [
        "NAME:Selections", "Selections:=", ','.join(partlist),
        "NewPartsModelFlag:=", "Model"
    ]

    tempparams = [
        "NAME:FilletParameters", "Edges:=", edgelist, "Vertices:=", vertexlist,
        "Radius:=",
        Ex(radius).expr, "Setback:=",
        str(setback)
    ]

    filletparameters = ["NAME:Parameters", tempparams]

    oEditor.Fillet(selectionsarray, filletparameters)
Example #5
0
def sweep_along_vector(oEditor, obj_name_list, x, y, z):
    """
    Sweeps the specified 1D or 2D parts along a vector.
    
    Parameters
    ----------
    oEditor : pywin32 COMObject
        The HFSS editor in which the operation will be performed.
    obj_name_list : list
        List of part name strings to be scaled.
    x : float
        x component of the sweep vector.
    y : float
        y component of the sweep vector.
    z : float
        z component of the sweep vector.
        
    Returns
    -------
    None
    """
    selections = ", ".join(obj_name_list)

    #    print(selections)

    oEditor.SweepAlongVector([
        "NAME:Selections", "Selections:=", selections, "NewPartsModelFlag:=",
        "Model"
    ], [
        "NAME:VectorSweepParameters", "DraftAngle:=", "0deg", "DraftType:=",
        "Round", "CheckFaceFaceIntersection:=", False, "SweepVectorX:=",
        Ex(x).expr, "SweepVectorY:=",
        Ex(y).expr, "SweepVectorZ:=",
        Ex(z).expr
    ])

    return get_selections(oEditor)
Example #6
0
def create_rectangle(oEditor,
                     xs,
                     ys,
                     zs,
                     width,
                     height,
                     WhichAxis='Z',
                     Name='Rectangle1',
                     Flags='',
                     Color=(132, 132, 193),
                     Transparency=0,
                     PartCoordinateSystem='Global',
                     UDMId='',
                     MaterialValue='"vacuum"',
                     SolveInside=True,
                     IsCovered=True):
    """
    Draw a rectangle.
    
    Parameters
    ----------
    oEditor : pywin32 COMObject
        The HFSS editor in which the operation will be performed.
    xs : float or hycohanz Expression object
    ys : float or hycohanz Expression object
    zs : float or hycohanz Expression object
        The x, y, and z coordinates of the center of the circle.
    width : float or hycohanz Expression object
        x-dimension of the rectangle
    height : float or hycohanz Expression object
        y-dimension of the rectangle
    WhichAxis : str
        The axis normal to the circle.  Can be 'X', 'Y', or 'Z'.
    Name : str
        The requested name of the object.  If this is not available, HFSS 
        will assign a different name, which is returned by this function.
    Flags : str
        Flags associated with this object.  See HFSS Scripting Guide for details.
    Color : tuple of length=3
        RGB components of the circle
    Transparency : float between 0 and 1
        Fractional transparency.  0 is opaque and 1 is transparent.
    PartCoordinateSystem : str
        The name of the coordinate system in which the object is drawn.
    MaterialName : str
        Name of the material to assign to the object.  Name must be surrounded 
        by double quotes.
    SolveInside : bool
        Whether to mesh the interior of the object and solve for the fields 
        inside.
    IsCovered : bool
        Whether the rectangle is has a surface or has only edges.
        
    Returns
    -------
    str
        The actual name of the created object.
        
    """
    RectangleParameters = [
        "NAME:RectangleParameters", "IsCovered:=", IsCovered, "XStart:=",
        Ex(xs).expr, "YStart:=",
        Ex(ys).expr, "ZStart:=",
        Ex(zs).expr, "Width:=",
        Ex(width).expr, "Height:=",
        Ex(height).expr, "WhichAxis:=", WhichAxis
    ]

    Attributes = [
        "NAME:Attributes", "Name:=", Name, "Flags:=", Flags, "Color:=",
        "({r} {g} {b})".format(r=Color[0], g=Color[1],
                               b=Color[2]), "Transparency:=", Transparency,
        "PartCoordinateSystem:=", PartCoordinateSystem, "UDMId:=", UDMId,
        "MaterialValue:=", MaterialValue, "SolveInside:=", SolveInside
    ]

    return oEditor.CreateRectangle(RectangleParameters, Attributes)
Example #7
0
def create_box(
    oEditor,
    xpos,
    ypos,
    zpos,
    xsize,
    ysize,
    zsize,
    Name='Box1',
    Flags='',
    Color=(132, 132, 193),
    Transparency=0,
    PartCoordinateSystem='Global',
    UDMId='',
    MaterialValue='"vacuum"',
    SolveInside=True,
    IsCovered=True,
):
    """
    Draw a 3D box.

    Note:  This function was contributed by C. A. Donado Morcillo.

    Parameters
    ----------
    oEditor : pywin32 COMObject
        The HFSS editor in which the operation will be performed.
    xpos : float or hycohanz Expression object
    ypos : float or hycohanz Expression object
    zpos : float or hycohanz Expression object
        The x, y, and z coordinates of the base point of the box.
    xsize : float or hycohanz Expression object
    ysize : float or hycohanz Expression object
    zsize : float or hycohanz Expression object
        x-, y-, and z-dimensions of the box
    Name : str
        The requested name of the object.  If this is not available, HFSS 
        will assign a different name, which is returned by this function.
    Flags : str
        Flags associated with this object.  See HFSS Scripting Guide for details.
    Color : tuple of length=3
        RGB components of the circle
    Transparency : float between 0 and 1
        Fractional transparency.  0 is opaque and 1 is transparent.
    PartCoordinateSystem : str
        The name of the coordinate system in which the object is drawn.
    MaterialName : str
        Name of the material to assign to the object.  Name must be surrounded 
        by double quotes.
    SolveInside : bool
        Whether to mesh the interior of the object and solve for the fields 
        inside.
    IsCovered : bool
        Whether the rectangle is has a surface or has only edges.

    Returns
    -------
    str
        The actual name of the created object.

    """
    BoxParameters = [
        "NAME:BoxParameters", "XPosition:=",
        Ex(xpos).expr, "YPosition:=",
        Ex(ypos).expr, "ZPosition:=",
        Ex(zpos).expr, "XSize:=",
        Ex(xsize).expr, "YSize:=",
        Ex(ysize).expr, "ZSize:=",
        Ex(zsize).expr
    ]

    Attributes = [
        "NAME:Attributes", "Name:=", Name, "Flags:=", Flags, "Color:=",
        "({r} {g} {b})".format(r=Color[0], g=Color[1],
                               b=Color[2]), "Transparency:=", Transparency,
        "PartCoordinateSystem:=", PartCoordinateSystem, "UDMId:=", UDMId,
        "MaterialValue:=", MaterialValue, "SolveInside:=", SolveInside
    ]

    return oEditor.CreateBox(BoxParameters, Attributes)
Example #8
0
def create_sphere(oEditor,
                  x,
                  y,
                  z,
                  radius,
                  Name="Sphere1",
                  Flags="",
                  Color=(132, 132, 193),
                  Transparency=0,
                  PartCoordinateSystem="Global",
                  UDMId="",
                  MaterialValue='"vacuum"',
                  SolveInside=True):
    """
    Create a sphere primitive.
    
    Parameters
    ----------
    oEditor : pywin32 COMObject
        The HFSS editor in which the operation will be performed.
    x : float or hycohanz Expression object
        x position in Cartesian coordinates.
    y : float or hycohanz Expression object
        y position in Cartesian coordinates.
    z : float or hycohanz Expression object
        z position in Cartesian coordinates.
    radius : float
        The sphere radius.
    Name : str
        The requested name of the object.  HFSS doesn't necessarily honor this.
    Flags : str
        Flags to attach to the object.  See the HFSS help for explanation 
        of this parameter.
    Color : tuple of ints
        The RGB indices corresponding to the desired color of the object.
    Transparency : float between 0 and 1
        Fractional transparency.  0 is opaque and 1 is transparent.
    PartCoordinateSystem : str
        The name of the coordinate system in which the object is drawn.
    UDMId : str
        Unknown use.  See HFSS documentation for explanation.
    MaterialValue : str
        Name of the material to assign to the object
    SolveInside : bool
        Whether to mesh the interior of the object and solve for the fields 
        inside.
        
    Returns
    -------
    part : str
        The actual name assigned by HFSS to the part.
        
    """
    sphereparametersarray = [
        "NAME:SphereParameters", "XCenter:=",
        Ex(x).expr, "YCenter:=",
        Ex(y).expr, "ZCenter:=",
        Ex(z).expr, "Radius:=",
        Ex(radius).expr
    ]

    attributesarray = [
        "NAME:Attributes", "Name:=", Name, "Flags:=", Flags, "Color:=",
        "({r} {g} {b})".format(r=Color[0], g=Color[1],
                               b=Color[2]), "Transparency:=", Transparency,
        "PartCoordinateSystem:=", PartCoordinateSystem, "UDMId:=", UDMId,
        "MaterialValue:=", MaterialValue, "SolveInside:=", SolveInside
    ]

    part = oEditor.CreateSphere(sphereparametersarray, attributesarray)

    return part
Example #9
0
def create_circle(oEditor,
                  xc,
                  yc,
                  zc,
                  radius,
                  WhichAxis='Z',
                  NumSegments=0,
                  Name='Circle1',
                  Flags='',
                  Color=(132, 132, 193),
                  Transparency=0,
                  PartCoordinateSystem='Global',
                  MaterialName='"vacuum"',
                  Solveinside=True):
    """
    Create a circle primitive.
    
    Parameters
    ----------
    oEditor : pywin32 COMObject
        The HFSS editor in which the operation will be performed.
    xc : float or hycohanz Expression object
    yc : float or hycohanz Expression object
    zc : float or hycohanz Expression object
        The x, y, and z coordinates of the center of the circle.
    radius : float
        The radius of the circle.
    WhichAxis : str
        The axis normal to the circle.  Can be 'X', 'Y', or 'Z'.
    NumSegments : int
        If 0, the circle is not segmented.  Otherwise, the circle is 
        segmented into NumSegments sides.
    Name : str
        The requested name of the object.  If this is not available, HFSS 
        will assign a different name, which is returned by this function.
    Flags : str
        Flags associated with this object.  See HFSS help for details.
    Color : tuple of length=3
        RGB components of the circle
    Transparency : float between 0 and 1
        Fractional transparency.  0 is opaque and 1 is transparent.
    PartCoordinateSystem : str
        The name of the coordinate system in which the object is drawn.
    MaterialName : str
        Name of the material to assign to the object.  Name must be surrounded 
        by double quotes.
    SolveInside : bool
        Whether to mesh the interior of the object and solve for the fields 
        inside.
        
    Returns
    -------
    str
        The actual name of the created object.
    """
    circleparams = [
        "NAME:CircleParameters", "XCenter:=",
        Ex(xc).expr, "YCenter:=",
        Ex(yc).expr, "ZCenter:=",
        Ex(zc).expr, "Radius:=",
        Ex(radius).expr, "WhichAxis:=",
        str(WhichAxis), "NumSegments:=",
        str(NumSegments)
    ]

    attributesarray = [
        "NAME:Attributes", "Name:=", Name, "Flags:=",
        Flags, "Color:=", "({r} {g} {b})".format(r=Color[0],
                                                 g=Color[1],
                                                 b=Color[2]), "Transparency:=",
        str(Transparency), "PartCoordinateSystem:=", PartCoordinateSystem,
        "MaterialName:=", MaterialName, "Solveinside:=", Solveinside
    ]

    return oEditor.CreateCircle(circleparams, attributesarray)