RobotStudio event

API: GraphicControl ExamineObject

Options
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.




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 Robotics
  • apox
    Options

    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:31
  • 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 Robotics
  • apox
    Options

    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:10
  • That's simpler :)

    Part.Opacity


    Johannes Weiman
    Software Engineer
    ABB Robotics
  • apox
    Options
    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 ?

  • No that's not really possible right now. Opacity will change the materials on the part.


    Johannes Weiman
    Software Engineer
    ABB Robotics
  • apox
    Options
    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.