[RobotStudio SDK] Creating Faces

Hi,

I´m trying to create a Body using the Body.CreateFromFace(Face face) function. The problem is that the Face class has no constructor, static members to create it are not available neither. So I don´t know how to create a Face to use it as a parameter of the function.

Thanks in advance.

Hi HM,

it is not possible to create a Face directly using the API. RobotStudio has limited modeling functionality, and there are more APIs for traversing a geometry than creating one.

There are APIs that corresponds to the create functions on the Modeling Tab.

For example CreateSurfaceCircle Method

Hi HM,

What is it that you are trying to accomplish?

In RobotStudio the Face object cannot exist on its own, instead it is always “inside” a body. So while you cannot create a face on its own you have lots of ways of generating surfaces (Face) which you can then use.

For example, I want to break up a solid object into its faces. Then I could take each individual face and put them in a seperate body. Like this:

// Check that we have an active station
Station _station = Project.ActiveProject as Station;
if (_station == null) return;

Project.UndoContext.BeginUndoStep(“TheBoxYouOpenedItWeCame”);
try
{

// Create a part to contain the bodies.
Part p = new Part();
_station.GraphicComponents.Add(p);

// Create a solid box.
Body box = Body.CreateSolidBox(new Matrix4(new Vector3(0, 0, 0), new Vector3()), new Vector3(1, 1, 1));

foreach (Face i in box.Faces)
{
p.Bodies.Add(Body.CreateFromFace(i));
}

}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}