Cancel
Showing results for 
Search instead for 
Did you mean: 

I cannot find the event to get the actual TxManipulatorElementData that is select.

Siemens Genius Siemens Genius
Siemens Genius

Question:

 

I have created an event for when the user selects the  TxManipulation but I cannot find the event to get the actual TxManipulatorElementData that is select.

 

Answer:

 

 You can use TxPickListener class to register to the Picked event. Then from the TxPickListener_PickedEventArgs event arguments you can take the ElementIndex. It will return you the index of the picked element in the manipulator.

 

void picker _Picked(object sender, TxPickListener_PickedEventArgs args)
{
         int index = args.ElementIndex;
         ArrayList elements = manip.GetGraphicsElements();
         TxManipulatorElementGraphicsData element = elements[index - 1] as TxManipulatorElementGraphicsDat
}

 

 

 

Note: When you create the elements of the manipulator, set the  Pickable property of the  element data to true. Also when you create the TxPickListener, set its IgnorPickOfTransientObjects property to false.

Then register to the Picked and Deactivated events. In the Deactivated event handler unregister from both events:

 

TxPickListener picker = new TxPickListener();//add it as a member of your class
picker.IgnorPickOfTransientObjects = false;
picker.PickLevel = TxPickLevel.Component;
picker.Picked += picker_Picked;
picker.Deactivated += picker_Deactivated;

void picker_Deactivated(object sender, TxPickListener_DeactivatedEventArgs args)
{
      picker.Picked -= picker_Picked;
      picker.Deactivated -= picker_Deactivated;
}

 

 

 

 

 

 

 

5 REPLIES

Re: I cannot find the event to get the actual TxManipulatorElementData that is select.

Pioneer
Pioneer

Hello Ofer,

 

I'm struggeling with the Manipulator. I tried to follow your suggestion but i never get the selected Element Index at the pick event.

I've wrote a tiny example for an manipulator with a line and an arc as seen below.

When i set the arc to pickable = false, i can pick it but the ElementIndex will be always -1 at PickerOnPicked()

When i set the line to pickable = true, the picked event never get fired. Is this pickable true/false reversed.

 

Can you tell me what is wrong?

 

Is there a way to use the original PlacementManipulator (Translation/Rotation) in an easy way, instead of building a completely new one from scratch?

 

 

using System.Collections;

using Tecnomatix.Engineering;

using Tecnomatix.Engineering.Ui;

namespace UserTools

{

class Tecno_Manip

 

{

private TxManipulator manipulator = null;

TxPickListener picker = new TxPickListener();

private static double m_width = 200.0;

private static double m_height = 200.0;

private TxColor CIRC_COLOR_X = new TxColor(0, 255, 0);

private TxColor LINE_COLOR_X = new TxColor(255, 0, 0);

public Tecno_Manip(TxTransformation posTransformation)

 

{

TxManipulatorCreationData creationData = new TxManipulatorCreationData("manip", posTransformation);

manipulator = TxApplication.ActiveDocument.PhysicalRoot.CreateManipulator(creationData);

picker.IgnorPickOfTransientObjects = false;

picker.PickLevel = TxPickLevel.Component;

 

}

private void PickerOnDeactivated(object sender, TxPickListener_DeactivatedEventArgs args)

 

{

picker.Picked -= PickerOnPicked;

picker.Deactivated -= PickerOnDeactivated;

}

private void PickerOnPicked(object sender, TxPickListener_PickedEventArgs args)

 

{

int index = args.ElementIndex;    //<<<<<<<<<< always -1

if (index > 0)

 

{

ArrayList elements = manipulator.GetGraphicsElements();

TxManipulatorElementGraphicsData element = elements[index - 1] as TxManipulatorElementGraphicsData;

 

}

}

public void activate()

 

{

CreateElements();

picker.Picked += PickerOnPicked;

picker.Deactivated += PickerOnDeactivated;

TxApplication.RefreshDisplay();

 

}

public void disable()

 

{

manipulator.RemoveAllElements();

TxApplication.RefreshDisplay();

 

picker.Picked -= PickerOnPicked;

picker.Deactivated -= PickerOnDeactivated;

}

public ArrayList getElements()

 

{

return manipulator.GetGraphicsElements();

 

}

private void CreateElements()

 

{

TxTransformation txTransformation = new TxTransformation();

TxTransformation txTransformation2 = new TxTransformation();

 

txTransformation2.Translation.X = m_width / 2.0;

txTransformation2.Translation.Y = m_height / 2.0;

// Arc ZY

TxTransformation txTransformation3 = new TxTransformation();

txTransformation3.Translation = new TxVector(txTransformation.Translation.X, txTransformation.Translation.Y, txTransformation.Translation.Z);

txTransformation3.RotationRPY_XYZ = new TxVector(txTransformation.RotationRPY_XYZ.X, txTransformation.RotationRPY_XYZ.Y, txTransformation.RotationRPY_XYZ.Z);

txTransformation3.RotationRPY_XYZ += new TxVector(1.57079633, 0.0, 0.0);

TxManipulatorArcElementData txManipulatorArcElementData = new TxManipulatorArcElementData(txTransformation3, 300.0, 300.0, 0.0, 1.57079633);

txManipulatorArcElementData.Color = this.CIRC_COLOR_X;

txManipulatorArcElementData.Pickable = false;   //<<<<<<<<<<<<<<< seems to be pickable

txManipulatorArcElementData.Unzoomable = true;

txManipulatorArcElementData.AlwaysOnTop = true;

 

txManipulatorArcElementData.LineWidth = 2.0;

manipulator.AddElement(txManipulatorArcElementData);

//Orientation

TxVector p = new TxVector(0.0, 0.0, 0.0);

TxVector p2 = new TxVector(400.0, 0.0, 0.0);

//Line X

TxManipulatorLineElementData txManipulatorLineElementData = new TxManipulatorLineElementData(txTransformation2, p, p2);

txManipulatorLineElementData.Color = this.LINE_COLOR_X;

 

txManipulatorLineElementData.LineWidth = 2.0;

txManipulatorLineElementData.Pickable = true;   //<<<<<<<<<<<<<<< seems to be not pickable

txManipulatorLineElementData.AlwaysOnTop = true;

txManipulatorLineElementData.Unzoomable = true;

manipulator.AddElement(txManipulatorLineElementData);

}

}

}

 

 

Re: I cannot find the event to get the actual TxManipulatorElementData that is select.

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi Titaniser,

 

I debugged your code.

The problem is due to the call to picker.IgnorPickOfTransientObjects = false;

 

It should be called afetr you register to the Picked and Deactivated events:

public void activate()
        {

            CreateElements();

            picker.Picked += PickerOnPicked;

            picker.Deactivated += PickerOnDeactivated;
            picker.IgnorPickOfTransientObjects = false;

            TxApplication.RefreshDisplay();



        }

Manipulator elements should be Pickable = true. Actually this is the default value, you can even omit it in the code.

 

Best Regards,

DianaG

Re: I cannot find the event to get the actual TxManipulatorElementData that is select.

Pioneer
Pioneer

that works fine for me.

 

Thanks a lot

Re: I cannot find the event to get the actual TxManipulatorElementData that is select.

Pioneer
Pioneer

Sorry to say that, but i'm not happy with that.

 

The TxPickListener is working and it tells me the id of manipulator elements.

But to have a proper manipulator it must be possible to drag it.

 

To do that i need to watch for the mouseDown, mouseUp events.

When ever a mouseDown is recognized i need to hold that info and "follow" the

mouse coordinates and i also need to know the elementID i've clicked on. (is it X, Y, or Z maybe)

On a mouseUP i stop that procedure.

 

The TxPickListener provides the element information, BUT only when the mouseUP raises.

That means, i cannot get the elementID on a MouseDown event with the txPicklistener.

 

any Ideas?

 

Re: I cannot find the event to get the actual TxManipulatorElementData that is select.

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi Titaniser,

 

Unfortunately you cannot get the element id on mouse down. 

Still you can check if the manipulator was picked on mouse down with 

TxGraphicsPickData data =  TxApplication.ViewersManager.GraphicViewer.PickSingleObject(args.X, args.Y, new TxGraphicsSingleObjectPickParameters());

To start dragging the manipulator you need to handle the event:

args.Handled = StartDragging();

Best Regards,

DianaG