Skip to content

Commit

Permalink
WIP: pyedb legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
SMoraisAnsys committed Oct 16, 2023
1 parent 0c9aba9 commit b4e62e4
Show file tree
Hide file tree
Showing 71 changed files with 2,858 additions and 1,077 deletions.
4 changes: 2 additions & 2 deletions doc/source/Getting_started/Contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ These examples demonstrate how to write messages only to the log file:
Handle exceptions
~~~~~~~~~~~~~~~~~
PyAEDT uses a specific decorator, ``@pyaedt_function_handler``,
PyAEDT uses a specific decorator, ``@pyedb_function_handler()``,
to handle exceptions caused by methods and by the AEDT API.
This exception handler decorator makes PyAEDT fault tolerant
to errors that can occur in any method.
Expand All @@ -106,7 +106,7 @@ For example:

.. code:: python
@pyaedt_function_handler()
@pyedb_function_handler()
def my_method(self, var):
pass
Expand Down
100 changes: 100 additions & 0 deletions examples/legacy/00_EDB_Create_VIA.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
"""
EDB: geometry creation
----------------------
This example shows how you can use EDB to create a layout.
"""
######################################################################
# Final expected project
# ~~~~~~~~~~~~~~~~~~~~~~
#
# .. image:: ../../_static/diff_via.png
# :width: 600
# :alt: Differential Vias.
######################################################################

######################################################################
# Import EDB layout object
# ~~~~~~~~~~~~~~~~~~~~~~~~
# Import the EDB layout object and initialize it on version 2023 R2.
######################################################################

import time
import os
import pyedb

start = time.time()

aedb_path = os.path.join(pyedb.generate_unique_folder_name(), pyedb.generate_unique_name("pcb") + ".aedb")
# print(aedb_path)
# edb = pyedb.Edb(edbpath=aedb_path, edbversion="2023.2")
edb = pyedb.Edb()
edb.save_edb_as(aedb_path)


####################
# Add stackup layers
# ~~~~~~~~~~~~~~~~~~
# Add stackup layers.
# A stackup can be created layer by layer or imported from a csv file or xml file.
#

edb.stackup.add_layer("GND")
edb.stackup.add_layer("Diel", "GND", layer_type="dielectric", thickness="0.1mm", material="FR4_epoxy")
edb.stackup.add_layer("TOP", "Diel", thickness="0.05mm")

#####################################
# Create signal net and ground planes
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Create a signal net and ground planes.

points = [
[0.0, 0],
[100e-3, 0.0],
]
edb.modeler.create_trace(points, "TOP", width=1e-3)
points = [[0.0, 1e-3], [0.0, 10e-3], [100e-3, 10e-3], [100e-3, 1e-3], [0.0, 1e-3]]
edb.modeler.create_polygon(points, "TOP")

points = [[0.0, -1e-3], [0.0, -10e-3], [100e-3, -10e-3], [100e-3, -1e-3], [0.0, -1e-3]]
edb.modeler.create_polygon(points, "TOP")

#######################################
# Create vias with parametric positions
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Create vias with parametric positions.

edb.padstacks.create("MyVia")
edb.padstacks.place([5e-3, 5e-3], "MyVia")
edb.padstacks.place([15e-3, 5e-3], "MyVia")
edb.padstacks.place([35e-3, 5e-3], "MyVia")
edb.padstacks.place([45e-3, 5e-3], "MyVia")
edb.padstacks.place([5e-3, -5e-3], "MyVia")
edb.padstacks.place([15e-3, -5e-3], "MyVia")
edb.padstacks.place([35e-3, -5e-3], "MyVia")
edb.padstacks.place([45e-3, -5e-3], "MyVia")


#######################################
# Geometry Plot
# ~~~~~~~~~~~~~
#
edb.nets.plot(None, color_by_net=True)

#######################################
# Stackup Plot
# ~~~~~~~~~~~~
#
edb.stackup.plot(plot_definitions="MyVia")


####################
# Save and close EDB
# ~~~~~~~~~~~~~~~~~~
# Save and close EDB.

if edb:
edb.save_edb()
edb.close_edb()
print("EDB saved correctly to {}. You can import in AEDT.".format(aedb_path))
end = time.time() - start
print(end)
46 changes: 45 additions & 1 deletion src/pyedb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import os

if os.name == "nt":
Expand All @@ -9,4 +10,47 @@

version = __version__

from pyedb.generic.design_types import Edb
from pyedb.generic.design_types import Edb


# import pyedb.legacy.downloads as downloads
# from pyedb.generic import constants
# import pyedb.generic.DataHandlers as data_handler
# import pyedb.generic.general_methods as general_methods
from pyedb.generic.general_methods import _pythonver
from pyedb.generic.general_methods import _retry_ntimes
from pyedb.generic.general_methods import generate_unique_folder_name
from pyedb.generic.general_methods import generate_unique_name
from pyedb.generic.general_methods import generate_unique_project_name
from pyedb.generic.general_methods import inside_desktop
from pyedb.generic.general_methods import is_ironpython
from pyedb.generic.general_methods import is_linux
from pyedb.generic.general_methods import is_windows
from pyedb.generic.general_methods import online_help
from pyedb.generic.general_methods import pyedb_function_handler
from pyedb.generic.general_methods import settings

# try:
# from pyedb.generic.design_types import Hfss3dLayout
# except:
# from pyedb.generic.design_types import Hfss3dLayout
# from pyedb.generic.design_types import Circuit
# from pyedb.generic.design_types import Desktop
# from pyedb.generic.design_types import Emit
# from pyedb.generic.design_types import Hfss
# from pyedb.generic.design_types import Icepak
# from pyedb.generic.design_types import Maxwell2d
# from pyedb.generic.design_types import Maxwell3d
# from pyedb.generic.design_types import MaxwellCircuit
# from pyedb.generic.design_types import Mechanical
# from pyedb.generic.design_types import Q2d
# from pyedb.generic.design_types import Q3d
# from pyedb.generic.design_types import Rmxprt
# from pyedb.generic.design_types import Simplorer
# from pyedb.generic.design_types import Siwave
# from pyedb.generic.design_types import TwinBuilder
# from pyedb.generic.design_types import get_pyedb_app
# from pyedb.generic.design_types import launch_desktop
from pyedb.misc.misc import current_student_version
from pyedb.misc.misc import current_version
from pyedb.misc.misc import installed_versions
Loading

0 comments on commit b4e62e4

Please sign in to comment.