Skip to content

Commit

Permalink
FEAT: add twinbuilder apis (#5265)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Samuelopez-ansys <samuel.lopez@ansys.com>
  • Loading branch information
3 people authored Oct 9, 2024
1 parent 1704762 commit 31e36ea
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
6 changes: 6 additions & 0 deletions _unittest/test_34_TwinBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,9 @@ def test_16_add_sml_component(self, local_scratch):
rom1 = self.aedtapp.modeler.schematic.create_component("ROM1", "", "Thermal_ROM_SML")

assert self.aedtapp.modeler.schematic.update_quantity_value(rom1.composed_name, "Input2_HeatFlow", "1")

def test_17_create_subsheet(self, local_scratch):
self.aedtapp.insert_design("SML")
self.aedtapp.create_subsheet("subsheet", "parentsheet")
assert "parentsheet" in self.aedtapp.design_list
assert len(self.aedtapp.odesign.GetSubDesigns()) > 0
11 changes: 8 additions & 3 deletions src/ansys/aedt/core/modeler/circuits/primitives_twin_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ def components_catalog(self):
self._components_catalog = ComponentCatalog(self)
return self._components_catalog

@property
def o_simmodel_manager(self):
"""Simulation models manager object."""
return self.o_definition_manager.GetManager("SimModel")

@pyaedt_function_handler(compname="name")
def create_resistor(self, name=None, value=50, location=None, angle=0, use_instance_id_netlist=False):
"""Create a resistor.
Expand Down Expand Up @@ -526,14 +531,14 @@ def create_component_from_sml(

@pyaedt_function_handler()
def update_quantity_value(self, component_name, name, value, netlist_units=""):
"""Change the property value of a component.
"""Change the quantity value of a component.
Parameters
----------
component_name : str
Component name.
name : str
Property name.
Quantity name.
value : str
Value of the quantity.
netlist_units : str, optional
Expand Down Expand Up @@ -586,5 +591,5 @@ def update_quantity_value(self, component_name, name, value, netlist_units=""):
)
return True
except Exception: # pragma: no cover
self.logger.warning(f"Property {name} has not been edited. Check if readonly.")
self.logger.warning(f"Quantity {name} has not been edited. Check if readonly.")
return False
32 changes: 32 additions & 0 deletions src/ansys/aedt/core/twinbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,38 @@ def set_sim_setup_parameter(self, variable, expression, analysis_name="TR"):
)
return True

@pyaedt_function_handler()
def create_subsheet(self, name, design_name):
"""Create a subsheet from a parent design. If the parent design does not exist, it will add at top level. Nested
subsheets are currently not supported.
Parameters
----------
name : str
Name of the subsheet.
design_name : str
Name of the parent design.
Returns
-------
bool
``True`` when successful, ``False`` when failed.
Examples
--------
>>> from ansys.aedt.core import TwinBuilder
>>> tb = TwinBuilder(version="2025.1")
>>> tb.create_subsheet('subsheet', 'parentdesign')
"""
try:
if design_name not in self.design_list:
self.insert_design(name=design_name)
self.odesign.InsertDesign("Twin Builder", name, "", design_name + ":U1")
return True
except Exception: # pragma: no cover
self.logger.warning(f"The Subsheet {name} has not been created.")
return False

@pyaedt_function_handler(setup_name="setup", sweep_name="sweep")
def add_q3d_dynamic_component(
self,
Expand Down

0 comments on commit 31e36ea

Please sign in to comment.