RobotStudio event

VSTA: read geometry information

Has anybody experiences on VSTA regarding the possibilities
to read geometrical information of a selected part or body

How can you read geometrical informations (faces, vertices, nodes):
e.g. a box has 6 faces, it has ... nodes at X, Y, Z ...

 

robotrix

Comments

  • apox
    apox ✭✭




    I'm using this code to get these informations. Perhaps there is a easier way to do that.



    Station station = Project.ActiveProject as Station;

    if (station == null)
    {
        Logger.AddMessage(new LogMessage("Station = null..."));
        return;
    }

    ProjectObject selObject = Project.ActiveProject.Selection.SingleSelectedObject as ProjectObject;
    if (selObject == null)
    {
        Logger.AddMessage(new LogMessage("Nothing selected..."));
        return;
    }

    Logger.AddMessage(new LogMessage("selected object: " + selObject.Name + " - " + selObject.Attributes.Count));

    Part selPart = selObject as Part;

    BodyCollection selBodiesC = selPart.Bodies;
    Body selBody = selPart.Bodies[0];
    Logger.AddMessage(new LogMessage("Number of bodies in selection :" + selBodiesC.Count));

    ShellCollection shellC = selBody.Shells;
    Logger.AddMessage(new LogMessage("Number of shells:" + shellC.Count));

    Shell selShell = shellC[0];
    FaceCollection faceC = selShell.Faces;
    Logger.AddMessage(new LogMessage("Number of faces:" + faceC.Count));


    foreach (Face f in faceC)
    {

        LoopCollection faceLoopC = f.Loops;
        Logger.AddMessage(new LogMessage("Number of loops:" + faceLoopC.Count));
        Logger.AddMessage(new LogMessage("Face Color:" + f.Color.ToString()));

        foreach (Loop l in faceLoopC)
        {
            CoedgeCollection coedgeC = l.Coedges;
            Logger.AddMessage(new LogMessage("Number of coedges:" + coedgeC.Count));

            foreach (Coedge cEdge in coedgeC)
            {
                 Vertex v0 = cEdge.StartVertex;
                 Vertex v1 = cEdge.EndVertex;
                 Logger.AddMessage(new LogMessage("Vertices: " + cEdge.StartVertex.Position.ToString() + " / " + cEdge.EndVertex.Position.ToString()));

            }//for coedges
        }//for loops
    }//for faces

    apox2007-5-16 13:58:38