RobotStudio event

VSTA transform relative to

Options

Hello i would like to move an object "part1" relative to the workobject.

How can i do that ? I have tryed this and it does not work:


trMat =
New Matrix4(trans, rot)
prt = stn2.GraphicComponents(
"Part_1")
prt.Transform.SetRelativeTransform(stn2.ActiveTask.ActiveWor kObject, TrMat)
 
 any help appretiated...

 

Comments

  • Niklas Skoglund
    Options

    Hi wolfino,

    this sample shows how to move the selected part 500mm in Z direction relative the User Frame of the active Workobject.

    [CODE] Part p = Selection.SelectedObjects.SingleSelectedObject as Part;

    Station s = Project.ActiveProject as Station;

    RsWorkObject w = s.ActiveTask.ActiveWorkObject;

    Matrix4 m = new Matrix4(new Vector3(0,0,0.5));

    p.Transform.SetRelativeTransform(w.UserFrame.GlobalMatrix, m);

    [/CODE]

     

    Niklas Skoglund2008-5-20 9:44:12

    Best Regards, Niklas Skoglund
    ABB Robotics

    Developer Center
    RobotStudio Blog
  • wolfino
    wolfino ✭✭
    Options
    Thank you...
  • wolfino
    wolfino ✭✭
    Options

    Hello Niklas,

    I have tried this but it does not work for me.

    I get this error :

    image

  • Niklas Skoglund
    Options

    Hello,

    by mistake I used an overload of SetRelativeTransform() that was not available in the RS5.10 version of the API.

    SetRelativeTransform is just a convinience-method. You can cope without it by doing the math yourself:

    [CODE]


    Part
    p = Selection.SelectedObjects.SingleSelectedObject as Part;
    Station s = Project.ActiveProject as Station;
    RsWorkObject w = s.ActiveTask.ActiveWorkObject;
    Matrix4 m1 = new Matrix4(new Vector3(0,0,0.5));
    Matrix4 m2 = w.UserFrame.GlobalMatrix.Multiply(m1);
    p.Transform.GlobalMatrix = m2;

    [/CODE]


    Best Regards, Niklas Skoglund
    ABB Robotics

    Developer Center
    RobotStudio Blog
  • wolfino
    wolfino ✭✭
    Options

    Hi,

    Thank you. This is how i actually did it before. I just thought I could use SetRelativeTransform method instead. Is it going to be available in 5.11 ? 

                    

  • Niklas Skoglund
    Options

    Hi wolfino,

    the overload that takes a Matrix4 will be available in 5.11.

    In 5.10 you can only pass an object that inherits IHasTransform, as the first parameter.

    For example RsTarget inherits IHasTransform.

    So if you wanted to move the part relative a target you could use SetRelativeTransform().

    [CODE]


    Part
    p = Selection.SelectedObjects.SingleSelectedObject as Part;
    RsTarget target = GetSomeTarget();
    Matrix4 m1 = new Matrix4(new Vector3(0,0,0.5));

    p.Transform.SetRelativeTransform(target, m1);

    [/CODE]

    The interface IHasTransform defines the property Transform. So objects like RsTarget, GraphicCompnent etc, that has a transform implements this interface.


    [CODE]
    public
    interface IHasTransform

    {

    Transform Transform { get; }

    }

    [/CODE]

    The problem with RsWorkObject is that it represents two transforms, the UserFrame and the ObjectFrame. If it inherited IHasTransform it would be kind of ambigous.


    Best Regards, Niklas Skoglund
    ABB Robotics

    Developer Center
    RobotStudio Blog
  • wolfino
    wolfino ✭✭
    Options

    OK Niklas.Thank you a lot !

     

This discussion has been closed.