VSTA transform relative to
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
-
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]
0 -
Thank you...0
-
Hello Niklas,
I have tried this but it does not work for me.
I get this error :
0 -
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]
0 -
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 ?
0 -
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.
0 -
OK Niklas.Thank you a lot !
0
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 310 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 786 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings