API: GraphicControl ExamineObject
apox
✭✭
in RobotStudio
Hi,
Im trying to use the "ExamineObject" method in an Addin, selecting an existing RS Part manually and then calling the addin:
object selObject = Project.ActiveProject.Selection.SingleSelectedObject;
GraphicControl graphicControl = GraphicControl.ActiveGraphicControl;
graphicControl.ExamineObject(singleSelectedObject as ProjectObject, 0.2f);
which works, but creating RobotStudio Parts within the addin and then examing does not work:
Part p = new Part();
p.Name = "part";
p.Bodies.Add(Body.CreateSolidBox(Matrix4.Identity, new Vector3(1, 1, 1)));
station.GraphicComponents.Add(p);
GraphicControl graphicControl = GraphicControl.ActiveGraphicControl;
graphicControl.ExamineObject(p as ProjectObject,
0.2f);
Is it possible to create Parts and axamine them within an RobotStudio Addin?
Thank you.
Im trying to use the "ExamineObject" method in an Addin, selecting an existing RS Part manually and then calling the addin:
object selObject = Project.ActiveProject.Selection.SingleSelectedObject;
GraphicControl graphicControl = GraphicControl.ActiveGraphicControl;
graphicControl.ExamineObject(singleSelectedObject as ProjectObject, 0.2f);
which works, but creating RobotStudio Parts within the addin and then examing does not work:
Part p = new Part();
p.Name = "part";
p.Bodies.Add(Body.CreateSolidBox(Matrix4.Identity, new Vector3(1, 1, 1)));
station.GraphicComponents.Add(p);
GraphicControl graphicControl = GraphicControl.ActiveGraphicControl;
graphicControl.ExamineObject(p as ProjectObject,
0.2f);
Is it possible to create Parts and axamine them within an RobotStudio Addin?
Thank you.
0
Comments
-
Hi,
Try calling Update() before examine:
GraphicControl graphicControl =
GraphicControl.ActiveGraphicControl;
graphicControl.Update();
graphicControl.ExamineObject(p
as ProjectObject,
0.2f);
regards,
Johannes
Johannes Weiman
Software Engineer
ABB Robotics0 -
Thank you, it works!
Another question: is it possible, to disable backface culling and/or to set transparency settings to a Part from the API (similiar to the graphic appereance dialog) ? , e.g.
Part p = new Part();
p.Bodies.Add(Body.CreateSolidBox(...));
...
p.BackfaceCulling = false; // NOT possible via material property ?
p.Alpha = 50%; // possible via material property
...
apox2010-02-19 14:51:310 -
It is possible via the Mesh API:
[code] static void SetBackFaceCull(Part part, bool bfc)
{
SetBackFaceCull(part.Mesh[DetailLevels.Coarse], bfc);
SetBackFaceCull(part.Mesh[DetailLevels.Medium], bfc);
SetBackFaceCull(part.Mesh[DetailLevels.Fine], bfc);
part.Mesh.Rebuild();
}
static void SetBackFaceCull(MeshPart mp, bool bfc)
{
if (mp == null) return;
foreach (MeshBody mb in mp.Bodies)
{
foreach (MeshFace mf in mb.Faces)
{
if (bfc) mf.Flags &= ~(MeshFlags.DisableBackFaceCull | MeshFlags.TwoSidedLighting);
else mf.Flags |= (MeshFlags.DisableBackFaceCull | MeshFlags.TwoSidedLighting);
}
}
}[/code]
Johannes Weiman
Software Engineer
ABB Robotics0 -
Thank you! How about the transparency, the same way via material proerpty os is there a more comfortable way ?
static void SetTransparency(Part part, int A)
{
SetTransparency(part.Mesh[DetailLevels.Coarse], A);
SetTransparency(part.Mesh[DetailLevels.Medium], A);
SetTransparency(part.Mesh[DetailLevels.Fine], A);
part.Mesh.Rebuild();
}
static void SetTransparency(MeshPart mp, int A)
{
if (mp == null) return;
foreach (MeshBody mb in mp.Bodies)
{
foreach (MeshFace mf in mb.Faces)
{
if (mf.Material != null)
{
mf.Material.Ambient = SetTransparency(mf.Material.Ambient, A);
mf.Material.Diffuse = SetTransparency(mf.Material.Diffuse, A);
mf.Material.Emissive = SetTransparency(mf.Material.Emissive, A);
mf.Material.Specular = SetTransparency(mf.Material.Specular, A);
}
// if (bfc) mf.Flags &= ~(MeshFlags.DisableBackFaceCull | MeshFlags.TwoSidedLighting);
// else mf.Flags |= (MeshFlags.DisableBackFaceCull | MeshFlags.TwoSidedLighting);
}
}
}
static System.Drawing.Color SetTransparency(System.Drawing.Color col, int A)
{
col = System.Drawing.Color.FromArgb(A, col.R, col.G, col.B);
return col;
}
apox2010-02-19 15:58:100 -
That's simpler
Part.Opacity
Johannes Weiman
Software Engineer
ABB Robotics0 -
Yes, thats really simpler :-) !
How about using material properties on meshes with some transparencies of any value. If i want to temporaray set (increase/decrease) the transparency on the whole part which includes some meshes and restore later on the origin material properties with all transparency values, is that possible with "part.Opacity" or will it override all material transparency values ?
0 -
No that's not really possible right now. Opacity will change the materials on the part.
Johannes Weiman
Software Engineer
ABB Robotics0 -
Okay, thanks.
Perhaps an other question: creating an intersection curves via Body.CreateIntersectionCurve(...) returns a new body. How do i determine the start and the end position of the new curve. body.shells.wires...startVertex/EndVertex return nothing.
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