5454from pyedb .grpc .database .hierarchy .component import Component
5555from pyedb .grpc .database .hierarchy .pin_pair_model import PinPairModel
5656from pyedb .grpc .database .hierarchy .pingroup import PinGroup
57+ from pyedb .grpc .database .padstacks import Padstacks
5758from pyedb .grpc .database .utility .sources import SourceType
5859from pyedb .modeler .geometry_operators import GeometryOperators
5960
@@ -119,34 +120,17 @@ def __getitem__(self, name):
119120
120121 def __init__ (self , p_edb ):
121122 self ._pedb = p_edb
122- self ._cmp = {}
123- self ._res = {}
124- self ._cap = {}
125- self ._ind = {}
126- self ._ios = {}
127- self ._ics = {}
128- self ._others = {}
123+ self .refresh_components ()
129124 self ._pins = {}
130125 self ._comps_by_part = {}
131- self ._init_parts ()
132- # self._padstack = Padstacks(self._pedb)
126+ self ._padstack = Padstacks (self ._pedb )
133127 # self._excitations = self._pedb.excitations
134128
135129 @property
136130 def _logger (self ):
137131 """Logger."""
138132 return self ._pedb .logger
139133
140- def _init_parts (self ):
141- a = self .instances
142- a = self .resistors
143- a = self .ICs
144- a = self .Others
145- a = self .inductors
146- a = self .IOs
147- a = self .components_by_partname
148- return True
149-
150134 @property
151135 def _active_layout (self ):
152136 return self ._pedb .active_layout
@@ -180,8 +164,6 @@ def instances(self):
180164 >>> edbapp.components.instances
181165
182166 """
183- if not self ._cmp :
184- self .refresh_components ()
185167 return self ._cmp
186168
187169 @property
@@ -287,10 +269,28 @@ def refresh_components(self):
287269 """Refresh the component dictionary."""
288270 self ._logger .info ("Refreshing the Components dictionary." )
289271 self ._cmp = {}
272+ self ._res = {}
273+ self ._ind = {}
274+ self ._cap = {}
275+ self ._ics = {}
276+ self ._ios = {}
277+ self ._others = {}
290278 for i in self ._pedb .layout .groups :
291- if isinstance (i , Component ):
292- if not i .is_null :
293- self ._cmp [i .name ] = i
279+ self ._cmp [i .name ] = i
280+ if i .type == "resistor" :
281+ self ._res [i .name ] = i
282+ elif i .type == "capacitor" :
283+ self ._cap [i .name ] = i
284+ elif i .type == "inductor" :
285+ self ._ind [i .name ] = i
286+ elif i .type == "ic" :
287+ self ._ics [i .name ] = i
288+ elif i .type == "io" :
289+ self ._ios [i .name ] = i
290+ elif i .type == "other" :
291+ self ._others [i .name ] = i
292+ else :
293+ self ._logger .warning (f"Unknown component type { i .name } found while refreshing components, will ignore" )
294294 return True
295295
296296 @property
@@ -309,14 +309,6 @@ def resistors(self):
309309 >>> edbapp = Edb("myaedbfolder")
310310 >>> edbapp.components.resistors
311311 """
312- self ._res = {}
313- for el , val in self .instances .items ():
314- if not val .is_null :
315- try :
316- if val .type == "resistor" :
317- self ._res [el ] = val
318- except :
319- pass
320312 return self ._res
321313
322314 @property
@@ -335,14 +327,6 @@ def capacitors(self):
335327 >>> edbapp = Edb("myaedbfolder")
336328 >>> edbapp.components.capacitors
337329 """
338- self ._cap = {}
339- for el , val in self .instances .items ():
340- if not val .is_null :
341- try :
342- if val .type == "capacitor" :
343- self ._cap [el ] = val
344- except :
345- pass
346330 return self ._cap
347331
348332 @property
@@ -362,14 +346,6 @@ def inductors(self):
362346 >>> edbapp.components.inductors
363347
364348 """
365- self ._ind = {}
366- for el , val in self .instances .items ():
367- if not val .is_null :
368- try :
369- if val .type == "inductor" :
370- self ._ind [el ] = val
371- except :
372- pass
373349 return self ._ind
374350
375351 @property
@@ -389,14 +365,6 @@ def ICs(self):
389365 >>> edbapp.components.ICs
390366
391367 """
392- self ._ics = {}
393- for el , val in self .instances .items ():
394- if not val .is_null :
395- try :
396- if val .type == "ic" :
397- self ._ics [el ] = val
398- except :
399- pass
400368 return self ._ics
401369
402370 @property
@@ -416,14 +384,6 @@ def IOs(self):
416384 >>> edbapp.components.IOs
417385
418386 """
419- self ._ios = {}
420- for el , val in self .instances .items ():
421- if not val .is_null :
422- try :
423- if val .type == "io" :
424- self ._ios [el ] = val
425- except :
426- pass
427387 return self ._ios
428388
429389 @property
@@ -443,14 +403,6 @@ def Others(self):
443403 >>> edbapp.components.others
444404
445405 """
446- self ._others = {}
447- for el , val in self .instances .items ():
448- if not val .is_null :
449- try :
450- if val .type == "other" :
451- self ._others [el ] = val
452- except :
453- pass
454406 return self ._others
455407
456408 @property
0 commit comments