icon

Support Forum

  • The requested topic does not exist.

Mirrored PythonPart


Hello

I am trying to create PythonPart. It is an arrow for welding label

User after pasting PP in to the drawing file can use "Mirror" command and create mirrored version.
But in this example i dont need correct mirrored replica of PP. Some part of the arrow needs to be faced to the left all the time due to the standarts (i circled that part in pics)

I need some kind of tool to forbade PP to be mirrored. (or it gets mirrored and creates same arrow)
Or i need PP to know it was mirrored, react to that in the code and redraw the arrow as needed. I tried to use coordinates of points of the arrow for that. But mirrored and unmirrored arrow seem to have exact same coordinates. Code sees them as equal elements

Thanks

Anhänge (2)

Typ: image/jpeg
2-mal heruntergeladen
Größe: 25,02 KiB
Typ: image/jpeg
1-mal heruntergeladen
Größe: 24,56 KiB

Hi Suren,

you cannot forbid the user to mirror the PythonPart, but you can react accordingly, when the PythonPart is transformed (e.g. mirrored).

I would try following approach (works only since ALLPLAN 2026 and only with ScriptObject or Interactor):

  • subscribe to the event of moving and copying; this will results in the script of your PythonPart being rerun everytime this PythonPart is copied or moved -> this allows you to react accordingly, but avoid doing expensive operations in this case
  • in your script, ideally in the __init__(), check whether the PyP has been mirrored; this is the case, if an odd number of scaling factors resulting from the placement matrix is negative
    import math
    ...
    self.is_mirrored = math.prod(self.build_ele.get_insert_matrix().GetScaling())  0

  • then, where you create the symbol, act accordingly, depending on the value of self.is_mirrored

IMPORTANT: The state of the symbol (mirrored or not) must be saved in a hidden parameter. Otherwise, after script recalculation ALLPLAN will not see any change in any parameter -> the hash stays the same -> no update being executed

Note, that subscribing to the event of moving/copying is possible since ALLPLAN 2026. In the previous versions, the user would have to actively reactivate the PythonPart after mirroring it.

Cheers,
Bart