Skip to content

Commit

Permalink
Add remove_node_positions
Browse files Browse the repository at this point in the history
  • Loading branch information
mph- committed Nov 5, 2024
1 parent 57777f3 commit ba909b3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 11 additions & 0 deletions lcapy/netlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,17 @@ def remove(self, name):
self._elements.pop(name, None)
return self

def remove_node_positions(self):
"""Remove explicit node positions added by lcapy-tk."""

new = self._new()

for cpt in self._elements.values():
if cpt.is_directive and 'nodes' in cpt.opts:
continue
new.add(cpt._copy())
return new

def annotate(self, cpts, *args, **kwargs):
"""Annotate a particular component (or list of components)
with specified schematic attributes and return new netlist.
Expand Down
5 changes: 4 additions & 1 deletion lcapy/scripts/schtex.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def main(argv=None):
parser.add_argument('--postamble', type=str, default=None,
help='specify circuitikz commands at end')

parser.add_argument('--remove-positions', action='store_true',
parser.add_argument('--remove-node-positions', action='store_true',
default=False,
help="remove explicit node positions; these will be inferred")

Expand Down Expand Up @@ -261,6 +261,9 @@ def main(argv=None):
if args.sympify:
cct = cct.sympify()

if args.remove_node_positions:
cct = cct.remove_node_positions()

if args.label_nodes not in ('none', 'all', 'alpha', 'pins', 'primary', False, None):
raise ValueError('Illegal option %s for label_nodes' %
args.label_nodes)
Expand Down

0 comments on commit ba909b3

Please sign in to comment.