Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REFACTOR: removed is_ironpython and inside_desktop variables as it is not anymore #661

Merged
merged 8 commits into from
Jul 11, 2024
71 changes: 9 additions & 62 deletions src/pyedb/dotnet/edb.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@
from pathlib import Path
import re
import shutil
import subprocess
import sys
import tempfile
import time
import traceback
from typing import Union
import warnings

import rtree

from pyedb.configuration.configuration import Configuration
from pyedb.dotnet.application.Variables import decompose_variable_value
from pyedb.dotnet.edb_core.cell.layout import Layout
Expand Down Expand Up @@ -95,8 +98,6 @@
from pyedb.generic.general_methods import (
generate_unique_name,
get_string_version,
inside_desktop,
is_ironpython,
is_linux,
is_windows,
)
Expand All @@ -106,13 +107,6 @@
from pyedb.modeler.geometry_operators import GeometryOperators
from pyedb.workflow import Workflow

if is_linux and is_ironpython:
import subprocessdotnet as subprocess
else:
import subprocess

import rtree


class Edb(Database):
"""Provides the EDB application interface.
Expand Down Expand Up @@ -227,8 +221,6 @@ def __init__(
if not isreadonly:
self._check_remove_project_files(edbpath, remove_existing_aedt)

if isaedtowned and (inside_desktop or settings.remote_rpc_session):
self.open_edb_inside_aedt()
elif edbpath[-3:] in ["brd", "mcm", "sip", "gds", "xml", "dxf", "tgz", "anf"]:
self.edbpath = edbpath[:-4] + ".aedb"
working_dir = os.path.dirname(edbpath)
Expand Down Expand Up @@ -553,40 +545,6 @@ def open_edb(self):

return True

def open_edb_inside_aedt(self):
"""Open EDB inside AEDT.

Returns
-------
``True`` when succeed ``False`` if failed : bool

"""
self.logger.info("Opening EDB from HDL")
self.run_as_standalone(False)
if self.oproject.GetEDBHandle():
self.attach(self.oproject.GetEDBHandle())
if not self.active_db:
self.logger.warning("Error getting the database.")
self._active_cell = None
return None
self._active_cell = self.edb_api.cell.cell.FindByName(
self.active_db,
self.edb_api.cell._cell.CellType.CircuitCell,
self.cellname,
)
if self._active_cell is None:
self._active_cell = list(self.top_circuit_cells)[0]
if self._active_cell:
if not os.path.exists(self.edbpath):
os.makedirs(self.edbpath)
self._init_objects()
return True
else:
return None
else:
self._active_cell = None
return None

def create_edb(self):
"""Create EDB.

Expand Down Expand Up @@ -2197,9 +2155,6 @@ def _create_cutout_multithread(
keep_lines_as_path=False,
inlcude_voids_in_extents=False,
):
if is_ironpython: # pragma: no cover
self.logger.error("Method working only in Cpython")
return False
from concurrent.futures import ThreadPoolExecutor

if output_aedb_path:
Expand Down Expand Up @@ -2729,20 +2684,12 @@ def _create_cutout_on_point_list(

for void_circle in voids_to_add:
if void_circle.type == "Circle":
if is_ironpython: # pragma: no cover
(
res,
center_x,
center_y,
radius,
) = void_circle.primitive_object.GetParameters()
else:
(
res,
center_x,
center_y,
radius,
) = void_circle.primitive_object.GetParameters(0.0, 0.0, 0.0)
(
res,
center_x,
center_y,
radius,
) = void_circle.primitive_object.GetParameters(0.0, 0.0, 0.0)
cloned_circle = self.edb_api.cell.primitive.circle.create(
layout,
void_circle.layer_name,
Expand Down
18 changes: 8 additions & 10 deletions src/pyedb/dotnet/edb_core/cell/hierarchy/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,14 @@
from pyedb.dotnet.edb_core.cell.hierarchy.spice_model import SpiceModel
from pyedb.dotnet.edb_core.definition.package_def import PackageDef
from pyedb.dotnet.edb_core.edb_data.padstacks_data import EDBPadstackInstance
from pyedb.generic.general_methods import is_ironpython

if not is_ironpython:
try:
import numpy as np
except ImportError:
warnings.warn(
"The NumPy module is required to run some functionalities of EDB.\n"
"Install with \n\npip install numpy\n\nRequires CPython."
)

try:
import numpy as np
except ImportError:
warnings.warn(
"The NumPy module is required to run some functionalities of EDB.\n"
"Install with \n\npip install numpy\n\nRequires CPython."
)
from pyedb.generic.general_methods import get_filename_without_extension


Expand Down
15 changes: 5 additions & 10 deletions src/pyedb/dotnet/edb_core/dotnet/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
env_path,
env_path_student,
env_value,
is_ironpython,
is_linux,
settings,
)
Expand Down Expand Up @@ -751,14 +750,10 @@ def __init__(self, edbversion, student_version=False):
self.base_path = edb_path
sys.path.append(edb_path)
os.environ[env_value(self.edbversion)] = self.base_path
if is_ironpython:
_clr.AddReferenceToFile("Ansys.Ansoft.Edb.dll")
_clr.AddReferenceToFile("Ansys.Ansoft.EdbBuilderUtils.dll")
_clr.AddReferenceToFileAndPath(os.path.join(self.base_path, "Ansys.Ansoft.SimSetupData.dll"))
else:
_clr.AddReference("Ansys.Ansoft.Edb")
_clr.AddReference("Ansys.Ansoft.EdbBuilderUtils")
_clr.AddReference("Ansys.Ansoft.SimSetupData")

_clr.AddReference("Ansys.Ansoft.Edb")
_clr.AddReference("Ansys.Ansoft.EdbBuilderUtils")
_clr.AddReference("Ansys.Ansoft.SimSetupData")
else:
if settings.edb_dll_path:
self.base_path = settings.edb_dll_path
Expand Down Expand Up @@ -1234,7 +1229,7 @@ def attach(self, hdb): # pragma no cover
-------

"""
from pyedb.generic.clr_module import Convert
from pyedb.dotnet.clr_module import Convert

hdl = Convert.ToUInt64(hdb)
self._db = self.edb_api.database.Attach(hdl)
Expand Down
14 changes: 2 additions & 12 deletions src/pyedb/dotnet/edb_core/edb_data/control_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,14 @@
import copy
import os
import re
import subprocess
import sys

from pyedb.edb_logger import pyedb_logger
from pyedb.generic.general_methods import (
ET,
env_path,
env_value,
is_ironpython,
is_linux,
)
from pyedb.generic.general_methods import ET, env_path, env_value, is_linux
from pyedb.misc.aedtlib_personalib_install import write_pretty_xml
from pyedb.misc.misc import list_installed_ansysem

if is_linux and is_ironpython:
import subprocessdotnet as subprocess
else:
import subprocess


def convert_technology_file(tech_file, edbversion=None, control_file=None):
"""Convert a technology file to edb control file (xml).
Expand Down
47 changes: 17 additions & 30 deletions src/pyedb/dotnet/edb_core/edb_data/padstacks_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
import re
import warnings

from pyedb.dotnet.clr_module import String, _clr
from pyedb.dotnet.clr_module import String
from pyedb.dotnet.edb_core.cell.primitive import Primitive
from pyedb.dotnet.edb_core.dotnet.database import PolygonDataDotNet
from pyedb.dotnet.edb_core.edb_data.edbvalue import EdbValue
from pyedb.dotnet.edb_core.general import PadGeometryTpe, convert_py_list_to_net_list
from pyedb.generic.general_methods import generate_unique_name, is_ironpython
from pyedb.generic.general_methods import generate_unique_name
from pyedb.modeler.geometry_operators import GeometryOperators


Expand Down Expand Up @@ -1403,17 +1403,12 @@ def backdrill_top(self):
layer = self._pedb.edb_api.cell.layer("", self._pedb.edb_api.cell.layer_type.SignalLayer)
val = self._pedb.edb_value(0)
offset = self._pedb.edb_value(0.0)
if is_ironpython: # pragma: no cover
diameter = _clr.StrongBox[type(val)]()
drill_to_layer = _clr.StrongBox[self._pedb.edb_api.Cell.ILayerReadOnly]()
flag = self._edb_padstackinstance.GetBackDrillParametersLayerValue(drill_to_layer, offset, diameter, False)
else:
(
flag,
drill_to_layer,
offset,
diameter,
) = self._edb_padstackinstance.GetBackDrillParametersLayerValue(layer, offset, val, False)
(
flag,
drill_to_layer,
offset,
diameter,
) = self._edb_padstackinstance.GetBackDrillParametersLayerValue(layer, offset, val, False)
if flag:
if offset.ToDouble():
return drill_to_layer.GetName(), diameter.ToString(), offset.ToString()
Expand Down Expand Up @@ -1461,17 +1456,12 @@ def backdrill_bottom(self):
layer = self._pedb.edb_api.cell.layer("", self._pedb.edb_api.cell.layer_type.SignalLayer)
val = self._pedb.edb_value(0)
offset = self._pedb.edb_value(0.0)
if is_ironpython: # pragma: no cover
diameter = _clr.StrongBox[type(val)]()
drill_to_layer = _clr.StrongBox[self._pedb.edb_api.Cell.ILayerReadOnly]()
flag = self._edb_padstackinstance.GetBackDrillParametersLayerValue(drill_to_layer, offset, diameter, True)
else:
(
flag,
drill_to_layer,
offset,
diameter,
) = self._edb_padstackinstance.GetBackDrillParametersLayerValue(layer, offset, val, True)
(
flag,
drill_to_layer,
offset,
diameter,
) = self._edb_padstackinstance.GetBackDrillParametersLayerValue(layer, offset, val, True)
if flag:
if offset.ToDouble():
return drill_to_layer.GetName(), diameter.ToString(), offset.ToString()
Expand Down Expand Up @@ -1751,12 +1741,9 @@ def aedt_name(self):
>>> edbapp.padstacks.instances[111].get_aedt_pin_name()

"""
if is_ironpython:
name = _clr.Reference[String]()
self._edb_padstackinstance.GetProductProperty(self._pedb.edb_api.ProductId.Designer, 11, name)
else:
val = String("")
_, name = self._edb_padstackinstance.GetProductProperty(self._pedb.edb_api.ProductId.Designer, 11, val)

val = String("")
_, name = self._edb_padstackinstance.GetProductProperty(self._pedb.edb_api.ProductId.Designer, 11, val)
name = str(name).strip("'")
return name

Expand Down
15 changes: 6 additions & 9 deletions src/pyedb/dotnet/edb_core/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,12 @@
import logging

from pyedb.dotnet.clr_module import Dictionary, List, Tuple
from pyedb.generic.general_methods import is_ironpython

if not is_ironpython: # pragma: no cover
try:
from enum import Enum
except ImportError:
Enum = None
else: # pragma: no cover
Enum = object

try:
from enum import Enum
except ImportError:
Enum = None


logger = logging.getLogger(__name__)

Expand Down
12 changes: 4 additions & 8 deletions src/pyedb/dotnet/edb_core/hfss.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
convert_pytuple_to_nettuple,
)
from pyedb.generic.constants import RadiationBoxType, SweepType
from pyedb.generic.general_methods import generate_unique_name, is_ironpython
from pyedb.generic.general_methods import generate_unique_name
from pyedb.modeler.geometry_operators import GeometryOperators


Expand Down Expand Up @@ -1258,13 +1258,9 @@ def configure_hfss_analysis_setup(self, simulation_setup=None):
adapt.AdaptiveFrequency = simulation_setup.mesh_freq
adapt.MaxPasses = int(simulation_setup.max_num_passes)
adapt.MaxDelta = str(simulation_setup.max_mag_delta_s)
if is_ironpython:
simsetup_info.SimulationSettings.AdaptiveSettings.AdaptiveFrequencyDataList.Clear()
simsetup_info.SimulationSettings.AdaptiveSettings.AdaptiveFrequencyDataList.Add(adapt)
else:
simsetup_info.SimulationSettings.AdaptiveSettings.AdaptiveFrequencyDataList = (
convert_py_list_to_net_list([adapt])
)
simsetup_info.SimulationSettings.AdaptiveSettings.AdaptiveFrequencyDataList = convert_py_list_to_net_list(
[adapt]
)
elif simulation_setup.ac_settings.adaptive_type == 2:
low_freq_adapt_data = self._pedb.simsetupdata.AdaptiveFrequencyData()
low_freq_adapt_data.MaxDelta = str(simulation_setup.max_mag_delta_s)
Expand Down
15 changes: 4 additions & 11 deletions src/pyedb/dotnet/edb_core/materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@
from pydantic import BaseModel, confloat

from pyedb import Edb
from pyedb.dotnet.clr_module import _clr
from pyedb.dotnet.edb_core.general import convert_py_list_to_net_list
from pyedb.exceptions import MaterialModelException
from pyedb.generic.general_methods import is_ironpython

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -426,16 +424,11 @@ def __load_all_properties(self):

def __property_value(self, material_property_id):
"""Get property value from a material property id."""
if is_ironpython: # pragma: no cover
property_box = _clr.StrongBox[float]()
self.__material_def.GetProperty(material_property_id, property_box)
return float(property_box)
_, property_box = self.__material_def.GetProperty(material_property_id)
if isinstance(property_box, float):
return property_box
else:
_, property_box = self.__material_def.GetProperty(material_property_id)
if isinstance(property_box, float):
return property_box
else:
return property_box.ToDouble()
return property_box.ToDouble()

# def __reset_property(self, name):
# """Reset a property using the default value of the EDB API.
Expand Down
5 changes: 1 addition & 4 deletions src/pyedb/dotnet/edb_core/nets.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

from pyedb.dotnet.edb_core.edb_data.nets_data import EDBNetsData
from pyedb.generic.constants import CSS4_COLORS
from pyedb.generic.general_methods import generate_unique_name, is_ironpython
from pyedb.generic.general_methods import generate_unique_name
from pyedb.modeler.geometry_operators import GeometryOperators


Expand Down Expand Up @@ -838,9 +838,6 @@ def plot(
show : bool, optional
Whether to show the plot or not. Default is `True`.
"""
if is_ironpython:
self._logger.warning("Plot functionalities are enabled only in CPython.")
return False
from pyedb.generic.plot import plot_matplotlib

object_lists = self.get_plot_data(
Expand Down
Loading
Loading