@@ -406,24 +406,37 @@ def _add_child_node(self, child_type, child_name=None):
406406 return new_id
407407
408408 @property
409- def reorient (self ) -> None :
410- """Reorient an emit node in the schematic .
409+ def orientation (self ) -> int :
410+ """Returns the orientation of the component .
411411
412412 Returns:
413- int: The new orientation of the component (0 or 1).
414-
415- Raises:
416- RuntimeError: If the component does not support orientation.
413+ int: The orientation of the component, where valid values range from 0 to 3.
417414 """
418- try :
419- orientation = self ._emit_obj .oeditor .GetComponentOrientation (self .name )
420- new_orientation = 1 - orientation
421- self ._emit_obj .oeditor .ReorientComponent (self .name , new_orientation )
422- self ._emit_obj .logger .info (f"Successfully reoriented component '{ self .name } '." )
423- except Exception as e :
415+ return self ._emit_obj .oeditor .GetComponentOrientation (self .name )
416+
417+ @orientation .setter
418+ def orientation (self , value : int ) -> None :
419+ if self .properties ["Type" ] != "Multiplexer" and value not in [0 , 1 ]:
420+ raise ValueError (f"Orientation must be either 0 or 1 for component '{ self .name } '." )
421+ elif self .properties ["Type" ] == "Multiplexer" and value not in [0 , 1 , 2 , 3 ]:
422+ raise ValueError ("Orientation must be one of the following: 0, 1, 2, or 3 for Multiplexer components." )
423+ if self .orintation_count > 1 :
424+ self ._emit_obj .oeditor .ReorientComponent (self .name , value )
425+ self ._emit_obj .logger .info (f"Successfully set orientation to { value } for component '{ self .name } '." )
426+ else :
424427 error_message = (
425- f"Reorientation failed; orientation adjustment is not supported "
426- f"for component ' { self . name } '. Error: { e } "
428+ f"Orientation adjustment is not supported for component ' { self . name } '. "
429+ "This component cannot be reoriented. "
427430 )
428431 self ._emit_obj .logger .error (error_message )
429- raise RuntimeError (error_message )
432+ raise ValueError (error_message )
433+
434+ @property
435+ def orintation_count (self ) -> int :
436+ """Returns the number of orientations available for the component.
437+
438+ Returns:
439+ int: The number of valid orientations. A value of 1 indicates the component cannot be reoriented,
440+ 2 indicates support for basic reorientation, and 4 is used for multiplexer components.
441+ """
442+ return self ._emit_obj .oeditor .GetNumComponentOrientations (self .name )
0 commit comments