Class Body
A body is typically a single 3D solid or a 2D surface, but it can also be several disjoint lumps treated as one body.
It is the highest level object in the geometric model. Several bodies can be grouped in a Part.
Inherited Members
Namespace: ABB.Robotics.RobotStudio.Stations
Assembly: ABB.Robotics.RobotStudio.Stations.dll
Syntax
Persistent(true)]
public sealed class Body : ProjectObject, IGeometryObject, IHasTransform, ISupportCopy, IHasGeometry, IGfxObject
Remarks
The Body object is generated on demand and is not stored in the station file; therefore Attributes cannot be used to persist attributes.
Properties
BodyType
Returns the type of the body.
Declaration
public BodyType BodyType { get; }
Property Value
Type | Description |
---|---|
BodyType |
CenterOfGravity
Gets the center of gravity of the body as a Vector3.
Declaration
public Vector3 CenterOfGravity { get; }
Property Value
Type | Description |
---|---|
Vector3 |
Examples
Get CenterOfGravity.
Project.UndoContext.BeginUndoStep("BodyProperties");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
Part p = new Part();
p.Name = "My_Part";
station.GraphicComponents.Add(p);
// Create a solid box.
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Vector3 size = new Vector3(0.5, 0.5, 0.5);
Body b1 = Body.CreateSolidBox(matrix_origo, size);
b1.Name = "Box";
p.Bodies.Add(b1);
// Log a summary of the bodies properties.
Logger.AddMessage(new LogMessage("The body '" + b1.Name + "' has the following properties:"));
Logger.AddMessage(new LogMessage("Center of gravity: x: " + b1.CenterOfGravity.x.ToString() +
" y: " + b1.CenterOfGravity.y.ToString() +
" z: " + b1.CenterOfGravity.z.ToString()));
Logger.AddMessage(new LogMessage("Color: " + b1.Color.ToString()));
Logger.AddMessage(new LogMessage("Moment of Inertia: x: (" + b1.MomentOfInertia.x.x.ToString() +
", " + b1.MomentOfInertia.x.y.ToString() +
", " + b1.MomentOfInertia.x.z.ToString() + ")" +
" y: (" + b1.MomentOfInertia.y.x.ToString() +
", " + b1.MomentOfInertia.y.y.ToString() +
", " + b1.MomentOfInertia.y.z.ToString() + ")" +
" z: (" + b1.MomentOfInertia.z.x.ToString() +
", " + b1.MomentOfInertia.z.y.ToString() +
", " + b1.MomentOfInertia.z.z.ToString() + ")"));
Logger.AddMessage(new LogMessage("Has '" + b1.Shells.Count.ToString() + "' number of shells."));
Logger.AddMessage(new LogMessage("Surface area: " + b1.SurfaceArea.ToString()));
Logger.AddMessage(new LogMessage("Transform: X: " + b1.Transform.X.ToString() +
" Y: " + b1.Transform.Y.ToString() +
" Z: " + b1.Transform.Z.ToString() +
" Rx: " + b1.Transform.RX.ToString() +
" Ry: " + b1.Transform.RY.ToString() +
" Rz: " + b1.Transform.RZ.ToString()));
Logger.AddMessage(new LogMessage("Visibility: " + b1.Visible.ToString()));
Logger.AddMessage(new LogMessage("Volume: " + b1.Volume.ToString()));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Color
Gets or sets the body color in the graphics.
Declaration
public Color Color { get; set; }
Property Value
Type | Description |
---|---|
Color |
Remarks
Returns Color.Empty if color is ambiguous.
Examples
Get/Set Color.
Project.UndoContext.BeginUndoStep("BodyProperties");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
Part p = new Part();
p.Name = "My_Part";
station.GraphicComponents.Add(p);
// Create a solid box.
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Vector3 size = new Vector3(0.5, 0.5, 0.5);
Body b1 = Body.CreateSolidBox(matrix_origo, size);
b1.Name = "Box";
p.Bodies.Add(b1);
// Log a summary of the bodies properties.
Logger.AddMessage(new LogMessage("The body '" + b1.Name + "' has the following properties:"));
Logger.AddMessage(new LogMessage("Center of gravity: x: " + b1.CenterOfGravity.x.ToString() +
" y: " + b1.CenterOfGravity.y.ToString() +
" z: " + b1.CenterOfGravity.z.ToString()));
Logger.AddMessage(new LogMessage("Color: " + b1.Color.ToString()));
Logger.AddMessage(new LogMessage("Moment of Inertia: x: (" + b1.MomentOfInertia.x.x.ToString() +
", " + b1.MomentOfInertia.x.y.ToString() +
", " + b1.MomentOfInertia.x.z.ToString() + ")" +
" y: (" + b1.MomentOfInertia.y.x.ToString() +
", " + b1.MomentOfInertia.y.y.ToString() +
", " + b1.MomentOfInertia.y.z.ToString() + ")" +
" z: (" + b1.MomentOfInertia.z.x.ToString() +
", " + b1.MomentOfInertia.z.y.ToString() +
", " + b1.MomentOfInertia.z.z.ToString() + ")"));
Logger.AddMessage(new LogMessage("Has '" + b1.Shells.Count.ToString() + "' number of shells."));
Logger.AddMessage(new LogMessage("Surface area: " + b1.SurfaceArea.ToString()));
Logger.AddMessage(new LogMessage("Transform: X: " + b1.Transform.X.ToString() +
" Y: " + b1.Transform.Y.ToString() +
" Z: " + b1.Transform.Z.ToString() +
" Rx: " + b1.Transform.RX.ToString() +
" Ry: " + b1.Transform.RY.ToString() +
" Rz: " + b1.Transform.RZ.ToString()));
Logger.AddMessage(new LogMessage("Visibility: " + b1.Visible.ToString()));
Logger.AddMessage(new LogMessage("Volume: " + b1.Volume.ToString()));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Faces
Gets a FaceCollection that contains all the faces in the body.
Declaration
public FaceCollection Faces { get; }
Property Value
Type | Description |
---|---|
FaceCollection |
MomentOfInertia
Gets the moment of inertia of the body as a Matrix3.
Declaration
public Matrix3 MomentOfInertia { get; }
Property Value
Type | Description |
---|---|
Matrix3 |
Remarks
The moment of inertia of an object about a given axis describes how difficult it is to change its angular motion about that axis. For the same object, different axes of rotation will have different moments of inertia about those axes. The moment of inertia summarize all moments of inertia of an object as a matrix.
Examples
Get MomentOfInertia.
Project.UndoContext.BeginUndoStep("BodyProperties");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
Part p = new Part();
p.Name = "My_Part";
station.GraphicComponents.Add(p);
// Create a solid box.
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Vector3 size = new Vector3(0.5, 0.5, 0.5);
Body b1 = Body.CreateSolidBox(matrix_origo, size);
b1.Name = "Box";
p.Bodies.Add(b1);
// Log a summary of the bodies properties.
Logger.AddMessage(new LogMessage("The body '" + b1.Name + "' has the following properties:"));
Logger.AddMessage(new LogMessage("Center of gravity: x: " + b1.CenterOfGravity.x.ToString() +
" y: " + b1.CenterOfGravity.y.ToString() +
" z: " + b1.CenterOfGravity.z.ToString()));
Logger.AddMessage(new LogMessage("Color: " + b1.Color.ToString()));
Logger.AddMessage(new LogMessage("Moment of Inertia: x: (" + b1.MomentOfInertia.x.x.ToString() +
", " + b1.MomentOfInertia.x.y.ToString() +
", " + b1.MomentOfInertia.x.z.ToString() + ")" +
" y: (" + b1.MomentOfInertia.y.x.ToString() +
", " + b1.MomentOfInertia.y.y.ToString() +
", " + b1.MomentOfInertia.y.z.ToString() + ")" +
" z: (" + b1.MomentOfInertia.z.x.ToString() +
", " + b1.MomentOfInertia.z.y.ToString() +
", " + b1.MomentOfInertia.z.z.ToString() + ")"));
Logger.AddMessage(new LogMessage("Has '" + b1.Shells.Count.ToString() + "' number of shells."));
Logger.AddMessage(new LogMessage("Surface area: " + b1.SurfaceArea.ToString()));
Logger.AddMessage(new LogMessage("Transform: X: " + b1.Transform.X.ToString() +
" Y: " + b1.Transform.Y.ToString() +
" Z: " + b1.Transform.Z.ToString() +
" Rx: " + b1.Transform.RX.ToString() +
" Ry: " + b1.Transform.RY.ToString() +
" Rz: " + b1.Transform.RZ.ToString()));
Logger.AddMessage(new LogMessage("Visibility: " + b1.Visible.ToString()));
Logger.AddMessage(new LogMessage("Volume: " + b1.Volume.ToString()));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Name
Gets or sets the name of the object.
Declaration
public override string Name { get; set; }
Property Value
Type | Description |
---|---|
String |
Overrides
Opacity
Gets or sets the opacity of the body
Declaration
public double Opacity { get; set; }
Property Value
Type | Description |
---|---|
Double |
Remarks
Valid values are 0.0 (fully transparent) through 1.0 (fully opaque). Returns 1.0 if opacity is ambiguous.
Parent
Gets the parent object of the body.
Declaration
public override ProjectObject Parent { get; }
Property Value
Type | Description |
---|---|
ProjectObject |
Overrides
Examples
Get Parent.
Project.UndoContext.BeginUndoStep("BodyProperties");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
Part p = new Part();
p.Name = "My_Part";
station.GraphicComponents.Add(p);
// Create a solid box.
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Vector3 size = new Vector3(0.5, 0.5, 0.5);
Body b1 = Body.CreateSolidBox(matrix_origo, size);
b1.Name = "Box";
p.Bodies.Add(b1);
// Log a summary of the bodies properties.
Logger.AddMessage(new LogMessage("The body '" + b1.Name + "' has the following properties:"));
Logger.AddMessage(new LogMessage("Center of gravity: x: " + b1.CenterOfGravity.x.ToString() +
" y: " + b1.CenterOfGravity.y.ToString() +
" z: " + b1.CenterOfGravity.z.ToString()));
Logger.AddMessage(new LogMessage("Color: " + b1.Color.ToString()));
Logger.AddMessage(new LogMessage("Moment of Inertia: x: (" + b1.MomentOfInertia.x.x.ToString() +
", " + b1.MomentOfInertia.x.y.ToString() +
", " + b1.MomentOfInertia.x.z.ToString() + ")" +
" y: (" + b1.MomentOfInertia.y.x.ToString() +
", " + b1.MomentOfInertia.y.y.ToString() +
", " + b1.MomentOfInertia.y.z.ToString() + ")" +
" z: (" + b1.MomentOfInertia.z.x.ToString() +
", " + b1.MomentOfInertia.z.y.ToString() +
", " + b1.MomentOfInertia.z.z.ToString() + ")"));
Logger.AddMessage(new LogMessage("Has '" + b1.Shells.Count.ToString() + "' number of shells."));
Logger.AddMessage(new LogMessage("Surface area: " + b1.SurfaceArea.ToString()));
Logger.AddMessage(new LogMessage("Transform: X: " + b1.Transform.X.ToString() +
" Y: " + b1.Transform.Y.ToString() +
" Z: " + b1.Transform.Z.ToString() +
" Rx: " + b1.Transform.RX.ToString() +
" Ry: " + b1.Transform.RY.ToString() +
" Rz: " + b1.Transform.RZ.ToString()));
Logger.AddMessage(new LogMessage("Visibility: " + b1.Visible.ToString()));
Logger.AddMessage(new LogMessage("Volume: " + b1.Volume.ToString()));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
PrimitiveSize
Gets the dimensions of the body if the PrimitiveType is known.
Declaration
public Vector3 PrimitiveSize { get; }
Property Value
Type | Description |
---|---|
Vector3 |
PrimitiveType
Gets the type of primitive for a body that was created by a method such as CreateSolidBox(Matrix4, Vector3).
Declaration
public BodyPrimitiveType PrimitiveType { get; }
Property Value
Type | Description |
---|---|
BodyPrimitiveType |
Remarks
For imported geometry or bodies that have been modified, Unknown is returned.
Shells
Gets a ShellCollection that contains all the shells in the body.
Declaration
public ShellCollection Shells { get; }
Property Value
Type | Description |
---|---|
ShellCollection |
Examples
Get Shells.
Project.UndoContext.BeginUndoStep("BodyProperties");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
Part p = new Part();
p.Name = "My_Part";
station.GraphicComponents.Add(p);
// Create a solid box.
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Vector3 size = new Vector3(0.5, 0.5, 0.5);
Body b1 = Body.CreateSolidBox(matrix_origo, size);
b1.Name = "Box";
p.Bodies.Add(b1);
// Log a summary of the bodies properties.
Logger.AddMessage(new LogMessage("The body '" + b1.Name + "' has the following properties:"));
Logger.AddMessage(new LogMessage("Center of gravity: x: " + b1.CenterOfGravity.x.ToString() +
" y: " + b1.CenterOfGravity.y.ToString() +
" z: " + b1.CenterOfGravity.z.ToString()));
Logger.AddMessage(new LogMessage("Color: " + b1.Color.ToString()));
Logger.AddMessage(new LogMessage("Moment of Inertia: x: (" + b1.MomentOfInertia.x.x.ToString() +
", " + b1.MomentOfInertia.x.y.ToString() +
", " + b1.MomentOfInertia.x.z.ToString() + ")" +
" y: (" + b1.MomentOfInertia.y.x.ToString() +
", " + b1.MomentOfInertia.y.y.ToString() +
", " + b1.MomentOfInertia.y.z.ToString() + ")" +
" z: (" + b1.MomentOfInertia.z.x.ToString() +
", " + b1.MomentOfInertia.z.y.ToString() +
", " + b1.MomentOfInertia.z.z.ToString() + ")"));
Logger.AddMessage(new LogMessage("Has '" + b1.Shells.Count.ToString() + "' number of shells."));
Logger.AddMessage(new LogMessage("Surface area: " + b1.SurfaceArea.ToString()));
Logger.AddMessage(new LogMessage("Transform: X: " + b1.Transform.X.ToString() +
" Y: " + b1.Transform.Y.ToString() +
" Z: " + b1.Transform.Z.ToString() +
" Rx: " + b1.Transform.RX.ToString() +
" Ry: " + b1.Transform.RY.ToString() +
" Rz: " + b1.Transform.RZ.ToString()));
Logger.AddMessage(new LogMessage("Visibility: " + b1.Visible.ToString()));
Logger.AddMessage(new LogMessage("Volume: " + b1.Volume.ToString()));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
SurfaceArea
Gets the surface area of the body.
Declaration
public double SurfaceArea { get; }
Property Value
Type | Description |
---|---|
Double |
Examples
Get SurfaceArea.
Project.UndoContext.BeginUndoStep("BodyProperties");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
Part p = new Part();
p.Name = "My_Part";
station.GraphicComponents.Add(p);
// Create a solid box.
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Vector3 size = new Vector3(0.5, 0.5, 0.5);
Body b1 = Body.CreateSolidBox(matrix_origo, size);
b1.Name = "Box";
p.Bodies.Add(b1);
// Log a summary of the bodies properties.
Logger.AddMessage(new LogMessage("The body '" + b1.Name + "' has the following properties:"));
Logger.AddMessage(new LogMessage("Center of gravity: x: " + b1.CenterOfGravity.x.ToString() +
" y: " + b1.CenterOfGravity.y.ToString() +
" z: " + b1.CenterOfGravity.z.ToString()));
Logger.AddMessage(new LogMessage("Color: " + b1.Color.ToString()));
Logger.AddMessage(new LogMessage("Moment of Inertia: x: (" + b1.MomentOfInertia.x.x.ToString() +
", " + b1.MomentOfInertia.x.y.ToString() +
", " + b1.MomentOfInertia.x.z.ToString() + ")" +
" y: (" + b1.MomentOfInertia.y.x.ToString() +
", " + b1.MomentOfInertia.y.y.ToString() +
", " + b1.MomentOfInertia.y.z.ToString() + ")" +
" z: (" + b1.MomentOfInertia.z.x.ToString() +
", " + b1.MomentOfInertia.z.y.ToString() +
", " + b1.MomentOfInertia.z.z.ToString() + ")"));
Logger.AddMessage(new LogMessage("Has '" + b1.Shells.Count.ToString() + "' number of shells."));
Logger.AddMessage(new LogMessage("Surface area: " + b1.SurfaceArea.ToString()));
Logger.AddMessage(new LogMessage("Transform: X: " + b1.Transform.X.ToString() +
" Y: " + b1.Transform.Y.ToString() +
" Z: " + b1.Transform.Z.ToString() +
" Rx: " + b1.Transform.RX.ToString() +
" Ry: " + b1.Transform.RY.ToString() +
" Rz: " + b1.Transform.RZ.ToString()));
Logger.AddMessage(new LogMessage("Visibility: " + b1.Visible.ToString()));
Logger.AddMessage(new LogMessage("Volume: " + b1.Volume.ToString()));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Transform
Gets the transform object of the body.
Declaration
public Transform Transform { get; }
Property Value
Type | Description |
---|---|
Transform |
Examples
Get Transform.
Project.UndoContext.BeginUndoStep("BodyProperties");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
Part p = new Part();
p.Name = "My_Part";
station.GraphicComponents.Add(p);
// Create a solid box.
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Vector3 size = new Vector3(0.5, 0.5, 0.5);
Body b1 = Body.CreateSolidBox(matrix_origo, size);
b1.Name = "Box";
p.Bodies.Add(b1);
// Log a summary of the bodies properties.
Logger.AddMessage(new LogMessage("The body '" + b1.Name + "' has the following properties:"));
Logger.AddMessage(new LogMessage("Center of gravity: x: " + b1.CenterOfGravity.x.ToString() +
" y: " + b1.CenterOfGravity.y.ToString() +
" z: " + b1.CenterOfGravity.z.ToString()));
Logger.AddMessage(new LogMessage("Color: " + b1.Color.ToString()));
Logger.AddMessage(new LogMessage("Moment of Inertia: x: (" + b1.MomentOfInertia.x.x.ToString() +
", " + b1.MomentOfInertia.x.y.ToString() +
", " + b1.MomentOfInertia.x.z.ToString() + ")" +
" y: (" + b1.MomentOfInertia.y.x.ToString() +
", " + b1.MomentOfInertia.y.y.ToString() +
", " + b1.MomentOfInertia.y.z.ToString() + ")" +
" z: (" + b1.MomentOfInertia.z.x.ToString() +
", " + b1.MomentOfInertia.z.y.ToString() +
", " + b1.MomentOfInertia.z.z.ToString() + ")"));
Logger.AddMessage(new LogMessage("Has '" + b1.Shells.Count.ToString() + "' number of shells."));
Logger.AddMessage(new LogMessage("Surface area: " + b1.SurfaceArea.ToString()));
Logger.AddMessage(new LogMessage("Transform: X: " + b1.Transform.X.ToString() +
" Y: " + b1.Transform.Y.ToString() +
" Z: " + b1.Transform.Z.ToString() +
" Rx: " + b1.Transform.RX.ToString() +
" Ry: " + b1.Transform.RY.ToString() +
" Rz: " + b1.Transform.RZ.ToString()));
Logger.AddMessage(new LogMessage("Visibility: " + b1.Visible.ToString()));
Logger.AddMessage(new LogMessage("Volume: " + b1.Volume.ToString()));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Visible
Gets or sets whether the body should be visible in the graphics or not.
Declaration
public bool Visible { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Examples
Get/Set Visible.
Project.UndoContext.BeginUndoStep("BodyProperties");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
Part p = new Part();
p.Name = "My_Part";
station.GraphicComponents.Add(p);
// Create a solid box.
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Vector3 size = new Vector3(0.5, 0.5, 0.5);
Body b1 = Body.CreateSolidBox(matrix_origo, size);
b1.Name = "Box";
p.Bodies.Add(b1);
// Log a summary of the bodies properties.
Logger.AddMessage(new LogMessage("The body '" + b1.Name + "' has the following properties:"));
Logger.AddMessage(new LogMessage("Center of gravity: x: " + b1.CenterOfGravity.x.ToString() +
" y: " + b1.CenterOfGravity.y.ToString() +
" z: " + b1.CenterOfGravity.z.ToString()));
Logger.AddMessage(new LogMessage("Color: " + b1.Color.ToString()));
Logger.AddMessage(new LogMessage("Moment of Inertia: x: (" + b1.MomentOfInertia.x.x.ToString() +
", " + b1.MomentOfInertia.x.y.ToString() +
", " + b1.MomentOfInertia.x.z.ToString() + ")" +
" y: (" + b1.MomentOfInertia.y.x.ToString() +
", " + b1.MomentOfInertia.y.y.ToString() +
", " + b1.MomentOfInertia.y.z.ToString() + ")" +
" z: (" + b1.MomentOfInertia.z.x.ToString() +
", " + b1.MomentOfInertia.z.y.ToString() +
", " + b1.MomentOfInertia.z.z.ToString() + ")"));
Logger.AddMessage(new LogMessage("Has '" + b1.Shells.Count.ToString() + "' number of shells."));
Logger.AddMessage(new LogMessage("Surface area: " + b1.SurfaceArea.ToString()));
Logger.AddMessage(new LogMessage("Transform: X: " + b1.Transform.X.ToString() +
" Y: " + b1.Transform.Y.ToString() +
" Z: " + b1.Transform.Z.ToString() +
" Rx: " + b1.Transform.RX.ToString() +
" Ry: " + b1.Transform.RY.ToString() +
" Rz: " + b1.Transform.RZ.ToString()));
Logger.AddMessage(new LogMessage("Visibility: " + b1.Visible.ToString()));
Logger.AddMessage(new LogMessage("Volume: " + b1.Volume.ToString()));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Volume
Gets the volume of the body.
Declaration
public double Volume { get; }
Property Value
Type | Description |
---|---|
Double |
Examples
Get Volume.
Project.UndoContext.BeginUndoStep("BodyProperties");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
Part p = new Part();
p.Name = "My_Part";
station.GraphicComponents.Add(p);
// Create a solid box.
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Vector3 size = new Vector3(0.5, 0.5, 0.5);
Body b1 = Body.CreateSolidBox(matrix_origo, size);
b1.Name = "Box";
p.Bodies.Add(b1);
// Log a summary of the bodies properties.
Logger.AddMessage(new LogMessage("The body '" + b1.Name + "' has the following properties:"));
Logger.AddMessage(new LogMessage("Center of gravity: x: " + b1.CenterOfGravity.x.ToString() +
" y: " + b1.CenterOfGravity.y.ToString() +
" z: " + b1.CenterOfGravity.z.ToString()));
Logger.AddMessage(new LogMessage("Color: " + b1.Color.ToString()));
Logger.AddMessage(new LogMessage("Moment of Inertia: x: (" + b1.MomentOfInertia.x.x.ToString() +
", " + b1.MomentOfInertia.x.y.ToString() +
", " + b1.MomentOfInertia.x.z.ToString() + ")" +
" y: (" + b1.MomentOfInertia.y.x.ToString() +
", " + b1.MomentOfInertia.y.y.ToString() +
", " + b1.MomentOfInertia.y.z.ToString() + ")" +
" z: (" + b1.MomentOfInertia.z.x.ToString() +
", " + b1.MomentOfInertia.z.y.ToString() +
", " + b1.MomentOfInertia.z.z.ToString() + ")"));
Logger.AddMessage(new LogMessage("Has '" + b1.Shells.Count.ToString() + "' number of shells."));
Logger.AddMessage(new LogMessage("Surface area: " + b1.SurfaceArea.ToString()));
Logger.AddMessage(new LogMessage("Transform: X: " + b1.Transform.X.ToString() +
" Y: " + b1.Transform.Y.ToString() +
" Z: " + b1.Transform.Z.ToString() +
" Rx: " + b1.Transform.RX.ToString() +
" Ry: " + b1.Transform.RY.ToString() +
" Rz: " + b1.Transform.RZ.ToString()));
Logger.AddMessage(new LogMessage("Visibility: " + b1.Visible.ToString()));
Logger.AddMessage(new LogMessage("Volume: " + b1.Volume.ToString()));
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Wires
Gets a WireCollection that contains all the wires in the body.
Declaration
public WireCollection Wires { get; }
Property Value
Type | Description |
---|---|
WireCollection |
Methods
Check()
Checks a body's geometry, topology, and data structure for errors.
Declaration
public int Check()
Returns
Type | Description |
---|---|
Int32 | The numbers of errors. |
Check(String)
Checks a body's geometry, topology, and data structure for errors.
Declaration
public int Check(string logFile)
Parameters
Type | Name | Description |
---|---|---|
String | logFile | Name of the logfile to be created. |
Returns
Type | Description |
---|---|
Int32 | The numbers of errors. |
Combine(Body)
Combines two given bodies into one body without performing boolean logic.
Declaration
public Body Combine(Body body)
Parameters
Type | Name | Description |
---|---|---|
Body | body | The body to combine this body with. |
Returns
Type | Description |
---|---|
Body | A new Body that contains copies of all primitives in the input bodies. |
Copy()
Creates a copy of the body.
Declaration
public ProjectObject Copy()
Returns
Type | Description |
---|---|
ProjectObject | The copy. |
Examples
Copy Body.
Project.UndoContext.BeginUndoStep("BodyMethods");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
Part p = new Part();
p.Name = "My_Part";
station.GraphicComponents.Add(p);
// Create a solid box.
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Vector3 size = new Vector3(0.5, 0.5, 0.5);
Body box = Body.CreateSolidBox(matrix_origo, size);
box.Name = "Box";
p.Bodies.Add(box);
// Create two points.
Vector3 point1 = new Vector3(0.1, 0.1, 0.1);
Vector3 point2 = new Vector3(0.6, 0.6, 0.6);
// Test if the points are inside the box.
Logger.AddMessage(new LogMessage("Point one " + point1.ToString() + " is inside the box: " + box.IsPointInside(point1).ToString()));
Logger.AddMessage(new LogMessage("Point two " + point2.ToString() + " is inside the box: " + box.IsPointInside(point2).ToString()));
// Find the vertex closest to point2.
Vertex closestVert = box.FindClosestVertex(point2);
Logger.AddMessage(new LogMessage("The closest vertex to point2 is : (" + closestVert.Position.x.ToString() +
", " + closestVert.Position.y.ToString() +
", " + closestVert.Position.z.ToString() + ")"));
// Copy the box.
Body boxcopy = (Body)box.Copy();
boxcopy.Name = "Copy of " + box.Name;
p.Bodies.Add(boxcopy);
// Remove the original box body.
p.Bodies.Remove(box);
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
CreateArc(Vector3, Vector3, Vector3)
Creates a new Body consisting of one single wire. The wire will start at the start position go via the circumference position and end in the end position
Declaration
public static Body CreateArc(Vector3 start, Vector3 end, Vector3 circumference)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | start | The start position of the arc. |
Vector3 | end | The end position of the arc. |
Vector3 | circumference | The via position of the arc. |
Returns
Type | Description |
---|---|
Body | The new Body. |
Examples
Create Arc.
Project.UndoContext.BeginUndoStep("BodyCreateCurves");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyCreateCurvesStep1
Part p = new Part();
p.Name = "My_Curves";
station.GraphicComponents.Add(p);
#endregion
// Create an arc.
#region BodyCreateCurvesStep2
Vector3 start = new Vector3(0.0, 0.0, 0.0);
Vector3 end = new Vector3(0.5, 0.5, 0.5);
Vector3 via = new Vector3(0.25, 0.25, 0.0);
Body b1 = Body.CreateArc(start, end, via);
b1.Name = "Arc";
p.Bodies.Add(b1);
#endregion
// Create a circle.
#region BodyCreateCurvesStep3
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Body b2 = Body.CreateCircle(matrix_origo, 0.5);
b2.Name = "Circle";
p.Bodies.Add(b2);
#endregion
// Create an ellipse.
#region BodyCreateCurvesStep4
Vector3 vector_origo = new Vector3(0.0, 0.0, 0.0);
Body b3 = Body.CreateEllipse(vector_origo, end, 0.25);
b3.Name = "Ellipse";
p.Bodies.Add(b3);
#endregion
// Create an elliptic arc.
#region BodyCreateCurvesStep5
Body b4 = Body.CreateEllipticArc(vector_origo, end, via, 0.3, 1.1);
b4.Name = "Elliptic arc";
p.Bodies.Add(b4);
#endregion
// Create a line.
#region BodyCreateCurvesStep6
Body b5 = Body.CreateLine(start, end);
b5.Name = "Line";
p.Bodies.Add(b5);
#endregion
// Create a polygon.
#region BodyCreateCurvesStep7
Body b6 = Body.CreatePolygon(vector_origo, via, 8);
b6.Name = "Polygon";
p.Bodies.Add(b6);
#endregion
// Create a polyline.
#region BodyCreateCurvesStep8
Vector3[] vertices = new Vector3[3] { start, via, end };
Body b7 = Body.CreatePolyLine(vertices);
b7.Name = "Polyline";
p.Bodies.Add(b7);
#endregion
// Create a reactangle.
#region BodyCreateCurvesStep9
Body b8 = Body.CreateRectangle(matrix_origo, 0.7, 0.3);
b8.Name = "Reactangle";
p.Bodies.Add(b8);
#endregion
// Create a spline.
#region BodyCreateCurvesStep10
Body b9 = Body.CreateSpline(vertices, 0.2);
b9.Name = "Spline";
p.Bodies.Add(b9);
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
CreateBorderAroundFace(Face)
Declaration
public static Body CreateBorderAroundFace(Face face)
Parameters
Type | Name | Description |
---|---|---|
Face | face | Defines the face to use. |
Returns
Type | Description |
---|---|
Body | The new Body. |
Examples
Create Border Around Face.
Project.UndoContext.BeginUndoStep("BodyAdvancedCurves");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyAdvancedCurvesStep1
Part p = new Part();
p.Name = "My_Advanced_Curves";
station.GraphicComponents.Add(p);
#endregion
// Create border around face.
// First create a box.
#region BodyAdvancedCurvesStep2
Matrix4 origin = new Matrix4(new Vector3(Axis.X), 0.0);
Vector3 size = new Vector3(0.5, 0.5, 0.5);
Body box = Body.CreateSolidBox(origin, size);
box.Name = "Box";
p.Bodies.Add(box);
#endregion
// Then create the border curve.
#region BodyAdvancedCurvesStep3
Body b1 = Body.CreateBorderAroundFace(box.Shells[0].Faces[0]);
b1.Name = "Face Border";
p.Bodies.Add(b1);
#endregion
// Create border from points.
// Create an array of points of the box.
#region BodyAdvancedCurvesStep4
Vector3 p1 = new Vector3(0.0, 0.0, 0.0);
Vector3 p2 = new Vector3(0.5, 0.0, 0.0);
Vector3 p3 = new Vector3(0.5, 0.5, 0.0);
Vector3 p4 = new Vector3(0.5, 0.5, 0.5);
Vector3[] points = new Vector3[4] { p1, p2, p3, p4 };
#endregion
#region BodyAdvancedCurvesStep5
Body b2 = Body.CreateBorderFromPoints(box, points);
b2.Name = "Border from Points";
p.Bodies.Add(b2);
#endregion
// Create Intersection Curve.
// Create a SolidSphere.
#region BodyAdvancedCurvesStep6
Body sphere = Body.CreateSolidSphere(new Vector3(0.25, 0.25, 0.25), 0.3);
p.Bodies.Add(sphere);
#endregion
#region BodyAdvancedCurvesStep7
Body intersectionCurve = Body.CreateIntersectionCurve(box, sphere);
p.Bodies.Add(intersectionCurve);
#endregion
// Create the same curve using the non static intersection curve method.
Body intersectionCurve2 = box.CreateIntersectionCurve(sphere);
p.Bodies.Add(intersectionCurve2);
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
CreateBorderFromPoints(Body, Vector3[])
Creates a new Body consisting of the curve defined by the body and the points.
Declaration
public static Body CreateBorderFromPoints(Body body, Vector3[] points)
Parameters
Type | Name | Description |
---|---|---|
Body | body | Defines the body to use. |
Vector3[] | points | Defines the array of points to use. |
Returns
Type | Description |
---|---|
Body | The new Body. |
Remarks
If the points specified are not on the body, the closest projection of them onto the body is used.
Examples
Create Borders From Points.
Project.UndoContext.BeginUndoStep("BodyAdvancedCurves");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyAdvancedCurvesStep1
Part p = new Part();
p.Name = "My_Advanced_Curves";
station.GraphicComponents.Add(p);
#endregion
// Create border around face.
// First create a box.
#region BodyAdvancedCurvesStep2
Matrix4 origin = new Matrix4(new Vector3(Axis.X), 0.0);
Vector3 size = new Vector3(0.5, 0.5, 0.5);
Body box = Body.CreateSolidBox(origin, size);
box.Name = "Box";
p.Bodies.Add(box);
#endregion
// Then create the border curve.
#region BodyAdvancedCurvesStep3
Body b1 = Body.CreateBorderAroundFace(box.Shells[0].Faces[0]);
b1.Name = "Face Border";
p.Bodies.Add(b1);
#endregion
// Create border from points.
// Create an array of points of the box.
#region BodyAdvancedCurvesStep4
Vector3 p1 = new Vector3(0.0, 0.0, 0.0);
Vector3 p2 = new Vector3(0.5, 0.0, 0.0);
Vector3 p3 = new Vector3(0.5, 0.5, 0.0);
Vector3 p4 = new Vector3(0.5, 0.5, 0.5);
Vector3[] points = new Vector3[4] { p1, p2, p3, p4 };
#endregion
#region BodyAdvancedCurvesStep5
Body b2 = Body.CreateBorderFromPoints(box, points);
b2.Name = "Border from Points";
p.Bodies.Add(b2);
#endregion
// Create Intersection Curve.
// Create a SolidSphere.
#region BodyAdvancedCurvesStep6
Body sphere = Body.CreateSolidSphere(new Vector3(0.25, 0.25, 0.25), 0.3);
p.Bodies.Add(sphere);
#endregion
#region BodyAdvancedCurvesStep7
Body intersectionCurve = Body.CreateIntersectionCurve(box, sphere);
p.Bodies.Add(intersectionCurve);
#endregion
// Create the same curve using the non static intersection curve method.
Body intersectionCurve2 = box.CreateIntersectionCurve(sphere);
p.Bodies.Add(intersectionCurve2);
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
CreateCircle(Matrix4, Double)
Creates a new Body consisting of one single circle shaped wire.
Declaration
public static Body CreateCircle(Matrix4 center, double radius)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | center | A matrix that defines the center position and rotation of the circle |
Double | radius | The radius of the circle |
Returns
Type | Description |
---|---|
Body | The new Body. |
Examples
Create Circle.
Project.UndoContext.BeginUndoStep("BodyCreateCurves");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyCreateCurvesStep1
Part p = new Part();
p.Name = "My_Curves";
station.GraphicComponents.Add(p);
#endregion
// Create an arc.
#region BodyCreateCurvesStep2
Vector3 start = new Vector3(0.0, 0.0, 0.0);
Vector3 end = new Vector3(0.5, 0.5, 0.5);
Vector3 via = new Vector3(0.25, 0.25, 0.0);
Body b1 = Body.CreateArc(start, end, via);
b1.Name = "Arc";
p.Bodies.Add(b1);
#endregion
// Create a circle.
#region BodyCreateCurvesStep3
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Body b2 = Body.CreateCircle(matrix_origo, 0.5);
b2.Name = "Circle";
p.Bodies.Add(b2);
#endregion
// Create an ellipse.
#region BodyCreateCurvesStep4
Vector3 vector_origo = new Vector3(0.0, 0.0, 0.0);
Body b3 = Body.CreateEllipse(vector_origo, end, 0.25);
b3.Name = "Ellipse";
p.Bodies.Add(b3);
#endregion
// Create an elliptic arc.
#region BodyCreateCurvesStep5
Body b4 = Body.CreateEllipticArc(vector_origo, end, via, 0.3, 1.1);
b4.Name = "Elliptic arc";
p.Bodies.Add(b4);
#endregion
// Create a line.
#region BodyCreateCurvesStep6
Body b5 = Body.CreateLine(start, end);
b5.Name = "Line";
p.Bodies.Add(b5);
#endregion
// Create a polygon.
#region BodyCreateCurvesStep7
Body b6 = Body.CreatePolygon(vector_origo, via, 8);
b6.Name = "Polygon";
p.Bodies.Add(b6);
#endregion
// Create a polyline.
#region BodyCreateCurvesStep8
Vector3[] vertices = new Vector3[3] { start, via, end };
Body b7 = Body.CreatePolyLine(vertices);
b7.Name = "Polyline";
p.Bodies.Add(b7);
#endregion
// Create a reactangle.
#region BodyCreateCurvesStep9
Body b8 = Body.CreateRectangle(matrix_origo, 0.7, 0.3);
b8.Name = "Reactangle";
p.Bodies.Add(b8);
#endregion
// Create a spline.
#region BodyCreateCurvesStep10
Body b9 = Body.CreateSpline(vertices, 0.2);
b9.Name = "Spline";
p.Bodies.Add(b9);
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
CreateCubicSplineCurve(IEnumerable<Vector3>, Double)
Creates a wire body by interpolating or fitting curve to the specified control points.
Declaration
public static Body CreateCubicSplineCurve(IEnumerable<Vector3> controlPoints, double fitTolerance)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Vector3> | controlPoints | |
Double | fitTolerance | If 0, the curve is interpolated through the control points. If > 0 the curve is fit to the control points. |
Returns
Type | Description |
---|---|
Body |
CreateEllipse(Vector3, Vector3, Double)
Creates a new Body consisting of one single ellipse shaped wire.
Declaration
public static Body CreateEllipse(Vector3 center, Vector3 majorAxisEnd, double minorAxisDist)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | center | A position that defines the center position of the ellipse |
Vector3 | majorAxisEnd | A position specifying the end of the major axis |
Double | minorAxisDist | The distace from the center to the minor axis, i.e. the radius of the minor axis |
Returns
Type | Description |
---|---|
Body | The new Body. |
Examples
Create Ellipse.
Project.UndoContext.BeginUndoStep("BodyCreateCurves");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyCreateCurvesStep1
Part p = new Part();
p.Name = "My_Curves";
station.GraphicComponents.Add(p);
#endregion
// Create an arc.
#region BodyCreateCurvesStep2
Vector3 start = new Vector3(0.0, 0.0, 0.0);
Vector3 end = new Vector3(0.5, 0.5, 0.5);
Vector3 via = new Vector3(0.25, 0.25, 0.0);
Body b1 = Body.CreateArc(start, end, via);
b1.Name = "Arc";
p.Bodies.Add(b1);
#endregion
// Create a circle.
#region BodyCreateCurvesStep3
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Body b2 = Body.CreateCircle(matrix_origo, 0.5);
b2.Name = "Circle";
p.Bodies.Add(b2);
#endregion
// Create an ellipse.
#region BodyCreateCurvesStep4
Vector3 vector_origo = new Vector3(0.0, 0.0, 0.0);
Body b3 = Body.CreateEllipse(vector_origo, end, 0.25);
b3.Name = "Ellipse";
p.Bodies.Add(b3);
#endregion
// Create an elliptic arc.
#region BodyCreateCurvesStep5
Body b4 = Body.CreateEllipticArc(vector_origo, end, via, 0.3, 1.1);
b4.Name = "Elliptic arc";
p.Bodies.Add(b4);
#endregion
// Create a line.
#region BodyCreateCurvesStep6
Body b5 = Body.CreateLine(start, end);
b5.Name = "Line";
p.Bodies.Add(b5);
#endregion
// Create a polygon.
#region BodyCreateCurvesStep7
Body b6 = Body.CreatePolygon(vector_origo, via, 8);
b6.Name = "Polygon";
p.Bodies.Add(b6);
#endregion
// Create a polyline.
#region BodyCreateCurvesStep8
Vector3[] vertices = new Vector3[3] { start, via, end };
Body b7 = Body.CreatePolyLine(vertices);
b7.Name = "Polyline";
p.Bodies.Add(b7);
#endregion
// Create a reactangle.
#region BodyCreateCurvesStep9
Body b8 = Body.CreateRectangle(matrix_origo, 0.7, 0.3);
b8.Name = "Reactangle";
p.Bodies.Add(b8);
#endregion
// Create a spline.
#region BodyCreateCurvesStep10
Body b9 = Body.CreateSpline(vertices, 0.2);
b9.Name = "Spline";
p.Bodies.Add(b9);
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
CreateEllipticArc(Vector3, Vector3, Vector3, Double, Double)
Creates a new Body consisting of one single elliptical arc shaped wire.
Declaration
public static Body CreateEllipticArc(Vector3 center, Vector3 majorAxisEnd, Vector3 minorAxisEnd, double startAngle, double endAngle)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | center | Defines the center position of the arc. |
Vector3 | majorAxisEnd | Defines the end position of the major axis. |
Vector3 | minorAxisEnd | Defines the end position of the minor axis. |
Double | startAngle | Defines the start angle. |
Double | endAngle | Defines the end angle. |
Returns
Type | Description |
---|---|
Body | The new Body. |
Examples
Create Eliptic Arc.
Project.UndoContext.BeginUndoStep("BodyCreateCurves");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyCreateCurvesStep1
Part p = new Part();
p.Name = "My_Curves";
station.GraphicComponents.Add(p);
#endregion
// Create an arc.
#region BodyCreateCurvesStep2
Vector3 start = new Vector3(0.0, 0.0, 0.0);
Vector3 end = new Vector3(0.5, 0.5, 0.5);
Vector3 via = new Vector3(0.25, 0.25, 0.0);
Body b1 = Body.CreateArc(start, end, via);
b1.Name = "Arc";
p.Bodies.Add(b1);
#endregion
// Create a circle.
#region BodyCreateCurvesStep3
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Body b2 = Body.CreateCircle(matrix_origo, 0.5);
b2.Name = "Circle";
p.Bodies.Add(b2);
#endregion
// Create an ellipse.
#region BodyCreateCurvesStep4
Vector3 vector_origo = new Vector3(0.0, 0.0, 0.0);
Body b3 = Body.CreateEllipse(vector_origo, end, 0.25);
b3.Name = "Ellipse";
p.Bodies.Add(b3);
#endregion
// Create an elliptic arc.
#region BodyCreateCurvesStep5
Body b4 = Body.CreateEllipticArc(vector_origo, end, via, 0.3, 1.1);
b4.Name = "Elliptic arc";
p.Bodies.Add(b4);
#endregion
// Create a line.
#region BodyCreateCurvesStep6
Body b5 = Body.CreateLine(start, end);
b5.Name = "Line";
p.Bodies.Add(b5);
#endregion
// Create a polygon.
#region BodyCreateCurvesStep7
Body b6 = Body.CreatePolygon(vector_origo, via, 8);
b6.Name = "Polygon";
p.Bodies.Add(b6);
#endregion
// Create a polyline.
#region BodyCreateCurvesStep8
Vector3[] vertices = new Vector3[3] { start, via, end };
Body b7 = Body.CreatePolyLine(vertices);
b7.Name = "Polyline";
p.Bodies.Add(b7);
#endregion
// Create a reactangle.
#region BodyCreateCurvesStep9
Body b8 = Body.CreateRectangle(matrix_origo, 0.7, 0.3);
b8.Name = "Reactangle";
p.Bodies.Add(b8);
#endregion
// Create a spline.
#region BodyCreateCurvesStep10
Body b9 = Body.CreateSpline(vertices, 0.2);
b9.Name = "Spline";
p.Bodies.Add(b9);
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
CreateFromFace(Face)
Creates a new Body consisting only of a copy of the given Face
Declaration
public static Body CreateFromFace(Face face)
Parameters
Type | Name | Description |
---|---|---|
Face | face |
Returns
Type | Description |
---|---|
Body |
CreateIntersectionCurve(Body)
Declaration
public Body CreateIntersectionCurve(Body body)
Parameters
Type | Name | Description |
---|---|---|
Body | body |
Returns
Type | Description |
---|---|
Body |
CreateIntersectionCurve(Body, Body)
Creates a new Body consisting of the curve(s) at the intersection of two bodies.
Declaration
public static Body CreateIntersectionCurve(Body body1, Body body2)
Parameters
Type | Name | Description |
---|---|---|
Body | body1 | Defines the first body to use. |
Body | body2 | Defines the second body to use. |
Returns
Type | Description |
---|---|
Body | The new Body |
Examples
Create Intersection Curve.
Project.UndoContext.BeginUndoStep("BodyAdvancedCurves");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyAdvancedCurvesStep1
Part p = new Part();
p.Name = "My_Advanced_Curves";
station.GraphicComponents.Add(p);
#endregion
// Create border around face.
// First create a box.
#region BodyAdvancedCurvesStep2
Matrix4 origin = new Matrix4(new Vector3(Axis.X), 0.0);
Vector3 size = new Vector3(0.5, 0.5, 0.5);
Body box = Body.CreateSolidBox(origin, size);
box.Name = "Box";
p.Bodies.Add(box);
#endregion
// Then create the border curve.
#region BodyAdvancedCurvesStep3
Body b1 = Body.CreateBorderAroundFace(box.Shells[0].Faces[0]);
b1.Name = "Face Border";
p.Bodies.Add(b1);
#endregion
// Create border from points.
// Create an array of points of the box.
#region BodyAdvancedCurvesStep4
Vector3 p1 = new Vector3(0.0, 0.0, 0.0);
Vector3 p2 = new Vector3(0.5, 0.0, 0.0);
Vector3 p3 = new Vector3(0.5, 0.5, 0.0);
Vector3 p4 = new Vector3(0.5, 0.5, 0.5);
Vector3[] points = new Vector3[4] { p1, p2, p3, p4 };
#endregion
#region BodyAdvancedCurvesStep5
Body b2 = Body.CreateBorderFromPoints(box, points);
b2.Name = "Border from Points";
p.Bodies.Add(b2);
#endregion
// Create Intersection Curve.
// Create a SolidSphere.
#region BodyAdvancedCurvesStep6
Body sphere = Body.CreateSolidSphere(new Vector3(0.25, 0.25, 0.25), 0.3);
p.Bodies.Add(sphere);
#endregion
#region BodyAdvancedCurvesStep7
Body intersectionCurve = Body.CreateIntersectionCurve(box, sphere);
p.Bodies.Add(intersectionCurve);
#endregion
// Create the same curve using the non static intersection curve method.
Body intersectionCurve2 = box.CreateIntersectionCurve(sphere);
p.Bodies.Add(intersectionCurve2);
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
CreateIntersectionCurve(Face, Face)
Creates a new wire Body consisting of the curve(s) at the intersection of two faces.
Declaration
public static Body CreateIntersectionCurve(Face face1, Face face2)
Parameters
Type | Name | Description |
---|---|---|
Face | face1 | Defines the first face to use. |
Face | face2 | Defines the second face to use. |
Returns
Type | Description |
---|---|
Body | The new Body |
CreateLine(Vector3, Vector3)
Creates a new Body consisting of one single line shaped wire.
Declaration
public static Body CreateLine(Vector3 start, Vector3 end)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | start | Defines the start position of the line. |
Vector3 | end | Defines the end position of the line. |
Returns
Type | Description |
---|---|
Body | The new Body. |
Examples
Create Line.
Project.UndoContext.BeginUndoStep("BodyCreateCurves");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyCreateCurvesStep1
Part p = new Part();
p.Name = "My_Curves";
station.GraphicComponents.Add(p);
#endregion
// Create an arc.
#region BodyCreateCurvesStep2
Vector3 start = new Vector3(0.0, 0.0, 0.0);
Vector3 end = new Vector3(0.5, 0.5, 0.5);
Vector3 via = new Vector3(0.25, 0.25, 0.0);
Body b1 = Body.CreateArc(start, end, via);
b1.Name = "Arc";
p.Bodies.Add(b1);
#endregion
// Create a circle.
#region BodyCreateCurvesStep3
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Body b2 = Body.CreateCircle(matrix_origo, 0.5);
b2.Name = "Circle";
p.Bodies.Add(b2);
#endregion
// Create an ellipse.
#region BodyCreateCurvesStep4
Vector3 vector_origo = new Vector3(0.0, 0.0, 0.0);
Body b3 = Body.CreateEllipse(vector_origo, end, 0.25);
b3.Name = "Ellipse";
p.Bodies.Add(b3);
#endregion
// Create an elliptic arc.
#region BodyCreateCurvesStep5
Body b4 = Body.CreateEllipticArc(vector_origo, end, via, 0.3, 1.1);
b4.Name = "Elliptic arc";
p.Bodies.Add(b4);
#endregion
// Create a line.
#region BodyCreateCurvesStep6
Body b5 = Body.CreateLine(start, end);
b5.Name = "Line";
p.Bodies.Add(b5);
#endregion
// Create a polygon.
#region BodyCreateCurvesStep7
Body b6 = Body.CreatePolygon(vector_origo, via, 8);
b6.Name = "Polygon";
p.Bodies.Add(b6);
#endregion
// Create a polyline.
#region BodyCreateCurvesStep8
Vector3[] vertices = new Vector3[3] { start, via, end };
Body b7 = Body.CreatePolyLine(vertices);
b7.Name = "Polyline";
p.Bodies.Add(b7);
#endregion
// Create a reactangle.
#region BodyCreateCurvesStep9
Body b8 = Body.CreateRectangle(matrix_origo, 0.7, 0.3);
b8.Name = "Reactangle";
p.Bodies.Add(b8);
#endregion
// Create a spline.
#region BodyCreateCurvesStep10
Body b9 = Body.CreateSpline(vertices, 0.2);
b9.Name = "Spline";
p.Bodies.Add(b9);
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
CreateOffsetWire(Coedge[], Double, Boolean)
ABB internal use only
Declaration
public static Body CreateOffsetWire(Coedge[] coedges, double distance, bool adjacentface)
Parameters
Type | Name | Description |
---|---|---|
Coedge[] | coedges | |
Double | distance | |
Boolean | adjacentface |
Returns
Type | Description |
---|---|
Body |
CreateParametricCurveU(Face, Double)
Creates a new wire Body consisting of the u-parametric curve(s) on the surface of the face.
Declaration
public static Body CreateParametricCurveU(Face face, double vParam)
Parameters
Type | Name | Description |
---|---|---|
Face | face | Defines the face to use. |
Double | vParam | V-parameter. |
Returns
Type | Description |
---|---|
Body | The new Body. |
Remarks
The face must be a spline surface.
CreateParametricCurveV(Face, Double)
Creates a new wire Body consisting of the v-parametric curve(s) on the surface of the face.
Declaration
public static Body CreateParametricCurveV(Face face, double uParam)
Parameters
Type | Name | Description |
---|---|---|
Face | face | Defines the face to use. |
Double | uParam | U-parameter. |
Returns
Type | Description |
---|---|
Body | The new Body. |
Remarks
The face must be a spline surface.
CreatePolygon(Vector3, Vector3, Int32)
Creates a new Body consisting of one single polygon shaped wire.
Declaration
public static Body CreatePolygon(Vector3 start, Vector3 vertex, int numberEdges)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | start | Defines the center position of the polygon. |
Vector3 | vertex | Defines the a position at one of the corners/vertices of the polygon, used to calculate distance between the center point and the vertices in the polygon. |
Int32 | numberEdges | Defines the nummber of edges in the polygon. |
Returns
Type | Description |
---|---|
Body | The new Body. |
Examples
Create Polygon.
Project.UndoContext.BeginUndoStep("BodyCreateCurves");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyCreateCurvesStep1
Part p = new Part();
p.Name = "My_Curves";
station.GraphicComponents.Add(p);
#endregion
// Create an arc.
#region BodyCreateCurvesStep2
Vector3 start = new Vector3(0.0, 0.0, 0.0);
Vector3 end = new Vector3(0.5, 0.5, 0.5);
Vector3 via = new Vector3(0.25, 0.25, 0.0);
Body b1 = Body.CreateArc(start, end, via);
b1.Name = "Arc";
p.Bodies.Add(b1);
#endregion
// Create a circle.
#region BodyCreateCurvesStep3
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Body b2 = Body.CreateCircle(matrix_origo, 0.5);
b2.Name = "Circle";
p.Bodies.Add(b2);
#endregion
// Create an ellipse.
#region BodyCreateCurvesStep4
Vector3 vector_origo = new Vector3(0.0, 0.0, 0.0);
Body b3 = Body.CreateEllipse(vector_origo, end, 0.25);
b3.Name = "Ellipse";
p.Bodies.Add(b3);
#endregion
// Create an elliptic arc.
#region BodyCreateCurvesStep5
Body b4 = Body.CreateEllipticArc(vector_origo, end, via, 0.3, 1.1);
b4.Name = "Elliptic arc";
p.Bodies.Add(b4);
#endregion
// Create a line.
#region BodyCreateCurvesStep6
Body b5 = Body.CreateLine(start, end);
b5.Name = "Line";
p.Bodies.Add(b5);
#endregion
// Create a polygon.
#region BodyCreateCurvesStep7
Body b6 = Body.CreatePolygon(vector_origo, via, 8);
b6.Name = "Polygon";
p.Bodies.Add(b6);
#endregion
// Create a polyline.
#region BodyCreateCurvesStep8
Vector3[] vertices = new Vector3[3] { start, via, end };
Body b7 = Body.CreatePolyLine(vertices);
b7.Name = "Polyline";
p.Bodies.Add(b7);
#endregion
// Create a reactangle.
#region BodyCreateCurvesStep9
Body b8 = Body.CreateRectangle(matrix_origo, 0.7, 0.3);
b8.Name = "Reactangle";
p.Bodies.Add(b8);
#endregion
// Create a spline.
#region BodyCreateCurvesStep10
Body b9 = Body.CreateSpline(vertices, 0.2);
b9.Name = "Spline";
p.Bodies.Add(b9);
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
CreatePolygonFenceFromRays(IEnumerable<Ray>, Body, Double)
Creates a sheet body shaped as a polygon fence where the rays forms the fence posts.
Declaration
public static Body CreatePolygonFenceFromRays(IEnumerable<Ray> rays, Body target, double fenceHeight)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Ray> | rays | |
Body | target | |
Double | fenceHeight |
Returns
Type | Description |
---|---|
Body |
CreatePolyLine(Vector3[])
Creates a new Body consisting of one single polyline wire.
Declaration
public static Body CreatePolyLine(Vector3[] vertices)
Parameters
Type | Name | Description |
---|---|---|
Vector3[] | vertices | Defines the vertices/positions used to create the polyline. |
Returns
Type | Description |
---|---|
Body | The new Body. |
Remarks
The wire is considered closed if the first and last vertices coincide.
Examples
Create Polyline.
Project.UndoContext.BeginUndoStep("BodyCreateCurves");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyCreateCurvesStep1
Part p = new Part();
p.Name = "My_Curves";
station.GraphicComponents.Add(p);
#endregion
// Create an arc.
#region BodyCreateCurvesStep2
Vector3 start = new Vector3(0.0, 0.0, 0.0);
Vector3 end = new Vector3(0.5, 0.5, 0.5);
Vector3 via = new Vector3(0.25, 0.25, 0.0);
Body b1 = Body.CreateArc(start, end, via);
b1.Name = "Arc";
p.Bodies.Add(b1);
#endregion
// Create a circle.
#region BodyCreateCurvesStep3
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Body b2 = Body.CreateCircle(matrix_origo, 0.5);
b2.Name = "Circle";
p.Bodies.Add(b2);
#endregion
// Create an ellipse.
#region BodyCreateCurvesStep4
Vector3 vector_origo = new Vector3(0.0, 0.0, 0.0);
Body b3 = Body.CreateEllipse(vector_origo, end, 0.25);
b3.Name = "Ellipse";
p.Bodies.Add(b3);
#endregion
// Create an elliptic arc.
#region BodyCreateCurvesStep5
Body b4 = Body.CreateEllipticArc(vector_origo, end, via, 0.3, 1.1);
b4.Name = "Elliptic arc";
p.Bodies.Add(b4);
#endregion
// Create a line.
#region BodyCreateCurvesStep6
Body b5 = Body.CreateLine(start, end);
b5.Name = "Line";
p.Bodies.Add(b5);
#endregion
// Create a polygon.
#region BodyCreateCurvesStep7
Body b6 = Body.CreatePolygon(vector_origo, via, 8);
b6.Name = "Polygon";
p.Bodies.Add(b6);
#endregion
// Create a polyline.
#region BodyCreateCurvesStep8
Vector3[] vertices = new Vector3[3] { start, via, end };
Body b7 = Body.CreatePolyLine(vertices);
b7.Name = "Polyline";
p.Bodies.Add(b7);
#endregion
// Create a reactangle.
#region BodyCreateCurvesStep9
Body b8 = Body.CreateRectangle(matrix_origo, 0.7, 0.3);
b8.Name = "Reactangle";
p.Bodies.Add(b8);
#endregion
// Create a spline.
#region BodyCreateCurvesStep10
Body b9 = Body.CreateSpline(vertices, 0.2);
b9.Name = "Spline";
p.Bodies.Add(b9);
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
CreateRectangle(Matrix4, Double, Double)
Creates a new Body consisting of one single rectangle shaped wire.
Declaration
public static Body CreateRectangle(Matrix4 corner, double length, double width)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | corner | Defines the corner position and rotation of the rectangle. |
Double | length | Defines the length of the rectangle. |
Double | width | Defines the width of the rectangle. |
Returns
Type | Description |
---|---|
Body | The new Body. |
Examples
Create Rectangle.
Project.UndoContext.BeginUndoStep("BodyCreateCurves");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyCreateCurvesStep1
Part p = new Part();
p.Name = "My_Curves";
station.GraphicComponents.Add(p);
#endregion
// Create an arc.
#region BodyCreateCurvesStep2
Vector3 start = new Vector3(0.0, 0.0, 0.0);
Vector3 end = new Vector3(0.5, 0.5, 0.5);
Vector3 via = new Vector3(0.25, 0.25, 0.0);
Body b1 = Body.CreateArc(start, end, via);
b1.Name = "Arc";
p.Bodies.Add(b1);
#endregion
// Create a circle.
#region BodyCreateCurvesStep3
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Body b2 = Body.CreateCircle(matrix_origo, 0.5);
b2.Name = "Circle";
p.Bodies.Add(b2);
#endregion
// Create an ellipse.
#region BodyCreateCurvesStep4
Vector3 vector_origo = new Vector3(0.0, 0.0, 0.0);
Body b3 = Body.CreateEllipse(vector_origo, end, 0.25);
b3.Name = "Ellipse";
p.Bodies.Add(b3);
#endregion
// Create an elliptic arc.
#region BodyCreateCurvesStep5
Body b4 = Body.CreateEllipticArc(vector_origo, end, via, 0.3, 1.1);
b4.Name = "Elliptic arc";
p.Bodies.Add(b4);
#endregion
// Create a line.
#region BodyCreateCurvesStep6
Body b5 = Body.CreateLine(start, end);
b5.Name = "Line";
p.Bodies.Add(b5);
#endregion
// Create a polygon.
#region BodyCreateCurvesStep7
Body b6 = Body.CreatePolygon(vector_origo, via, 8);
b6.Name = "Polygon";
p.Bodies.Add(b6);
#endregion
// Create a polyline.
#region BodyCreateCurvesStep8
Vector3[] vertices = new Vector3[3] { start, via, end };
Body b7 = Body.CreatePolyLine(vertices);
b7.Name = "Polyline";
p.Bodies.Add(b7);
#endregion
// Create a reactangle.
#region BodyCreateCurvesStep9
Body b8 = Body.CreateRectangle(matrix_origo, 0.7, 0.3);
b8.Name = "Reactangle";
p.Bodies.Add(b8);
#endregion
// Create a spline.
#region BodyCreateCurvesStep10
Body b9 = Body.CreateSpline(vertices, 0.2);
b9.Name = "Spline";
p.Bodies.Add(b9);
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
CreateSheetBody(IEnumerable<Face>)
Creates a sheet (non-solid) body from the given faces.
Declaration
public static Body CreateSheetBody(IEnumerable<Face> faces)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Face> | faces |
Returns
Type | Description |
---|---|
Body |
Remarks
All input faces must belong to the same Body.
CreateSolidBox(Matrix4, Vector3)
Creates a new Body consisting of a solid box.
Declaration
public static Body CreateSolidBox(Matrix4 origin, Vector3 size)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | origin | Defines the origin position and rotation of the box. |
Vector3 | size | Defines the length, height and width of the box. |
Returns
Type | Description |
---|---|
Body | The new Body. |
Examples
Create Solid Box.
Project.UndoContext.BeginUndoStep("BodyCreateSolids");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyCreateSolidsStep1
Part p = new Part();
p.Name = "My_Solid_Bodies";
station.GraphicComponents.Add(p);
#endregion
// Create a solid box.
#region BodyCreateSolidsStep2
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Vector3 size = new Vector3(0.5, 0.5, 0.5);
Body b1 = Body.CreateSolidBox(matrix_origo, size);
b1.Name = "Box";
p.Bodies.Add(b1);
#endregion
// Create a cone.
#region BodyCreateSolidsStep3
Body b2 = Body.CreateSolidCone(matrix_origo, 1.0, 1.0);
b2.Name = "Cone";
p.Bodies.Add(b2);
#endregion
// Create a cylinder.
#region BodyCreateSolidsStep4
Body b3 = Body.CreateSolidCylinder(matrix_origo, 0.5, 0.5);
b3.Name = "Cylinder";
p.Bodies.Add(b3);
#endregion
// Create a pyramid.
#region BodyCreateSolidsStep5
Body b4 = Body.CreateSolidPyramid(matrix_origo, 1.0, 1.0, 6);
b4.Name = "Pyramid";
p.Bodies.Add(b4);
#endregion
// Create a sphere.
#region BodyCreateSolidsStep6
Vector3 vector_origo = new Vector3(0.0, 0.0, 0.0);
Body b5 = Body.CreateSolidSphere(vector_origo, 0.75);
b5.Name = "Sphere";
p.Bodies.Add(b5);
#endregion
// Create a torus.
#region BodyCreateSolidsStep7
Body b6 = Body.CreateSolidTorus(matrix_origo, 1.0, 0.5);
b6.Name = "Torus";
p.Bodies.Add(b6);
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
CreateSolidCapsule(Matrix4, Double, Double)
Creates a new capsule (a cylinder with spherical endcaps).
Declaration
public static Body CreateSolidCapsule(Matrix4 center, double radius, double height)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | center | Defines the position and rotation of the capsule |
Double | radius | Defines the radius of the capsule |
Double | height | Defines the total height (including endcaps) of the capsule |
Returns
Type | Description |
---|---|
Body |
CreateSolidCone(Matrix4, Double, Double)
Creates a new Body consisting of a solid cone.
Declaration
public static Body CreateSolidCone(Matrix4 center, double radius, double height)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | center | Defines the center position and rotation of the cone. |
Double | radius | Defines the radius of the base circle of the cone. |
Double | height | Defines the height of the cone. |
Returns
Type | Description |
---|---|
Body | The new Body. |
Examples
Create Solid Cone.
Project.UndoContext.BeginUndoStep("BodyCreateSolids");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyCreateSolidsStep1
Part p = new Part();
p.Name = "My_Solid_Bodies";
station.GraphicComponents.Add(p);
#endregion
// Create a solid box.
#region BodyCreateSolidsStep2
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Vector3 size = new Vector3(0.5, 0.5, 0.5);
Body b1 = Body.CreateSolidBox(matrix_origo, size);
b1.Name = "Box";
p.Bodies.Add(b1);
#endregion
// Create a cone.
#region BodyCreateSolidsStep3
Body b2 = Body.CreateSolidCone(matrix_origo, 1.0, 1.0);
b2.Name = "Cone";
p.Bodies.Add(b2);
#endregion
// Create a cylinder.
#region BodyCreateSolidsStep4
Body b3 = Body.CreateSolidCylinder(matrix_origo, 0.5, 0.5);
b3.Name = "Cylinder";
p.Bodies.Add(b3);
#endregion
// Create a pyramid.
#region BodyCreateSolidsStep5
Body b4 = Body.CreateSolidPyramid(matrix_origo, 1.0, 1.0, 6);
b4.Name = "Pyramid";
p.Bodies.Add(b4);
#endregion
// Create a sphere.
#region BodyCreateSolidsStep6
Vector3 vector_origo = new Vector3(0.0, 0.0, 0.0);
Body b5 = Body.CreateSolidSphere(vector_origo, 0.75);
b5.Name = "Sphere";
p.Bodies.Add(b5);
#endregion
// Create a torus.
#region BodyCreateSolidsStep7
Body b6 = Body.CreateSolidTorus(matrix_origo, 1.0, 0.5);
b6.Name = "Torus";
p.Bodies.Add(b6);
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
CreateSolidCone(Matrix4, Double, Double, Double)
Creates a new Body consisting of a solid elliptical cone.
Declaration
public static Body CreateSolidCone(Matrix4 center, double radiusx, double radiusy, double height)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | center | Defines the center position and rotation of the cone. |
Double | radiusx | Defines the radius of the base ellipse in the x direction. |
Double | radiusy | Defines the radius of the base ellipse in the y direction. |
Double | height | Defines the height of the cone. |
Returns
Type | Description |
---|---|
Body | The new Body. |
CreateSolidCylinder(Matrix4, Double, Double)
Creates a new Body consisting of a solid cylinder.
Declaration
public static Body CreateSolidCylinder(Matrix4 center, double radius, double height)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | center | Defines the center position and rotation of the cylinder. |
Double | radius | Defines the radius of the cylinder. |
Double | height | Defines the height of the cylinder. |
Returns
Type | Description |
---|---|
Body | The new Body. |
Examples
Create Solid Cylinder.
Project.UndoContext.BeginUndoStep("BodyCreateSolids");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyCreateSolidsStep1
Part p = new Part();
p.Name = "My_Solid_Bodies";
station.GraphicComponents.Add(p);
#endregion
// Create a solid box.
#region BodyCreateSolidsStep2
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Vector3 size = new Vector3(0.5, 0.5, 0.5);
Body b1 = Body.CreateSolidBox(matrix_origo, size);
b1.Name = "Box";
p.Bodies.Add(b1);
#endregion
// Create a cone.
#region BodyCreateSolidsStep3
Body b2 = Body.CreateSolidCone(matrix_origo, 1.0, 1.0);
b2.Name = "Cone";
p.Bodies.Add(b2);
#endregion
// Create a cylinder.
#region BodyCreateSolidsStep4
Body b3 = Body.CreateSolidCylinder(matrix_origo, 0.5, 0.5);
b3.Name = "Cylinder";
p.Bodies.Add(b3);
#endregion
// Create a pyramid.
#region BodyCreateSolidsStep5
Body b4 = Body.CreateSolidPyramid(matrix_origo, 1.0, 1.0, 6);
b4.Name = "Pyramid";
p.Bodies.Add(b4);
#endregion
// Create a sphere.
#region BodyCreateSolidsStep6
Vector3 vector_origo = new Vector3(0.0, 0.0, 0.0);
Body b5 = Body.CreateSolidSphere(vector_origo, 0.75);
b5.Name = "Sphere";
p.Bodies.Add(b5);
#endregion
// Create a torus.
#region BodyCreateSolidsStep7
Body b6 = Body.CreateSolidTorus(matrix_origo, 1.0, 0.5);
b6.Name = "Torus";
p.Bodies.Add(b6);
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
CreateSolidCylinder(Matrix4, Double, Double, Double)
Creates a new Body consisting of a solid elliptical cylinder.
Declaration
public static Body CreateSolidCylinder(Matrix4 center, double radiusx, double radiusy, double height)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | center | Defines the center position and rotation of the cylinder. |
Double | radiusx | Defines the radius of the cylinder in the x direction. |
Double | radiusy | Defines the radius of the cylinder in the y direction. |
Double | height | Defines the height of the cylinder. |
Returns
Type | Description |
---|---|
Body | The new Body. |
CreateSolidPyramid(Matrix4, Double, Double, Int32)
Creates a new Body consisting of a solid pyramid.
Declaration
public static Body CreateSolidPyramid(Matrix4 center, double radius, double height, int numberSides)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | center | Defines the center position and rotation of the pyramid. |
Double | radius | Defines the distance from center point to the corners of the base of the pyramid. |
Double | height | Defines the height of the pyramid. |
Int32 | numberSides | Defines the number of sides of the pyramid. |
Returns
Type | Description |
---|---|
Body | The new Body. |
Examples
Create Solid Pyramid.
Project.UndoContext.BeginUndoStep("BodyCreateSolids");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyCreateSolidsStep1
Part p = new Part();
p.Name = "My_Solid_Bodies";
station.GraphicComponents.Add(p);
#endregion
// Create a solid box.
#region BodyCreateSolidsStep2
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Vector3 size = new Vector3(0.5, 0.5, 0.5);
Body b1 = Body.CreateSolidBox(matrix_origo, size);
b1.Name = "Box";
p.Bodies.Add(b1);
#endregion
// Create a cone.
#region BodyCreateSolidsStep3
Body b2 = Body.CreateSolidCone(matrix_origo, 1.0, 1.0);
b2.Name = "Cone";
p.Bodies.Add(b2);
#endregion
// Create a cylinder.
#region BodyCreateSolidsStep4
Body b3 = Body.CreateSolidCylinder(matrix_origo, 0.5, 0.5);
b3.Name = "Cylinder";
p.Bodies.Add(b3);
#endregion
// Create a pyramid.
#region BodyCreateSolidsStep5
Body b4 = Body.CreateSolidPyramid(matrix_origo, 1.0, 1.0, 6);
b4.Name = "Pyramid";
p.Bodies.Add(b4);
#endregion
// Create a sphere.
#region BodyCreateSolidsStep6
Vector3 vector_origo = new Vector3(0.0, 0.0, 0.0);
Body b5 = Body.CreateSolidSphere(vector_origo, 0.75);
b5.Name = "Sphere";
p.Bodies.Add(b5);
#endregion
// Create a torus.
#region BodyCreateSolidsStep7
Body b6 = Body.CreateSolidTorus(matrix_origo, 1.0, 0.5);
b6.Name = "Torus";
p.Bodies.Add(b6);
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
CreateSolidSphere(Vector3, Double)
Creates a new Body consisting of a solid sphere.
Declaration
public static Body CreateSolidSphere(Vector3 center, double radius)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | center | Defines the center position of the sphere. |
Double | radius | Defines the radius of the sphere. |
Returns
Type | Description |
---|---|
Body | The new Body. |
Examples
Create Solid Sphere.
Project.UndoContext.BeginUndoStep("BodyCreateSolids");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyCreateSolidsStep1
Part p = new Part();
p.Name = "My_Solid_Bodies";
station.GraphicComponents.Add(p);
#endregion
// Create a solid box.
#region BodyCreateSolidsStep2
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Vector3 size = new Vector3(0.5, 0.5, 0.5);
Body b1 = Body.CreateSolidBox(matrix_origo, size);
b1.Name = "Box";
p.Bodies.Add(b1);
#endregion
// Create a cone.
#region BodyCreateSolidsStep3
Body b2 = Body.CreateSolidCone(matrix_origo, 1.0, 1.0);
b2.Name = "Cone";
p.Bodies.Add(b2);
#endregion
// Create a cylinder.
#region BodyCreateSolidsStep4
Body b3 = Body.CreateSolidCylinder(matrix_origo, 0.5, 0.5);
b3.Name = "Cylinder";
p.Bodies.Add(b3);
#endregion
// Create a pyramid.
#region BodyCreateSolidsStep5
Body b4 = Body.CreateSolidPyramid(matrix_origo, 1.0, 1.0, 6);
b4.Name = "Pyramid";
p.Bodies.Add(b4);
#endregion
// Create a sphere.
#region BodyCreateSolidsStep6
Vector3 vector_origo = new Vector3(0.0, 0.0, 0.0);
Body b5 = Body.CreateSolidSphere(vector_origo, 0.75);
b5.Name = "Sphere";
p.Bodies.Add(b5);
#endregion
// Create a torus.
#region BodyCreateSolidsStep7
Body b6 = Body.CreateSolidTorus(matrix_origo, 1.0, 0.5);
b6.Name = "Torus";
p.Bodies.Add(b6);
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
CreateSolidTorus(Matrix4, Double, Double)
Creates a new Body consisting of a solid torus.
Declaration
public static Body CreateSolidTorus(Matrix4 center, double majorRadius, double minorRadius)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | center | Defines the center position and rotation of the torus. |
Double | majorRadius | Defines the major radius of the torus. |
Double | minorRadius | Defines the minor radius of the torus. |
Returns
Type | Description |
---|---|
Body | The new Body. |
Examples
Create Solid Torus.
Project.UndoContext.BeginUndoStep("BodyCreateSolids");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyCreateSolidsStep1
Part p = new Part();
p.Name = "My_Solid_Bodies";
station.GraphicComponents.Add(p);
#endregion
// Create a solid box.
#region BodyCreateSolidsStep2
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Vector3 size = new Vector3(0.5, 0.5, 0.5);
Body b1 = Body.CreateSolidBox(matrix_origo, size);
b1.Name = "Box";
p.Bodies.Add(b1);
#endregion
// Create a cone.
#region BodyCreateSolidsStep3
Body b2 = Body.CreateSolidCone(matrix_origo, 1.0, 1.0);
b2.Name = "Cone";
p.Bodies.Add(b2);
#endregion
// Create a cylinder.
#region BodyCreateSolidsStep4
Body b3 = Body.CreateSolidCylinder(matrix_origo, 0.5, 0.5);
b3.Name = "Cylinder";
p.Bodies.Add(b3);
#endregion
// Create a pyramid.
#region BodyCreateSolidsStep5
Body b4 = Body.CreateSolidPyramid(matrix_origo, 1.0, 1.0, 6);
b4.Name = "Pyramid";
p.Bodies.Add(b4);
#endregion
// Create a sphere.
#region BodyCreateSolidsStep6
Vector3 vector_origo = new Vector3(0.0, 0.0, 0.0);
Body b5 = Body.CreateSolidSphere(vector_origo, 0.75);
b5.Name = "Sphere";
p.Bodies.Add(b5);
#endregion
// Create a torus.
#region BodyCreateSolidsStep7
Body b6 = Body.CreateSolidTorus(matrix_origo, 1.0, 0.5);
b6.Name = "Torus";
p.Bodies.Add(b6);
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
CreateSpline(Vector3[], Double)
Creates a new Body consisting of one single spline wire.
Declaration
public static Body CreateSpline(Vector3[] vertices, double tolerance)
Parameters
Type | Name | Description |
---|---|---|
Vector3[] | vertices | Defines the vertices/positions used to create the spline. |
Double | tolerance | Defines the tolerance used to shape the spline at each vertice. |
Returns
Type | Description |
---|---|
Body | The new Body. |
Examples
Create Spline.
Project.UndoContext.BeginUndoStep("BodyCreateCurves");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyCreateCurvesStep1
Part p = new Part();
p.Name = "My_Curves";
station.GraphicComponents.Add(p);
#endregion
// Create an arc.
#region BodyCreateCurvesStep2
Vector3 start = new Vector3(0.0, 0.0, 0.0);
Vector3 end = new Vector3(0.5, 0.5, 0.5);
Vector3 via = new Vector3(0.25, 0.25, 0.0);
Body b1 = Body.CreateArc(start, end, via);
b1.Name = "Arc";
p.Bodies.Add(b1);
#endregion
// Create a circle.
#region BodyCreateCurvesStep3
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Body b2 = Body.CreateCircle(matrix_origo, 0.5);
b2.Name = "Circle";
p.Bodies.Add(b2);
#endregion
// Create an ellipse.
#region BodyCreateCurvesStep4
Vector3 vector_origo = new Vector3(0.0, 0.0, 0.0);
Body b3 = Body.CreateEllipse(vector_origo, end, 0.25);
b3.Name = "Ellipse";
p.Bodies.Add(b3);
#endregion
// Create an elliptic arc.
#region BodyCreateCurvesStep5
Body b4 = Body.CreateEllipticArc(vector_origo, end, via, 0.3, 1.1);
b4.Name = "Elliptic arc";
p.Bodies.Add(b4);
#endregion
// Create a line.
#region BodyCreateCurvesStep6
Body b5 = Body.CreateLine(start, end);
b5.Name = "Line";
p.Bodies.Add(b5);
#endregion
// Create a polygon.
#region BodyCreateCurvesStep7
Body b6 = Body.CreatePolygon(vector_origo, via, 8);
b6.Name = "Polygon";
p.Bodies.Add(b6);
#endregion
// Create a polyline.
#region BodyCreateCurvesStep8
Vector3[] vertices = new Vector3[3] { start, via, end };
Body b7 = Body.CreatePolyLine(vertices);
b7.Name = "Polyline";
p.Bodies.Add(b7);
#endregion
// Create a reactangle.
#region BodyCreateCurvesStep9
Body b8 = Body.CreateRectangle(matrix_origo, 0.7, 0.3);
b8.Name = "Reactangle";
p.Bodies.Add(b8);
#endregion
// Create a spline.
#region BodyCreateCurvesStep10
Body b9 = Body.CreateSpline(vertices, 0.2);
b9.Name = "Spline";
p.Bodies.Add(b9);
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
CreateSpline(Vector3[], Double, Boolean)
Creates a new Body consisting of one single spline wire.
Declaration
public static Body CreateSpline(Vector3[] vertices, double tolerance, bool periodic)
Parameters
Type | Name | Description |
---|---|---|
Vector3[] | vertices | Defines the vertices/positions used to create the spline. |
Double | tolerance | Defines the tolerance used to shape the spline at each vertice. |
Boolean | periodic | Create a periodic spline if the start and end vertices coincide. |
Returns
Type | Description |
---|---|
Body | The new Body. |
Examples
Create Spline.
Project.UndoContext.BeginUndoStep("BodyCreateCurves");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyCreateCurvesStep1
Part p = new Part();
p.Name = "My_Curves";
station.GraphicComponents.Add(p);
#endregion
// Create an arc.
#region BodyCreateCurvesStep2
Vector3 start = new Vector3(0.0, 0.0, 0.0);
Vector3 end = new Vector3(0.5, 0.5, 0.5);
Vector3 via = new Vector3(0.25, 0.25, 0.0);
Body b1 = Body.CreateArc(start, end, via);
b1.Name = "Arc";
p.Bodies.Add(b1);
#endregion
// Create a circle.
#region BodyCreateCurvesStep3
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Body b2 = Body.CreateCircle(matrix_origo, 0.5);
b2.Name = "Circle";
p.Bodies.Add(b2);
#endregion
// Create an ellipse.
#region BodyCreateCurvesStep4
Vector3 vector_origo = new Vector3(0.0, 0.0, 0.0);
Body b3 = Body.CreateEllipse(vector_origo, end, 0.25);
b3.Name = "Ellipse";
p.Bodies.Add(b3);
#endregion
// Create an elliptic arc.
#region BodyCreateCurvesStep5
Body b4 = Body.CreateEllipticArc(vector_origo, end, via, 0.3, 1.1);
b4.Name = "Elliptic arc";
p.Bodies.Add(b4);
#endregion
// Create a line.
#region BodyCreateCurvesStep6
Body b5 = Body.CreateLine(start, end);
b5.Name = "Line";
p.Bodies.Add(b5);
#endregion
// Create a polygon.
#region BodyCreateCurvesStep7
Body b6 = Body.CreatePolygon(vector_origo, via, 8);
b6.Name = "Polygon";
p.Bodies.Add(b6);
#endregion
// Create a polyline.
#region BodyCreateCurvesStep8
Vector3[] vertices = new Vector3[3] { start, via, end };
Body b7 = Body.CreatePolyLine(vertices);
b7.Name = "Polyline";
p.Bodies.Add(b7);
#endregion
// Create a reactangle.
#region BodyCreateCurvesStep9
Body b8 = Body.CreateRectangle(matrix_origo, 0.7, 0.3);
b8.Name = "Reactangle";
p.Bodies.Add(b8);
#endregion
// Create a spline.
#region BodyCreateCurvesStep10
Body b9 = Body.CreateSpline(vertices, 0.2);
b9.Name = "Spline";
p.Bodies.Add(b9);
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
CreateSplineFenceFromRays(IEnumerable<Ray>, Body, Double)
Creates a sheet body shaped as a spline fence where the rays forms the fence posts.
Declaration
public static Body CreateSplineFenceFromRays(IEnumerable<Ray> rays, Body target, double fenceHeight)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Ray> | rays | |
Body | target | |
Double | fenceHeight |
Returns
Type | Description |
---|---|
Body |
CreateSurfaceCircle(Matrix4, Double)
Creates a new Body consisting of a surface circle.
Declaration
public static Body CreateSurfaceCircle(Matrix4 center, double radius)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | center | Defines the center position and rotation of the circle. |
Double | radius | Defines the radius of the circle. |
Returns
Type | Description |
---|---|
Body | The new Body. |
Examples
Create Surface Circle.
Project.UndoContext.BeginUndoStep("BodyCreateSurfaces");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyCreateSurfacesStep1
Part p = new Part();
p.Name = "My_Surfaces";
station.GraphicComponents.Add(p);
#endregion
// Create a surface circle.
#region BodyCreateSurfacesStep2
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Body b1 = Body.CreateSurfaceCircle(matrix_origo, 0.5);
b1.Name = "Surface circle";
p.Bodies.Add(b1);
#endregion
// Create surface from curve.
// Create a curve, that must be closed.
#region BodyCreateSurfacesStep3
Vector3 v1 = new Vector3(0.0, 0.0, 0.0);
Vector3 v2 = new Vector3(0.5, 0.5, 0.0);
Vector3 v3 = new Vector3(0.2, -0.2, 0.0);
Vector3 v4 = new Vector3(-0.2, -0.3, 0.0);
Vector3 v5 = new Vector3(-0.3, 0.2, 0.0);
Vector3[] vertices = new Vector3[6] { v1, v2, v3, v4, v5, v1 };
Body spline = Body.CreateSpline(vertices, 0.0);
spline.Name = "Spline";
p.Bodies.Add(spline);
#endregion
#region BodyCreateSurfacesStep4
Body b2 = Body.CreateSurfaceFromCurve(spline.Shells[0].Wires[0]);
b2.Name = "Curve surface";
p.Bodies.Add(b2);
#endregion
// Create a surface polygon.
#region BodyCreateSurfacesStep5
Vector3 vector_origo = new Vector3(0.0, 0.0, 0.0);
Body b3 = Body.CreateSurfacePolygon(vector_origo, new Vector3(0.5, 0.5, 0.5), 8);
b3.Name = "Surface Polygon";
p.Bodies.Add(b3);
#endregion
// Create a surface rectangle.
#region BodyCreateSurfacesStep6
Body b4 = Body.CreateSurfaceRectangle(matrix_origo, 0.2, 0.5);
b4.Name = "Surface Rectangle";
p.Bodies.Add(b4);
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
CreateSurfaceFromCurve(Wire)
Creates a new Body consisting of a surface defined by the curve.
Declaration
public static Body CreateSurfaceFromCurve(Wire wire)
Parameters
Type | Name | Description |
---|---|---|
Wire | wire | Defines the circumference of the surface |
Returns
Type | Description |
---|---|
Body | The new Body. |
Remarks
The wire supplied must be closed, i.e. the start and end point must coincide.
Examples
Create Surface from Curve.
Project.UndoContext.BeginUndoStep("BodyCreateSurfaces");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyCreateSurfacesStep1
Part p = new Part();
p.Name = "My_Surfaces";
station.GraphicComponents.Add(p);
#endregion
// Create a surface circle.
#region BodyCreateSurfacesStep2
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Body b1 = Body.CreateSurfaceCircle(matrix_origo, 0.5);
b1.Name = "Surface circle";
p.Bodies.Add(b1);
#endregion
// Create surface from curve.
// Create a curve, that must be closed.
#region BodyCreateSurfacesStep3
Vector3 v1 = new Vector3(0.0, 0.0, 0.0);
Vector3 v2 = new Vector3(0.5, 0.5, 0.0);
Vector3 v3 = new Vector3(0.2, -0.2, 0.0);
Vector3 v4 = new Vector3(-0.2, -0.3, 0.0);
Vector3 v5 = new Vector3(-0.3, 0.2, 0.0);
Vector3[] vertices = new Vector3[6] { v1, v2, v3, v4, v5, v1 };
Body spline = Body.CreateSpline(vertices, 0.0);
spline.Name = "Spline";
p.Bodies.Add(spline);
#endregion
#region BodyCreateSurfacesStep4
Body b2 = Body.CreateSurfaceFromCurve(spline.Shells[0].Wires[0]);
b2.Name = "Curve surface";
p.Bodies.Add(b2);
#endregion
// Create a surface polygon.
#region BodyCreateSurfacesStep5
Vector3 vector_origo = new Vector3(0.0, 0.0, 0.0);
Body b3 = Body.CreateSurfacePolygon(vector_origo, new Vector3(0.5, 0.5, 0.5), 8);
b3.Name = "Surface Polygon";
p.Bodies.Add(b3);
#endregion
// Create a surface rectangle.
#region BodyCreateSurfacesStep6
Body b4 = Body.CreateSurfaceRectangle(matrix_origo, 0.2, 0.5);
b4.Name = "Surface Rectangle";
p.Bodies.Add(b4);
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
CreateSurfacePolygon(Vector3, Vector3, Int32)
Creates a new Body consisting of a surface polygon.
Declaration
public static Body CreateSurfacePolygon(Vector3 start, Vector3 vertex, int numberEdges)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | start | Defines the center position on the polygon. |
Vector3 | vertex | Defines a corner vertex of the polygon, used to calculate the distance between center poit and the vertices of the polygon. |
Int32 | numberEdges | Defines the number of edges of the polygon. |
Returns
Type | Description |
---|---|
Body | The new Body. |
Examples
Create Surface Polygon.
Project.UndoContext.BeginUndoStep("BodyCreateSurfaces");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyCreateSurfacesStep1
Part p = new Part();
p.Name = "My_Surfaces";
station.GraphicComponents.Add(p);
#endregion
// Create a surface circle.
#region BodyCreateSurfacesStep2
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Body b1 = Body.CreateSurfaceCircle(matrix_origo, 0.5);
b1.Name = "Surface circle";
p.Bodies.Add(b1);
#endregion
// Create surface from curve.
// Create a curve, that must be closed.
#region BodyCreateSurfacesStep3
Vector3 v1 = new Vector3(0.0, 0.0, 0.0);
Vector3 v2 = new Vector3(0.5, 0.5, 0.0);
Vector3 v3 = new Vector3(0.2, -0.2, 0.0);
Vector3 v4 = new Vector3(-0.2, -0.3, 0.0);
Vector3 v5 = new Vector3(-0.3, 0.2, 0.0);
Vector3[] vertices = new Vector3[6] { v1, v2, v3, v4, v5, v1 };
Body spline = Body.CreateSpline(vertices, 0.0);
spline.Name = "Spline";
p.Bodies.Add(spline);
#endregion
#region BodyCreateSurfacesStep4
Body b2 = Body.CreateSurfaceFromCurve(spline.Shells[0].Wires[0]);
b2.Name = "Curve surface";
p.Bodies.Add(b2);
#endregion
// Create a surface polygon.
#region BodyCreateSurfacesStep5
Vector3 vector_origo = new Vector3(0.0, 0.0, 0.0);
Body b3 = Body.CreateSurfacePolygon(vector_origo, new Vector3(0.5, 0.5, 0.5), 8);
b3.Name = "Surface Polygon";
p.Bodies.Add(b3);
#endregion
// Create a surface rectangle.
#region BodyCreateSurfacesStep6
Body b4 = Body.CreateSurfaceRectangle(matrix_origo, 0.2, 0.5);
b4.Name = "Surface Rectangle";
p.Bodies.Add(b4);
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
CreateSurfacePolygon(Vector3[])
Creates a new Body consisting of a surface polygon defined by a cirquit of vertices.
Declaration
public static Body CreateSurfacePolygon(Vector3[] outerLoop)
Parameters
Type | Name | Description |
---|---|---|
Vector3[] | outerLoop | The vertices that define the outer edge of the polygon. |
Returns
Type | Description |
---|---|
Body | The new Body. |
Remarks
The loop must be planar, but doesn't have to be closed (a closing vertex is added automatically).
CreateSurfacePolygonWithHoles(Vector3[], Vector3[][])
Creates a new Body consisting of a surface polygon defined by outer and inner vertices.
Declaration
public static Body CreateSurfacePolygonWithHoles(Vector3[] outerLoop, Vector3[][] innerLoops)
Parameters
Type | Name | Description |
---|---|---|
Vector3[] | outerLoop | The vertices that define the outer edge of the polygon. |
Vector3[][] | innerLoops | Arrays of vertices that define edges of holes in the polygon. |
Returns
Type | Description |
---|---|
Body | The new Body. |
Remarks
All loops must be coplanar, but they don't have to be closed (a closing vertex is added automatically).
CreateSurfaceRectangle(Matrix4, Double, Double)
Creates a new Body consisting of a rectangle polygon.
Declaration
public static Body CreateSurfaceRectangle(Matrix4 corner, double length, double width)
Parameters
Type | Name | Description |
---|---|---|
Matrix4 | corner | Defines the corner position and rotation of the rectangle. |
Double | length | Defines the length of the rectangle. |
Double | width | Defines the width of the rectangle. |
Returns
Type | Description |
---|---|
Body | The new Body. |
Examples
Create Suface Rectangle.
Project.UndoContext.BeginUndoStep("BodyCreateSurfaces");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyCreateSurfacesStep1
Part p = new Part();
p.Name = "My_Surfaces";
station.GraphicComponents.Add(p);
#endregion
// Create a surface circle.
#region BodyCreateSurfacesStep2
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Body b1 = Body.CreateSurfaceCircle(matrix_origo, 0.5);
b1.Name = "Surface circle";
p.Bodies.Add(b1);
#endregion
// Create surface from curve.
// Create a curve, that must be closed.
#region BodyCreateSurfacesStep3
Vector3 v1 = new Vector3(0.0, 0.0, 0.0);
Vector3 v2 = new Vector3(0.5, 0.5, 0.0);
Vector3 v3 = new Vector3(0.2, -0.2, 0.0);
Vector3 v4 = new Vector3(-0.2, -0.3, 0.0);
Vector3 v5 = new Vector3(-0.3, 0.2, 0.0);
Vector3[] vertices = new Vector3[6] { v1, v2, v3, v4, v5, v1 };
Body spline = Body.CreateSpline(vertices, 0.0);
spline.Name = "Spline";
p.Bodies.Add(spline);
#endregion
#region BodyCreateSurfacesStep4
Body b2 = Body.CreateSurfaceFromCurve(spline.Shells[0].Wires[0]);
b2.Name = "Curve surface";
p.Bodies.Add(b2);
#endregion
// Create a surface polygon.
#region BodyCreateSurfacesStep5
Vector3 vector_origo = new Vector3(0.0, 0.0, 0.0);
Body b3 = Body.CreateSurfacePolygon(vector_origo, new Vector3(0.5, 0.5, 0.5), 8);
b3.Name = "Surface Polygon";
p.Bodies.Add(b3);
#endregion
// Create a surface rectangle.
#region BodyCreateSurfacesStep6
Body b4 = Body.CreateSurfaceRectangle(matrix_origo, 0.2, 0.5);
b4.Name = "Surface Rectangle";
p.Bodies.Add(b4);
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
CreateWireFromEdges(Edge[])
ABB internal use only
Declaration
public static Body CreateWireFromEdges(Edge[] edges)
Parameters
Type | Name | Description |
---|---|---|
Edge[] | edges |
Returns
Type | Description |
---|---|
Body |
CreateWireSlicesAlongWire(IEnumerable<Face>, Body, Double)
Slices the input faces along the given Wire (using the planes defined by the Wire direction) and generates a Body containing the resulting intersection Wires.
Declaration
public static Body CreateWireSlicesAlongWire(IEnumerable<Face> faces, Body wire, double distance)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Face> | faces | The faces to slice. Should form a contiguous surface. |
Body | wire | A Wire that is used to compute the slicing planes |
Double | distance | Distance between slicing planes |
Returns
Type | Description |
---|---|
Body |
Cut(Body)
Declaration
olete("This method cuts this body from the specified body instead of the opposite way around, which is expected. Please use Cut2 instead.")]
public Body[] Cut(Body body)
Parameters
Type | Name | Description |
---|---|---|
Body | body |
Returns
Type | Description |
---|---|
Body[] |
Cut2(Body)
Creates an array of new Body(s) consisting of the cut of this body with the one provided.
Declaration
public Body[] Cut2(Body body)
Parameters
Type | Name | Description |
---|---|---|
Body | body | The body to cut this body with. |
Returns
Type | Description |
---|---|
Body[] | The array of new Body(s) |
Examples
Cut Body.
Project.UndoContext.BeginUndoStep("BodyBooleanOperations");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyBooleanOperationsStep1
Part p = new Part();
p.Name = "My_Part";
station.GraphicComponents.Add(p);
#endregion
// Create a solid box.
#region BodyBooleanOperationsStep2
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Vector3 size = new Vector3(0.5, 0.5, 0.5);
Body box = Body.CreateSolidBox(matrix_origo, size);
box.Name = "Box";
p.Bodies.Add(box);
#endregion
// Create a cone.
#region BodyBooleanOperationsStep3
Body cone = Body.CreateSolidCone(matrix_origo, 1.0, 1.0);
cone.Name = "Cone";
p.Bodies.Add(cone);
#endregion
// Create the intersection between the box and the cone.
#region BodyBooleanOperationsStep4
Body[] intersection = box.Intersect(cone);
foreach (Body b in intersection)
{
b.Name = "Intersection Body";
p.Bodies.Add(b);
}
#endregion
//Cut the cone with the box
#region BodyBooleanOperationsStep5
Body[] cut = cone.Cut2(box);
foreach (Body b in cut)
{
b.Name = "Cut Body";
p.Bodies.Add(b);
}
#endregion
// Join the box and the cone.
#region BodyBooleanOperationsStep6
Body[] union = box.Join(cone);
foreach (Body b in union)
{
b.Name = "Join Body";
p.Bodies.Add(b);
}
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Defeature(Double, Double, Double, ProgressNotification)
Removes features (holes, chamfers and blends).
Declaration
public Body Defeature(double blendRadius, double chamferWidth, double holeDiameter, ProgressNotification progressDelegate)
Parameters
Type | Name | Description |
---|---|---|
Double | blendRadius | The maximum radius of blends to remove, or zero to disable. |
Double | chamferWidth | The maximum width of chamfers to remove, or zero to disable. |
Double | holeDiameter | The maximum diameter of holes to remove, or zero to disable. |
ProgressNotification | progressDelegate | Progress notification callback (can be null). |
Returns
Type | Description |
---|---|
Body | The new defeatured body. |
Extrude(Face, Vector3, Wire, SweepOptions)
Declaration
public static Body[] Extrude(Face face, Vector3 projection, Wire alongWire, SweepOptions sweepOptions)
Parameters
Type | Name | Description |
---|---|---|
Face | face | The Face object that shall be extruded. |
Vector3 | projection | The direction and length of the projection. |
Wire | alongWire | If not null, the Extrude operation will follow the specified wire instead of the projection vector |
SweepOptions | sweepOptions | Sweep options for this operation. |
Returns
Type | Description |
---|---|
Body[] | The array of new Bodys. |
Examples
Extrude Body.
Project.UndoContext.BeginUndoStep("BodyExtrude");
try
{
Station station = Station.ActiveStation;
// Create a part.
#region BodyExtrudeStep1
Part p = new Part();
p.Name = "My_Extruded_Bodies";
station.GraphicComponents.Add(p);
#endregion
// Create a solid box and add it to My_Part1.
#region BodyExtrudeStep2
Body b = Body.CreateSolidBox(new Matrix4
(new Vector3(0.0, 0.0, 0.0)), new Vector3(0.5, 0.5, 0.5));
b.Name = "Box";
p.Bodies.Add(b);
#endregion
// Create face.
#region BodyExtrudeStep3
Face f = b.Shells[0].Faces[0];
#endregion
// Create a wire.
#region BodyExtrudeStep4
Body wirebody = Body.CreateLine
(new Vector3(0.0, 0.0, 0.0), new Vector3(1.0, 1.0, 1.0));
wirebody.Name = "Wirebody";
p.Bodies.Add(wirebody);
Wire w = wirebody.Shells[0].Wires[0];
#endregion
// Set the sweep option to solid.
#region BodyExtrudeStep5
SweepOptions so = new SweepOptions();
so.MakeSolid = true;
#endregion
#region BodyExtrudeStep6
Vector3 vec = new Vector3(1.0, 1.0, 1.0);
#endregion
// Extrude face along wire.
#region BodyExtrudeStep7
Body[] bds = Body.Extrude(f, vec, w, so);
foreach (Body bd in bds)
{
bd.Name = "Face extruded along wire";
p.Bodies.Add(bd);
}
#endregion
// Create a second wire.
#region BodyExtrudeStep8
Body wirebody2 = Body.CreateLine
(new Vector3(0.0, 0.0, 0.0), new Vector3(1.0, 1.0, -1.0));
wirebody2.Name = "Wirebody 2";
p.Bodies.Add(wirebody2);
Wire w2 = wirebody2.Shells[0].Wires[0];
#endregion
// Extrude the first wire along the second.
#region BodyExtrudeStep9
Body[] bds2 = Body.Extrude(w, vec, w2, so);
foreach (Body bd in bds2)
{
bd.Name = "Wire extruded along wire";
p.Bodies.Add(bd);
}
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Exceptions
Type | Condition |
---|---|
ArgumentException | |
ArgumentNullException | |
IOException |
Extrude(Wire, Vector3, Wire, SweepOptions)
Declaration
public static Body[] Extrude(Wire wire, Vector3 projection, Wire alongWire, SweepOptions sweepOptions)
Parameters
Type | Name | Description |
---|---|---|
Wire | wire | The Wire object that shall be extruded. |
Vector3 | projection | The direction and length of the projection. |
Wire | alongWire | If not null, the Extrude operation will follow the specified wire instead of the projection vector. |
SweepOptions | sweepOptions | Sweep options for this operation. |
Returns
Type | Description |
---|---|
Body[] | The array of new Bodys. |
Examples
Extrude Body.
Project.UndoContext.BeginUndoStep("BodyExtrude");
try
{
Station station = Station.ActiveStation;
// Create a part.
#region BodyExtrudeStep1
Part p = new Part();
p.Name = "My_Extruded_Bodies";
station.GraphicComponents.Add(p);
#endregion
// Create a solid box and add it to My_Part1.
#region BodyExtrudeStep2
Body b = Body.CreateSolidBox(new Matrix4
(new Vector3(0.0, 0.0, 0.0)), new Vector3(0.5, 0.5, 0.5));
b.Name = "Box";
p.Bodies.Add(b);
#endregion
// Create face.
#region BodyExtrudeStep3
Face f = b.Shells[0].Faces[0];
#endregion
// Create a wire.
#region BodyExtrudeStep4
Body wirebody = Body.CreateLine
(new Vector3(0.0, 0.0, 0.0), new Vector3(1.0, 1.0, 1.0));
wirebody.Name = "Wirebody";
p.Bodies.Add(wirebody);
Wire w = wirebody.Shells[0].Wires[0];
#endregion
// Set the sweep option to solid.
#region BodyExtrudeStep5
SweepOptions so = new SweepOptions();
so.MakeSolid = true;
#endregion
#region BodyExtrudeStep6
Vector3 vec = new Vector3(1.0, 1.0, 1.0);
#endregion
// Extrude face along wire.
#region BodyExtrudeStep7
Body[] bds = Body.Extrude(f, vec, w, so);
foreach (Body bd in bds)
{
bd.Name = "Face extruded along wire";
p.Bodies.Add(bd);
}
#endregion
// Create a second wire.
#region BodyExtrudeStep8
Body wirebody2 = Body.CreateLine
(new Vector3(0.0, 0.0, 0.0), new Vector3(1.0, 1.0, -1.0));
wirebody2.Name = "Wirebody 2";
p.Bodies.Add(wirebody2);
Wire w2 = wirebody2.Shells[0].Wires[0];
#endregion
// Extrude the first wire along the second.
#region BodyExtrudeStep9
Body[] bds2 = Body.Extrude(w, vec, w2, so);
foreach (Body bd in bds2)
{
bd.Name = "Wire extruded along wire";
p.Bodies.Add(bd);
}
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Exceptions
Type | Condition |
---|---|
ArgumentException | |
ArgumentNullException | |
IOException |
FindClosestVertex(Vector3)
Declaration
public Vertex FindClosestVertex(Vector3 testPoint)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | testPoint | The point which to find the closest vertex to. |
Returns
Type | Description |
---|---|
Vertex | The closest Vertex. |
Examples
Find closest Vertex.
Project.UndoContext.BeginUndoStep("BodyMethods");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
Part p = new Part();
p.Name = "My_Part";
station.GraphicComponents.Add(p);
// Create a solid box.
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Vector3 size = new Vector3(0.5, 0.5, 0.5);
Body box = Body.CreateSolidBox(matrix_origo, size);
box.Name = "Box";
p.Bodies.Add(box);
// Create two points.
Vector3 point1 = new Vector3(0.1, 0.1, 0.1);
Vector3 point2 = new Vector3(0.6, 0.6, 0.6);
// Test if the points are inside the box.
Logger.AddMessage(new LogMessage("Point one " + point1.ToString() + " is inside the box: " + box.IsPointInside(point1).ToString()));
Logger.AddMessage(new LogMessage("Point two " + point2.ToString() + " is inside the box: " + box.IsPointInside(point2).ToString()));
// Find the vertex closest to point2.
Vertex closestVert = box.FindClosestVertex(point2);
Logger.AddMessage(new LogMessage("The closest vertex to point2 is : (" + closestVert.Position.x.ToString() +
", " + closestVert.Position.y.ToString() +
", " + closestVert.Position.z.ToString() + ")"));
// Copy the box.
Body boxcopy = (Body)box.Copy();
boxcopy.Name = "Copy of " + box.Name;
p.Bodies.Add(boxcopy);
// Remove the original box body.
p.Bodies.Remove(box);
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
FindFeatures(Double, Double, Double, ProgressNotification)
Finds features (holes, chamfers and blends) that satisfy specified conditions.
Declaration
public Face[] FindFeatures(double blendRadius, double chamferWidth, double holeDiameter, ProgressNotification progressDelegate)
Parameters
Type | Name | Description |
---|---|---|
Double | blendRadius | The maximum radius of blends, or zero to disable. |
Double | chamferWidth | The maximum width of chamfers, or zero to disable. |
Double | holeDiameter | The maximum diameter of holes, or zero to disable. |
ProgressNotification | progressDelegate | Progress notification callback (can be null). |
Returns
Type | Description |
---|---|
Face[] | The array of found features |
GetMaterial()
Gets the Material of the graphical representation of the body.
Declaration
public Material GetMaterial()
Returns
Type | Description |
---|---|
Material |
Heal(Body)
Heals the Body (performs all phases of the healing process) using intelligently selected tolerances.
Declaration
public static Body Heal(Body body)
Parameters
Type | Name | Description |
---|---|---|
Body | body | The Body to be healed. |
Returns
Type | Description |
---|---|
Body | The new healed Body |
Intersect(Body)
Creates an array of new Body(s) consisting of intersection of this body and the the one provided.
Declaration
public Body[] Intersect(Body body)
Parameters
Type | Name | Description |
---|---|---|
Body | body | The body to intersect this body with. |
Returns
Type | Description |
---|---|
Body[] | The array of new Body(s). |
Examples
Intersect Body.
Project.UndoContext.BeginUndoStep("BodyBooleanOperations");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyBooleanOperationsStep1
Part p = new Part();
p.Name = "My_Part";
station.GraphicComponents.Add(p);
#endregion
// Create a solid box.
#region BodyBooleanOperationsStep2
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Vector3 size = new Vector3(0.5, 0.5, 0.5);
Body box = Body.CreateSolidBox(matrix_origo, size);
box.Name = "Box";
p.Bodies.Add(box);
#endregion
// Create a cone.
#region BodyBooleanOperationsStep3
Body cone = Body.CreateSolidCone(matrix_origo, 1.0, 1.0);
cone.Name = "Cone";
p.Bodies.Add(cone);
#endregion
// Create the intersection between the box and the cone.
#region BodyBooleanOperationsStep4
Body[] intersection = box.Intersect(cone);
foreach (Body b in intersection)
{
b.Name = "Intersection Body";
p.Bodies.Add(b);
}
#endregion
//Cut the cone with the box
#region BodyBooleanOperationsStep5
Body[] cut = cone.Cut2(box);
foreach (Body b in cut)
{
b.Name = "Cut Body";
p.Bodies.Add(b);
}
#endregion
// Join the box and the cone.
#region BodyBooleanOperationsStep6
Body[] union = box.Join(cone);
foreach (Body b in union)
{
b.Name = "Join Body";
p.Bodies.Add(b);
}
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
IntersectWithBoundary(Body, Body)
Creates a sheet body containing copies of the faces of this body which are inside the specified boundary. For faces which are are partially inside the boundary, the copy will be trimmed to fit inside the boundary.
Declaration
public static Body IntersectWithBoundary(Body target, Body closedFenceBoundary)
Parameters
Type | Name | Description |
---|---|---|
Body | target | The target body that shall be intersected with the closed fence boundary. |
Body | closedFenceBoundary | Faces of the target body which are inside this closed sheet body will be returned. |
Returns
Type | Description |
---|---|
Body | A sheet body which is a copy of the surface of the target body which is inside the specified boundary. |
Remarks
CreatePolygonFenceFromRays(IEnumerable<Ray>, Body, Double) and CreatePolygonFenceFromRays(IEnumerable<Ray>, Body, Double) can be used to create the boundary
IsPointInside(Vector3)
Tests if a point is inside the body.
Declaration
public bool IsPointInside(Vector3 point)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | point | The point to test. |
Returns
Type | Description |
---|---|
Boolean | True if the point is inside the body, else false. |
Examples
IsPointInside.
Project.UndoContext.BeginUndoStep("BodyMethods");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
Part p = new Part();
p.Name = "My_Part";
station.GraphicComponents.Add(p);
// Create a solid box.
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Vector3 size = new Vector3(0.5, 0.5, 0.5);
Body box = Body.CreateSolidBox(matrix_origo, size);
box.Name = "Box";
p.Bodies.Add(box);
// Create two points.
Vector3 point1 = new Vector3(0.1, 0.1, 0.1);
Vector3 point2 = new Vector3(0.6, 0.6, 0.6);
// Test if the points are inside the box.
Logger.AddMessage(new LogMessage("Point one " + point1.ToString() + " is inside the box: " + box.IsPointInside(point1).ToString()));
Logger.AddMessage(new LogMessage("Point two " + point2.ToString() + " is inside the box: " + box.IsPointInside(point2).ToString()));
// Find the vertex closest to point2.
Vertex closestVert = box.FindClosestVertex(point2);
Logger.AddMessage(new LogMessage("The closest vertex to point2 is : (" + closestVert.Position.x.ToString() +
", " + closestVert.Position.y.ToString() +
", " + closestVert.Position.z.ToString() + ")"));
// Copy the box.
Body boxcopy = (Body)box.Copy();
boxcopy.Name = "Copy of " + box.Name;
p.Bodies.Add(boxcopy);
// Remove the original box body.
p.Bodies.Remove(box);
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Join(Body)
Creates an array of new Body(s) consisting of the union of this body with the one provided.
Declaration
public Body[] Join(Body body)
Parameters
Type | Name | Description |
---|---|---|
Body | body | The body to join this body with. |
Returns
Type | Description |
---|---|
Body[] | The array of new Body(s) |
Examples
Join Body.
Project.UndoContext.BeginUndoStep("BodyJoinSeparate");
try
{
Station station = Station.ActiveStation;
// Create parts and bodies.
#region BodyJoinSeparateStep1
Part p = new Part();
p.Name = "My_Surfaces";
station.GraphicComponents.Add(p);
Body b1 = Body.CreateSurfaceRectangle(Matrix4.Identity, 1, 1);
b1.Name = "Surface 1";
p.Bodies.Add(b1);
Body b2 = Body.CreateSurfaceRectangle(Matrix4.Identity, 1, 1);
b2.Name = "Surface 2";
p.Bodies.Add(b2);
Body b3 = Body.CreateSurfaceRectangle(Matrix4.Identity, 1, 1);
b3.Name = "Surface 3";
p.Bodies.Add(b3);
#endregion
// Place the bodies.
#region BodyJoinSeparateStep2
b1.Transform.X = 0;
b1.Transform.Y = 0;
b2.Transform.X = 2;
b2.Transform.Y = 0;
b3.Transform.X = 2;
b3.Transform.Y = 1;
#endregion
// Join b1 and b2.
// When the second parameter is false, only one element is created.
// This creates a new array b4, with one element, created from b1 and b2.
#region BodyJoinSeparateStep3
Body[] b4 = b1.Join(b2, false);
foreach (Body b in b4)
{
b.Name = "Surface 4: Surface 1 joined with Surface 2.";
p.Bodies.Add(b);
}
#endregion
// Join the first element in b4 with b3.
// This creates a new array b7, with one element, created from b3 and the first element in b4.
#region BodyJoinSeparateStep4
Body[] b7 = b4[0].Join(b3, false);
foreach (Body b in b7)
{
b.Name =
"Surface 5: Surface 1 joined with Surface 2 and Surface 3. Not separated.";
p.Bodies.Add(b);
}
#endregion
// Join the first element in b4 with b3.
// The elements in b5 is created from each disjunct piece in b3 and the first element in b4.
#region BodyJoinSeparateStep5
Body[] b5 = b4[0].Join(b3, true);
foreach (Body b in b5)
{
b.Name = "Surface 6: Surface 1 joined with Surface 2" +
"and Surface 3. Disjunct lumps separated.";
p.Bodies.Add(b);
}
#endregion
// Separate the first element in b7.
// Each disjunct piece in the first element in b7 creates a new element in b8.
#region BodyJoinSeparateStep6
Body[] b8 = b7[0].Separate();
foreach (Body b in b8)
{
b.Name =
"Surface 7: Disjunct lumps separated from Surface 5.";
p.Bodies.Add(b);
}
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Join(Body, Boolean)
Creates an array of new Body(s) consisting of the union of this body with the one provided.
Declaration
public Body[] Join(Body body, bool separateResultingBody)
Parameters
Type | Name | Description |
---|---|---|
Body | body | The body to join this body with. |
Boolean | separateResultingBody | If true, returns an array with one element for each disjunct piece in the joined body. If false, returns an array with one element containing the joined body. |
Returns
Type | Description |
---|---|
Body[] | The array of new Body(s) |
Examples
Join Body.
Project.UndoContext.BeginUndoStep("BodyJoinSeparate");
try
{
Station station = Station.ActiveStation;
// Create parts and bodies.
#region BodyJoinSeparateStep1
Part p = new Part();
p.Name = "My_Surfaces";
station.GraphicComponents.Add(p);
Body b1 = Body.CreateSurfaceRectangle(Matrix4.Identity, 1, 1);
b1.Name = "Surface 1";
p.Bodies.Add(b1);
Body b2 = Body.CreateSurfaceRectangle(Matrix4.Identity, 1, 1);
b2.Name = "Surface 2";
p.Bodies.Add(b2);
Body b3 = Body.CreateSurfaceRectangle(Matrix4.Identity, 1, 1);
b3.Name = "Surface 3";
p.Bodies.Add(b3);
#endregion
// Place the bodies.
#region BodyJoinSeparateStep2
b1.Transform.X = 0;
b1.Transform.Y = 0;
b2.Transform.X = 2;
b2.Transform.Y = 0;
b3.Transform.X = 2;
b3.Transform.Y = 1;
#endregion
// Join b1 and b2.
// When the second parameter is false, only one element is created.
// This creates a new array b4, with one element, created from b1 and b2.
#region BodyJoinSeparateStep3
Body[] b4 = b1.Join(b2, false);
foreach (Body b in b4)
{
b.Name = "Surface 4: Surface 1 joined with Surface 2.";
p.Bodies.Add(b);
}
#endregion
// Join the first element in b4 with b3.
// This creates a new array b7, with one element, created from b3 and the first element in b4.
#region BodyJoinSeparateStep4
Body[] b7 = b4[0].Join(b3, false);
foreach (Body b in b7)
{
b.Name =
"Surface 5: Surface 1 joined with Surface 2 and Surface 3. Not separated.";
p.Bodies.Add(b);
}
#endregion
// Join the first element in b4 with b3.
// The elements in b5 is created from each disjunct piece in b3 and the first element in b4.
#region BodyJoinSeparateStep5
Body[] b5 = b4[0].Join(b3, true);
foreach (Body b in b5)
{
b.Name = "Surface 6: Surface 1 joined with Surface 2" +
"and Surface 3. Disjunct lumps separated.";
p.Bodies.Add(b);
}
#endregion
// Separate the first element in b7.
// Each disjunct piece in the first element in b7 creates a new element in b8.
#region BodyJoinSeparateStep6
Body[] b8 = b7[0].Separate();
foreach (Body b in b8)
{
b.Name =
"Surface 7: Disjunct lumps separated from Surface 5.";
p.Bodies.Add(b);
}
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Join(Body, Boolean, Boolean)
Creates an array of new Body(s) consisting of the union of this body with the one provided.
Declaration
public Body[] Join(Body body, bool separateResultingBody, bool nonRegularized)
Parameters
Type | Name | Description |
---|---|---|
Body | body | The body to join this body with. |
Boolean | separateResultingBody | If true, returns an array with one element for each disjunct piece in the joined body. If false, returns an array with one element containing the joined body. |
Boolean | nonRegularized | If true, performs a non-regularized boolean operation which keeps all face regions from the two bodies (although it may split them into separate faces). |
Returns
Type | Description |
---|---|
Body[] | The array of new Body(s) |
Examples
Join Body.
Project.UndoContext.BeginUndoStep("BodyJoinSeparate");
try
{
Station station = Station.ActiveStation;
// Create parts and bodies.
#region BodyJoinSeparateStep1
Part p = new Part();
p.Name = "My_Surfaces";
station.GraphicComponents.Add(p);
Body b1 = Body.CreateSurfaceRectangle(Matrix4.Identity, 1, 1);
b1.Name = "Surface 1";
p.Bodies.Add(b1);
Body b2 = Body.CreateSurfaceRectangle(Matrix4.Identity, 1, 1);
b2.Name = "Surface 2";
p.Bodies.Add(b2);
Body b3 = Body.CreateSurfaceRectangle(Matrix4.Identity, 1, 1);
b3.Name = "Surface 3";
p.Bodies.Add(b3);
#endregion
// Place the bodies.
#region BodyJoinSeparateStep2
b1.Transform.X = 0;
b1.Transform.Y = 0;
b2.Transform.X = 2;
b2.Transform.Y = 0;
b3.Transform.X = 2;
b3.Transform.Y = 1;
#endregion
// Join b1 and b2.
// When the second parameter is false, only one element is created.
// This creates a new array b4, with one element, created from b1 and b2.
#region BodyJoinSeparateStep3
Body[] b4 = b1.Join(b2, false);
foreach (Body b in b4)
{
b.Name = "Surface 4: Surface 1 joined with Surface 2.";
p.Bodies.Add(b);
}
#endregion
// Join the first element in b4 with b3.
// This creates a new array b7, with one element, created from b3 and the first element in b4.
#region BodyJoinSeparateStep4
Body[] b7 = b4[0].Join(b3, false);
foreach (Body b in b7)
{
b.Name =
"Surface 5: Surface 1 joined with Surface 2 and Surface 3. Not separated.";
p.Bodies.Add(b);
}
#endregion
// Join the first element in b4 with b3.
// The elements in b5 is created from each disjunct piece in b3 and the first element in b4.
#region BodyJoinSeparateStep5
Body[] b5 = b4[0].Join(b3, true);
foreach (Body b in b5)
{
b.Name = "Surface 6: Surface 1 joined with Surface 2" +
"and Surface 3. Disjunct lumps separated.";
p.Bodies.Add(b);
}
#endregion
// Separate the first element in b7.
// Each disjunct piece in the first element in b7 creates a new element in b8.
#region BodyJoinSeparateStep6
Body[] b8 = b7[0].Separate();
foreach (Body b in b8)
{
b.Name =
"Surface 7: Disjunct lumps separated from Surface 5.";
p.Bodies.Add(b);
}
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
JoinCurves(Wire[])
Creates one or more bodies that consisting of one single wire each. The source wires that are connected will be joined and separate wires will result in new wire bodies.
Declaration
public static Body[] JoinCurves(Wire[] wires)
Parameters
Type | Name | Description |
---|---|---|
Wire[] | wires | The array of Wire objects that shall be joined. |
Returns
Type | Description |
---|---|
Body[] | The array of new wire bodies. |
Remarks
The transformation matrices of the new wire bodies are reset and will be placed at origin of their part. The order of the wires of the resulting wire body is reversed, compared to the order of the wires in the array given as input.
Examples
Join Curves.
Project.UndoContext.BeginUndoStep("BodyCurveManipulations");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyCurveManipulationsStep1
Part p = new Part();
p.Name = "My_Curve_Manipulations";
station.GraphicComponents.Add(p);
#endregion
// Joined curves.
// Create two lines (wires).
#region BodyCurveManipulationsStep2
Body wire1 = Body.CreateLine(new Vector3(0.0, 0.0, 0.0), new Vector3(0.5, 0.5, 0.5));
wire1.Name = "Wire1";
p.Bodies.Add(wire1);
Body wire2 = Body.CreateLine(new Vector3(0.0, 0.0, 0.0), new Vector3(-0.5, 0.5, 0.5));
wire2.Name = "Wire2";
p.Bodies.Add(wire2);
#endregion
// Create a wire array with the wires that should be joined.
#region BodyCurveManipulationsStep3
Wire[] wires = new Wire[2] { wire1.Shells[0].Wires[0], wire2.Shells[0].Wires[0] };
Body[] wireUnion = Body.JoinCurves(wires);
foreach (Body b in wireUnion)
{
b.Name = "Wire Array";
p.Bodies.Add(b);
}
#endregion
// Create solid cylinder.
#region BodyCurveManipulationsStep4
Matrix4 origin = new Matrix4(new Vector3(Axis.X), 0.0);
Body cylinder = Body.CreateSolidCylinder(origin, 0.2, 1);
cylinder.Name = "Cylinder";
p.Bodies.Add(cylinder);
#endregion
// Create a wire array containing the first wire,
// and a body array containing the cylinder.
#region BodyCurveManipulationsStep5
Wire[] wires2 = new Wire[1] { wire1.Shells[0].Wires[0] };
Body[] bodies = new Body[1] { cylinder };
#endregion
// Project wire1 on the surface of the cylinder along the X-axis.
#region BodyCurveManipulationsStep6
Body[] projection = Body.ProjectCurve(wires2, bodies, Vector3.XVector);
foreach (Body b in projection)
{
b.Name = "Wire1 projected on the cylinders surface along x-axis";
p.Bodies.Add(b);
}
#endregion
// Split wire1 in half.
Body[] splitCurves = Body.SplitCurve(wire1.Shells[0].Wires[0], new Vector3(0.25, 0.25, 0.25));
foreach (Body b in splitCurves)
{
b.Name = "Wire1 split in half";
p.Bodies.Add(b);
}
// Create a semicircle shaped wire.
// Create a circle.
#region BodyCurveManipulationsStep7
Body circle = Body.CreateCircle(new Matrix4(Vector3.XVector, 0.0), 0.5);
circle.Name = "Circle";
p.Bodies.Add(circle);
#endregion
// Create a line to intersect the circle with.
#region BodyCurveManipulationsStep8
Body line = Body.CreateLine(new Vector3(0.5, 0.0, 0.0), new Vector3(-0.5, 0.0, 0.0));
line.Name = "Line";
p.Bodies.Add(line);
#endregion
// Join the circle and the line.
#region BodyCurveManipulationsStep9
Wire[] ws = new Wire[2] { circle.Shells[0].Wires[0], line.Shells[0].Wires[0] };
Body[] union = Body.JoinCurves(ws);
#endregion
// Get the wire of the union.
#region BodyCurveManipulationsStep10
Wire unionWire = union[0].Shells[0].Wires[0];
#endregion
// Get the section to trim.
#region BodyCurveManipulationsStep11
Vector3 sectionSelectionPoint = new Vector3(0.0, -0.5, 0.0);
Vector3 firstTrimPoint = new Vector3(-0.5, 0.0, 0.0);
Vector3 secondTrimPoint = new Vector3(0.5, 0.0, 0.0);
#endregion
// Trim points to array.
#region BodyCurveManipulationsStep12
Vector3[] testPoints = new Vector3[2] { firstTrimPoint, secondTrimPoint };
CurveSection trimSection = unionWire.GetSection(sectionSelectionPoint, testPoints);
Body[] trimmedCircle = Body.TrimCurve(unionWire, trimSection);
foreach (Body b in trimmedCircle)
{
b.Name = "Semicircle from cirle and line";
p.Bodies.Add(b);
}
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Exceptions
Type | Condition |
---|---|
ArgumentException | |
ArgumentNullException |
JoinCurves(Wire[], Double)
Creates one or more bodies that consisting of one single wire each. The source wires that are connected will be joined and separate wires will result in new wire bodies.
Declaration
public static Body[] JoinCurves(Wire[] wires, double tolerance)
Parameters
Type | Name | Description |
---|---|---|
Wire[] | wires | The array of Wire objects that shall be joined. |
Double | tolerance | The largest distance between vertices that are considered coincident. |
Returns
Type | Description |
---|---|
Body[] | The array of new wire bodies. |
Remarks
The transformation matrices of the new wire bodies are reset and will be placed at origin of their part. The order of the wires of the resulting wire body is reversed, compared to the order of the wires in the array given as input.
Examples
Join Curves.
Project.UndoContext.BeginUndoStep("BodyCurveManipulations");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyCurveManipulationsStep1
Part p = new Part();
p.Name = "My_Curve_Manipulations";
station.GraphicComponents.Add(p);
#endregion
// Joined curves.
// Create two lines (wires).
#region BodyCurveManipulationsStep2
Body wire1 = Body.CreateLine(new Vector3(0.0, 0.0, 0.0), new Vector3(0.5, 0.5, 0.5));
wire1.Name = "Wire1";
p.Bodies.Add(wire1);
Body wire2 = Body.CreateLine(new Vector3(0.0, 0.0, 0.0), new Vector3(-0.5, 0.5, 0.5));
wire2.Name = "Wire2";
p.Bodies.Add(wire2);
#endregion
// Create a wire array with the wires that should be joined.
#region BodyCurveManipulationsStep3
Wire[] wires = new Wire[2] { wire1.Shells[0].Wires[0], wire2.Shells[0].Wires[0] };
Body[] wireUnion = Body.JoinCurves(wires);
foreach (Body b in wireUnion)
{
b.Name = "Wire Array";
p.Bodies.Add(b);
}
#endregion
// Create solid cylinder.
#region BodyCurveManipulationsStep4
Matrix4 origin = new Matrix4(new Vector3(Axis.X), 0.0);
Body cylinder = Body.CreateSolidCylinder(origin, 0.2, 1);
cylinder.Name = "Cylinder";
p.Bodies.Add(cylinder);
#endregion
// Create a wire array containing the first wire,
// and a body array containing the cylinder.
#region BodyCurveManipulationsStep5
Wire[] wires2 = new Wire[1] { wire1.Shells[0].Wires[0] };
Body[] bodies = new Body[1] { cylinder };
#endregion
// Project wire1 on the surface of the cylinder along the X-axis.
#region BodyCurveManipulationsStep6
Body[] projection = Body.ProjectCurve(wires2, bodies, Vector3.XVector);
foreach (Body b in projection)
{
b.Name = "Wire1 projected on the cylinders surface along x-axis";
p.Bodies.Add(b);
}
#endregion
// Split wire1 in half.
Body[] splitCurves = Body.SplitCurve(wire1.Shells[0].Wires[0], new Vector3(0.25, 0.25, 0.25));
foreach (Body b in splitCurves)
{
b.Name = "Wire1 split in half";
p.Bodies.Add(b);
}
// Create a semicircle shaped wire.
// Create a circle.
#region BodyCurveManipulationsStep7
Body circle = Body.CreateCircle(new Matrix4(Vector3.XVector, 0.0), 0.5);
circle.Name = "Circle";
p.Bodies.Add(circle);
#endregion
// Create a line to intersect the circle with.
#region BodyCurveManipulationsStep8
Body line = Body.CreateLine(new Vector3(0.5, 0.0, 0.0), new Vector3(-0.5, 0.0, 0.0));
line.Name = "Line";
p.Bodies.Add(line);
#endregion
// Join the circle and the line.
#region BodyCurveManipulationsStep9
Wire[] ws = new Wire[2] { circle.Shells[0].Wires[0], line.Shells[0].Wires[0] };
Body[] union = Body.JoinCurves(ws);
#endregion
// Get the wire of the union.
#region BodyCurveManipulationsStep10
Wire unionWire = union[0].Shells[0].Wires[0];
#endregion
// Get the section to trim.
#region BodyCurveManipulationsStep11
Vector3 sectionSelectionPoint = new Vector3(0.0, -0.5, 0.0);
Vector3 firstTrimPoint = new Vector3(-0.5, 0.0, 0.0);
Vector3 secondTrimPoint = new Vector3(0.5, 0.0, 0.0);
#endregion
// Trim points to array.
#region BodyCurveManipulationsStep12
Vector3[] testPoints = new Vector3[2] { firstTrimPoint, secondTrimPoint };
CurveSection trimSection = unionWire.GetSection(sectionSelectionPoint, testPoints);
Body[] trimmedCircle = Body.TrimCurve(unionWire, trimSection);
foreach (Body b in trimmedCircle)
{
b.Name = "Semicircle from cirle and line";
p.Bodies.Add(b);
}
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Exceptions
Type | Condition |
---|---|
ArgumentException | |
ArgumentNullException |
JoinEdges(Edge[], Double)
Creates one or more bodies consisting of one edge each. The source edges that are connected, or within the given tolerance, will be joined. The separate edged outside of the given tolerance will remain separated. The result will be an array of edges.
Declaration
public static Body[] JoinEdges(Edge[] edges, double tolerance)
Parameters
Type | Name | Description |
---|---|---|
Edge[] | edges | The array of Edges to be joined. |
Double | tolerance | The largest distance between vertices that are considered coincident. |
Returns
Type | Description |
---|---|
Body[] | The array of new wire bodies. |
Remarks
The order of the edges of the resulting wire body is reversed, compared to the order of the edges in the array given as input.
Mirror(Plane)
Creates a new Body by mirroring this body.
Declaration
public Body Mirror(Plane plane)
Parameters
Type | Name | Description |
---|---|---|
Plane | plane | Mirror plane. |
Returns
Type | Description |
---|---|
Body | The new Body. |
MoveToPart(Part)
Moves this Body to a new parent Part
Declaration
public void MoveToPart(Part part)
Parameters
Type | Name | Description |
---|---|---|
Part | part |
Remarks
Use this method to directly move a body. It is more efficient than first removing the body and then adding it to the new part.
NormalizeTextureCoordinates(Boolean, Boolean)
Normalizes the texture coordinates of the graphical representation to the range [0-1].
Declaration
public void NormalizeTextureCoordinates(bool u, bool v)
Parameters
Type | Name | Description |
---|---|---|
Boolean | u | Normalize u coordinates. |
Boolean | v | Normalize v coordinages. |
ProjectCurve(Wire[], Body[], Vector3)
Declaration
public static Body[] ProjectCurve(Wire[] wires, Body[] targets, Vector3 direction)
Parameters
Type | Name | Description |
---|---|---|
Wire[] | wires | The array of Wire objects that shall be projected. |
Body[] | targets | |
Vector3 | direction | The direction of projection (used as a unit vector). |
Returns
Type | Description |
---|---|
Body[] | The array of new wire Bodys. Returns an empty array if no intersection is found. |
Examples
Project Curve.
Project.UndoContext.BeginUndoStep("BodyCurveManipulations");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyCurveManipulationsStep1
Part p = new Part();
p.Name = "My_Curve_Manipulations";
station.GraphicComponents.Add(p);
#endregion
// Joined curves.
// Create two lines (wires).
#region BodyCurveManipulationsStep2
Body wire1 = Body.CreateLine(new Vector3(0.0, 0.0, 0.0), new Vector3(0.5, 0.5, 0.5));
wire1.Name = "Wire1";
p.Bodies.Add(wire1);
Body wire2 = Body.CreateLine(new Vector3(0.0, 0.0, 0.0), new Vector3(-0.5, 0.5, 0.5));
wire2.Name = "Wire2";
p.Bodies.Add(wire2);
#endregion
// Create a wire array with the wires that should be joined.
#region BodyCurveManipulationsStep3
Wire[] wires = new Wire[2] { wire1.Shells[0].Wires[0], wire2.Shells[0].Wires[0] };
Body[] wireUnion = Body.JoinCurves(wires);
foreach (Body b in wireUnion)
{
b.Name = "Wire Array";
p.Bodies.Add(b);
}
#endregion
// Create solid cylinder.
#region BodyCurveManipulationsStep4
Matrix4 origin = new Matrix4(new Vector3(Axis.X), 0.0);
Body cylinder = Body.CreateSolidCylinder(origin, 0.2, 1);
cylinder.Name = "Cylinder";
p.Bodies.Add(cylinder);
#endregion
// Create a wire array containing the first wire,
// and a body array containing the cylinder.
#region BodyCurveManipulationsStep5
Wire[] wires2 = new Wire[1] { wire1.Shells[0].Wires[0] };
Body[] bodies = new Body[1] { cylinder };
#endregion
// Project wire1 on the surface of the cylinder along the X-axis.
#region BodyCurveManipulationsStep6
Body[] projection = Body.ProjectCurve(wires2, bodies, Vector3.XVector);
foreach (Body b in projection)
{
b.Name = "Wire1 projected on the cylinders surface along x-axis";
p.Bodies.Add(b);
}
#endregion
// Split wire1 in half.
Body[] splitCurves = Body.SplitCurve(wire1.Shells[0].Wires[0], new Vector3(0.25, 0.25, 0.25));
foreach (Body b in splitCurves)
{
b.Name = "Wire1 split in half";
p.Bodies.Add(b);
}
// Create a semicircle shaped wire.
// Create a circle.
#region BodyCurveManipulationsStep7
Body circle = Body.CreateCircle(new Matrix4(Vector3.XVector, 0.0), 0.5);
circle.Name = "Circle";
p.Bodies.Add(circle);
#endregion
// Create a line to intersect the circle with.
#region BodyCurveManipulationsStep8
Body line = Body.CreateLine(new Vector3(0.5, 0.0, 0.0), new Vector3(-0.5, 0.0, 0.0));
line.Name = "Line";
p.Bodies.Add(line);
#endregion
// Join the circle and the line.
#region BodyCurveManipulationsStep9
Wire[] ws = new Wire[2] { circle.Shells[0].Wires[0], line.Shells[0].Wires[0] };
Body[] union = Body.JoinCurves(ws);
#endregion
// Get the wire of the union.
#region BodyCurveManipulationsStep10
Wire unionWire = union[0].Shells[0].Wires[0];
#endregion
// Get the section to trim.
#region BodyCurveManipulationsStep11
Vector3 sectionSelectionPoint = new Vector3(0.0, -0.5, 0.0);
Vector3 firstTrimPoint = new Vector3(-0.5, 0.0, 0.0);
Vector3 secondTrimPoint = new Vector3(0.5, 0.0, 0.0);
#endregion
// Trim points to array.
#region BodyCurveManipulationsStep12
Vector3[] testPoints = new Vector3[2] { firstTrimPoint, secondTrimPoint };
CurveSection trimSection = unionWire.GetSection(sectionSelectionPoint, testPoints);
Body[] trimmedCircle = Body.TrimCurve(unionWire, trimSection);
foreach (Body b in trimmedCircle)
{
b.Name = "Semicircle from cirle and line";
p.Bodies.Add(b);
}
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Exceptions
Type | Condition |
---|---|
ArgumentException | |
ArgumentNullException | |
DirectoryNotFoundException | |
FileNotFoundException | |
UnauthorizedAccessException | |
IOException |
ReplaceMaterial(Material, Material)
Replaces one Material in the graphical representation with another.
Declaration
public void ReplaceMaterial(Material oldMaterial, Material newMaterial)
Parameters
Type | Name | Description |
---|---|---|
Material | oldMaterial | |
Material | newMaterial |
Scale(Double)
Creates a new Body by scaling this body.
Declaration
public Body Scale(double scale)
Parameters
Type | Name | Description |
---|---|---|
Double | scale | Scale factor. |
Returns
Type | Description |
---|---|
Body | The new Body. |
Separate()
Creates an array of new Body(s) consisting of the disjunct lumps of this body.
Declaration
public Body[] Separate()
Returns
Type | Description |
---|---|
Body[] | The array of new Body(s) |
Examples
Separate Body.
Project.UndoContext.BeginUndoStep("BodyJoinSeparate");
try
{
Station station = Station.ActiveStation;
// Create parts and bodies.
#region BodyJoinSeparateStep1
Part p = new Part();
p.Name = "My_Surfaces";
station.GraphicComponents.Add(p);
Body b1 = Body.CreateSurfaceRectangle(Matrix4.Identity, 1, 1);
b1.Name = "Surface 1";
p.Bodies.Add(b1);
Body b2 = Body.CreateSurfaceRectangle(Matrix4.Identity, 1, 1);
b2.Name = "Surface 2";
p.Bodies.Add(b2);
Body b3 = Body.CreateSurfaceRectangle(Matrix4.Identity, 1, 1);
b3.Name = "Surface 3";
p.Bodies.Add(b3);
#endregion
// Place the bodies.
#region BodyJoinSeparateStep2
b1.Transform.X = 0;
b1.Transform.Y = 0;
b2.Transform.X = 2;
b2.Transform.Y = 0;
b3.Transform.X = 2;
b3.Transform.Y = 1;
#endregion
// Join b1 and b2.
// When the second parameter is false, only one element is created.
// This creates a new array b4, with one element, created from b1 and b2.
#region BodyJoinSeparateStep3
Body[] b4 = b1.Join(b2, false);
foreach (Body b in b4)
{
b.Name = "Surface 4: Surface 1 joined with Surface 2.";
p.Bodies.Add(b);
}
#endregion
// Join the first element in b4 with b3.
// This creates a new array b7, with one element, created from b3 and the first element in b4.
#region BodyJoinSeparateStep4
Body[] b7 = b4[0].Join(b3, false);
foreach (Body b in b7)
{
b.Name =
"Surface 5: Surface 1 joined with Surface 2 and Surface 3. Not separated.";
p.Bodies.Add(b);
}
#endregion
// Join the first element in b4 with b3.
// The elements in b5 is created from each disjunct piece in b3 and the first element in b4.
#region BodyJoinSeparateStep5
Body[] b5 = b4[0].Join(b3, true);
foreach (Body b in b5)
{
b.Name = "Surface 6: Surface 1 joined with Surface 2" +
"and Surface 3. Disjunct lumps separated.";
p.Bodies.Add(b);
}
#endregion
// Separate the first element in b7.
// Each disjunct piece in the first element in b7 creates a new element in b8.
#region BodyJoinSeparateStep6
Body[] b8 = b7[0].Separate();
foreach (Body b in b8)
{
b.Name =
"Surface 7: Disjunct lumps separated from Surface 5.";
p.Bodies.Add(b);
}
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
SetMaterial(Material)
Sets the Material of the graphical representation of the body.
Declaration
public void SetMaterial(Material material)
Parameters
Type | Name | Description |
---|---|---|
Material | material | New material. |
SetMaterial(Material, Boolean)
Sets the Material of the graphical representation of the body.
Declaration
public void SetMaterial(Material material, bool preserveOpacity)
Parameters
Type | Name | Description |
---|---|---|
Material | material | New material. |
Boolean | preserveOpacity | Preserve the opacity of the current material. |
SplitCurve(Wire, Vector3)
Splits a wire at a position. The position is valid if it lies closer than 10e-3 to the curve. If the split position is the same as any of the endpoints of the wire, nothing will happen.
Declaration
public static Body[] SplitCurve(Wire wire, Vector3 pointOnWire)
Parameters
Type | Name | Description |
---|---|---|
Wire | wire | The Wire object that shall be split. |
Vector3 | pointOnWire | The split location on the wire. |
Returns
Type | Description |
---|---|
Body[] | The array of new wire bodies. |
Examples
Split Curve.
Project.UndoContext.BeginUndoStep("BodyCurveManipulations");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyCurveManipulationsStep1
Part p = new Part();
p.Name = "My_Curve_Manipulations";
station.GraphicComponents.Add(p);
#endregion
// Joined curves.
// Create two lines (wires).
#region BodyCurveManipulationsStep2
Body wire1 = Body.CreateLine(new Vector3(0.0, 0.0, 0.0), new Vector3(0.5, 0.5, 0.5));
wire1.Name = "Wire1";
p.Bodies.Add(wire1);
Body wire2 = Body.CreateLine(new Vector3(0.0, 0.0, 0.0), new Vector3(-0.5, 0.5, 0.5));
wire2.Name = "Wire2";
p.Bodies.Add(wire2);
#endregion
// Create a wire array with the wires that should be joined.
#region BodyCurveManipulationsStep3
Wire[] wires = new Wire[2] { wire1.Shells[0].Wires[0], wire2.Shells[0].Wires[0] };
Body[] wireUnion = Body.JoinCurves(wires);
foreach (Body b in wireUnion)
{
b.Name = "Wire Array";
p.Bodies.Add(b);
}
#endregion
// Create solid cylinder.
#region BodyCurveManipulationsStep4
Matrix4 origin = new Matrix4(new Vector3(Axis.X), 0.0);
Body cylinder = Body.CreateSolidCylinder(origin, 0.2, 1);
cylinder.Name = "Cylinder";
p.Bodies.Add(cylinder);
#endregion
// Create a wire array containing the first wire,
// and a body array containing the cylinder.
#region BodyCurveManipulationsStep5
Wire[] wires2 = new Wire[1] { wire1.Shells[0].Wires[0] };
Body[] bodies = new Body[1] { cylinder };
#endregion
// Project wire1 on the surface of the cylinder along the X-axis.
#region BodyCurveManipulationsStep6
Body[] projection = Body.ProjectCurve(wires2, bodies, Vector3.XVector);
foreach (Body b in projection)
{
b.Name = "Wire1 projected on the cylinders surface along x-axis";
p.Bodies.Add(b);
}
#endregion
// Split wire1 in half.
Body[] splitCurves = Body.SplitCurve(wire1.Shells[0].Wires[0], new Vector3(0.25, 0.25, 0.25));
foreach (Body b in splitCurves)
{
b.Name = "Wire1 split in half";
p.Bodies.Add(b);
}
// Create a semicircle shaped wire.
// Create a circle.
#region BodyCurveManipulationsStep7
Body circle = Body.CreateCircle(new Matrix4(Vector3.XVector, 0.0), 0.5);
circle.Name = "Circle";
p.Bodies.Add(circle);
#endregion
// Create a line to intersect the circle with.
#region BodyCurveManipulationsStep8
Body line = Body.CreateLine(new Vector3(0.5, 0.0, 0.0), new Vector3(-0.5, 0.0, 0.0));
line.Name = "Line";
p.Bodies.Add(line);
#endregion
// Join the circle and the line.
#region BodyCurveManipulationsStep9
Wire[] ws = new Wire[2] { circle.Shells[0].Wires[0], line.Shells[0].Wires[0] };
Body[] union = Body.JoinCurves(ws);
#endregion
// Get the wire of the union.
#region BodyCurveManipulationsStep10
Wire unionWire = union[0].Shells[0].Wires[0];
#endregion
// Get the section to trim.
#region BodyCurveManipulationsStep11
Vector3 sectionSelectionPoint = new Vector3(0.0, -0.5, 0.0);
Vector3 firstTrimPoint = new Vector3(-0.5, 0.0, 0.0);
Vector3 secondTrimPoint = new Vector3(0.5, 0.0, 0.0);
#endregion
// Trim points to array.
#region BodyCurveManipulationsStep12
Vector3[] testPoints = new Vector3[2] { firstTrimPoint, secondTrimPoint };
CurveSection trimSection = unionWire.GetSection(sectionSelectionPoint, testPoints);
Body[] trimmedCircle = Body.TrimCurve(unionWire, trimSection);
foreach (Body b in trimmedCircle)
{
b.Name = "Semicircle from cirle and line";
p.Bodies.Add(b);
}
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Exceptions
Type | Condition |
---|---|
ArgumentException | |
ArgumentNullException | |
DirectoryNotFoundException | |
FileNotFoundException | |
UnauthorizedAccessException | |
IOException |
Stitch(IEnumerable<Body>)
Stitches the input bodies by closing gaps between faces smaller than a specific threshold. The threshold is determined by an internal algorithm.
Declaration
public static Body[] Stitch(IEnumerable<Body> bodies)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Body> | bodies | The entities to be stitched |
Returns
Type | Description |
---|---|
Body[] | An array of type Body. The array consists of copies of the input bodies. If two or more entities are stitched together, they will be represented as a single entity in the returned array. |
Exceptions
Type | Condition |
---|---|
RobotStudio.API.Internal.GeoException |
Stitch(IEnumerable<Body>, Double)
Stitches the input bodies by closing gaps between faces smaller than maxStitchTolerance.
Declaration
public static Body[] Stitch(IEnumerable<Body> bodies, double maxStitchTolerance)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Body> | bodies | The entities to be stitched |
Double | maxStitchTolerance | Threshold in meter |
Returns
Type | Description |
---|---|
Body[] | An array of type Body. The array consists of copies of the input bodies. If two or more entities are stitched together, they will be represented as a single entity in the returned array. |
Exceptions
Type | Condition |
---|---|
RobotStudio.API.Internal.GeoException |
Sweep(Face, Vector3, Vector3, Double, SweepOptions)
Declaration
public static Body Sweep(Face face, Vector3 root, Vector3 axis, double angle, SweepOptions sweepOptions)
Parameters
Type | Name | Description |
---|---|---|
Face | face | |
Vector3 | root | |
Vector3 | axis | |
Double | angle | |
SweepOptions | sweepOptions |
Returns
Type | Description |
---|---|
Body |
TrimCurve(Wire, CurveSection)
Removes a section of a wire. The section is limited by a startpoint and an endpoint, both adjacent to the wire. The start point must be adjacent to the first edge in the supplied list, and the end point must be adjacent to the last edge in the list.
Declaration
public static Body[] TrimCurve(Wire wire, CurveSection curveSection)
Parameters
Type | Name | Description |
---|---|---|
Wire | wire | The Wire object that shall be trimmed. |
CurveSection | curveSection | The section of the wire to trim. |
Returns
Type | Description |
---|---|
Body[] | The array of new wire bodies. |
Remarks
This version ignores section limiter (start and end) in the CurveSection object and simply removes the supplied edges only.
Examples
Trim Curve.
Project.UndoContext.BeginUndoStep("BodyCurveManipulations");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyCurveManipulationsStep1
Part p = new Part();
p.Name = "My_Curve_Manipulations";
station.GraphicComponents.Add(p);
#endregion
// Joined curves.
// Create two lines (wires).
#region BodyCurveManipulationsStep2
Body wire1 = Body.CreateLine(new Vector3(0.0, 0.0, 0.0), new Vector3(0.5, 0.5, 0.5));
wire1.Name = "Wire1";
p.Bodies.Add(wire1);
Body wire2 = Body.CreateLine(new Vector3(0.0, 0.0, 0.0), new Vector3(-0.5, 0.5, 0.5));
wire2.Name = "Wire2";
p.Bodies.Add(wire2);
#endregion
// Create a wire array with the wires that should be joined.
#region BodyCurveManipulationsStep3
Wire[] wires = new Wire[2] { wire1.Shells[0].Wires[0], wire2.Shells[0].Wires[0] };
Body[] wireUnion = Body.JoinCurves(wires);
foreach (Body b in wireUnion)
{
b.Name = "Wire Array";
p.Bodies.Add(b);
}
#endregion
// Create solid cylinder.
#region BodyCurveManipulationsStep4
Matrix4 origin = new Matrix4(new Vector3(Axis.X), 0.0);
Body cylinder = Body.CreateSolidCylinder(origin, 0.2, 1);
cylinder.Name = "Cylinder";
p.Bodies.Add(cylinder);
#endregion
// Create a wire array containing the first wire,
// and a body array containing the cylinder.
#region BodyCurveManipulationsStep5
Wire[] wires2 = new Wire[1] { wire1.Shells[0].Wires[0] };
Body[] bodies = new Body[1] { cylinder };
#endregion
// Project wire1 on the surface of the cylinder along the X-axis.
#region BodyCurveManipulationsStep6
Body[] projection = Body.ProjectCurve(wires2, bodies, Vector3.XVector);
foreach (Body b in projection)
{
b.Name = "Wire1 projected on the cylinders surface along x-axis";
p.Bodies.Add(b);
}
#endregion
// Split wire1 in half.
Body[] splitCurves = Body.SplitCurve(wire1.Shells[0].Wires[0], new Vector3(0.25, 0.25, 0.25));
foreach (Body b in splitCurves)
{
b.Name = "Wire1 split in half";
p.Bodies.Add(b);
}
// Create a semicircle shaped wire.
// Create a circle.
#region BodyCurveManipulationsStep7
Body circle = Body.CreateCircle(new Matrix4(Vector3.XVector, 0.0), 0.5);
circle.Name = "Circle";
p.Bodies.Add(circle);
#endregion
// Create a line to intersect the circle with.
#region BodyCurveManipulationsStep8
Body line = Body.CreateLine(new Vector3(0.5, 0.0, 0.0), new Vector3(-0.5, 0.0, 0.0));
line.Name = "Line";
p.Bodies.Add(line);
#endregion
// Join the circle and the line.
#region BodyCurveManipulationsStep9
Wire[] ws = new Wire[2] { circle.Shells[0].Wires[0], line.Shells[0].Wires[0] };
Body[] union = Body.JoinCurves(ws);
#endregion
// Get the wire of the union.
#region BodyCurveManipulationsStep10
Wire unionWire = union[0].Shells[0].Wires[0];
#endregion
// Get the section to trim.
#region BodyCurveManipulationsStep11
Vector3 sectionSelectionPoint = new Vector3(0.0, -0.5, 0.0);
Vector3 firstTrimPoint = new Vector3(-0.5, 0.0, 0.0);
Vector3 secondTrimPoint = new Vector3(0.5, 0.0, 0.0);
#endregion
// Trim points to array.
#region BodyCurveManipulationsStep12
Vector3[] testPoints = new Vector3[2] { firstTrimPoint, secondTrimPoint };
CurveSection trimSection = unionWire.GetSection(sectionSelectionPoint, testPoints);
Body[] trimmedCircle = Body.TrimCurve(unionWire, trimSection);
foreach (Body b in trimmedCircle)
{
b.Name = "Semicircle from cirle and line";
p.Bodies.Add(b);
}
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Exceptions
Type | Condition |
---|---|
ArgumentException | |
ArgumentNullException | |
DirectoryNotFoundException | |
FileNotFoundException | |
UnauthorizedAccessException | |
IOException |
TryCut(Body, out Body[])
Creates an array of new Body(s) consisting of the cut of this body with the one provided.
Declaration
public bool TryCut(Body body, out Body[] bodies)
Parameters
Type | Name | Description |
---|---|---|
Body | body | The body to cut this body with. |
Body[] | bodies | The array of new Body(s) |
Returns
Type | Description |
---|---|
Boolean |
Examples
Cut Body.
Project.UndoContext.BeginUndoStep("BodyBooleanOperations");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyBooleanOperationsStep1
Part p = new Part();
p.Name = "My_Part";
station.GraphicComponents.Add(p);
#endregion
// Create a solid box.
#region BodyBooleanOperationsStep2
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Vector3 size = new Vector3(0.5, 0.5, 0.5);
Body box = Body.CreateSolidBox(matrix_origo, size);
box.Name = "Box";
p.Bodies.Add(box);
#endregion
// Create a cone.
#region BodyBooleanOperationsStep3
Body cone = Body.CreateSolidCone(matrix_origo, 1.0, 1.0);
cone.Name = "Cone";
p.Bodies.Add(cone);
#endregion
// Create the intersection between the box and the cone.
#region BodyBooleanOperationsStep4
Body[] intersection = box.Intersect(cone);
foreach (Body b in intersection)
{
b.Name = "Intersection Body";
p.Bodies.Add(b);
}
#endregion
//Cut the cone with the box
#region BodyBooleanOperationsStep5
Body[] cut = cone.Cut2(box);
foreach (Body b in cut)
{
b.Name = "Cut Body";
p.Bodies.Add(b);
}
#endregion
// Join the box and the cone.
#region BodyBooleanOperationsStep6
Body[] union = box.Join(cone);
foreach (Body b in union)
{
b.Name = "Join Body";
p.Bodies.Add(b);
}
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
TryIntersect(Body, out Body[])
Creates an array of new Body(s) consisting of intersection of this body and the the one provided.
Declaration
public bool TryIntersect(Body body, out Body[] bodies)
Parameters
Type | Name | Description |
---|---|---|
Body | body | The body to intersect this body with. |
Body[] | bodies | The array of new Body(s). |
Returns
Type | Description |
---|---|
Boolean |
Examples
Intersect Body.
Project.UndoContext.BeginUndoStep("BodyBooleanOperations");
try
{
Station station = Station.ActiveStation;
// Create a part to contain the bodies.
#region BodyBooleanOperationsStep1
Part p = new Part();
p.Name = "My_Part";
station.GraphicComponents.Add(p);
#endregion
// Create a solid box.
#region BodyBooleanOperationsStep2
Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
Vector3 size = new Vector3(0.5, 0.5, 0.5);
Body box = Body.CreateSolidBox(matrix_origo, size);
box.Name = "Box";
p.Bodies.Add(box);
#endregion
// Create a cone.
#region BodyBooleanOperationsStep3
Body cone = Body.CreateSolidCone(matrix_origo, 1.0, 1.0);
cone.Name = "Cone";
p.Bodies.Add(cone);
#endregion
// Create the intersection between the box and the cone.
#region BodyBooleanOperationsStep4
Body[] intersection = box.Intersect(cone);
foreach (Body b in intersection)
{
b.Name = "Intersection Body";
p.Bodies.Add(b);
}
#endregion
//Cut the cone with the box
#region BodyBooleanOperationsStep5
Body[] cut = cone.Cut2(box);
foreach (Body b in cut)
{
b.Name = "Cut Body";
p.Bodies.Add(b);
}
#endregion
// Join the box and the cone.
#region BodyBooleanOperationsStep6
Body[] union = box.Join(cone);
foreach (Body b in union)
{
b.Name = "Join Body";
p.Bodies.Add(b);
}
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
TryJoin(Body, Boolean, out Body[])
Creates an array of new Body(s) consisting of the union of this body with the one provided.
Declaration
public bool TryJoin(Body body, bool separateResultingBody, out Body[] joined)
Parameters
Type | Name | Description |
---|---|---|
Body | body | The body to join this body with. |
Boolean | separateResultingBody | If true, creates an array with one element for each disjunct piece in the joined body. If false, creates an array with one element containing the joined body. |
Body[] | joined | The array of new Body(s) |
Returns
Type | Description |
---|---|
Boolean |
Examples
Join Body.
Project.UndoContext.BeginUndoStep("BodyJoinSeparate");
try
{
Station station = Station.ActiveStation;
// Create parts and bodies.
#region BodyJoinSeparateStep1
Part p = new Part();
p.Name = "My_Surfaces";
station.GraphicComponents.Add(p);
Body b1 = Body.CreateSurfaceRectangle(Matrix4.Identity, 1, 1);
b1.Name = "Surface 1";
p.Bodies.Add(b1);
Body b2 = Body.CreateSurfaceRectangle(Matrix4.Identity, 1, 1);
b2.Name = "Surface 2";
p.Bodies.Add(b2);
Body b3 = Body.CreateSurfaceRectangle(Matrix4.Identity, 1, 1);
b3.Name = "Surface 3";
p.Bodies.Add(b3);
#endregion
// Place the bodies.
#region BodyJoinSeparateStep2
b1.Transform.X = 0;
b1.Transform.Y = 0;
b2.Transform.X = 2;
b2.Transform.Y = 0;
b3.Transform.X = 2;
b3.Transform.Y = 1;
#endregion
// Join b1 and b2.
// When the second parameter is false, only one element is created.
// This creates a new array b4, with one element, created from b1 and b2.
#region BodyJoinSeparateStep3
Body[] b4 = b1.Join(b2, false);
foreach (Body b in b4)
{
b.Name = "Surface 4: Surface 1 joined with Surface 2.";
p.Bodies.Add(b);
}
#endregion
// Join the first element in b4 with b3.
// This creates a new array b7, with one element, created from b3 and the first element in b4.
#region BodyJoinSeparateStep4
Body[] b7 = b4[0].Join(b3, false);
foreach (Body b in b7)
{
b.Name =
"Surface 5: Surface 1 joined with Surface 2 and Surface 3. Not separated.";
p.Bodies.Add(b);
}
#endregion
// Join the first element in b4 with b3.
// The elements in b5 is created from each disjunct piece in b3 and the first element in b4.
#region BodyJoinSeparateStep5
Body[] b5 = b4[0].Join(b3, true);
foreach (Body b in b5)
{
b.Name = "Surface 6: Surface 1 joined with Surface 2" +
"and Surface 3. Disjunct lumps separated.";
p.Bodies.Add(b);
}
#endregion
// Separate the first element in b7.
// Each disjunct piece in the first element in b7 creates a new element in b8.
#region BodyJoinSeparateStep6
Body[] b8 = b7[0].Separate();
foreach (Body b in b8)
{
b.Name =
"Surface 7: Disjunct lumps separated from Surface 5.";
p.Bodies.Add(b);
}
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
TryJoin(Body, Boolean, Boolean, out Body[])
Creates an array of new Body(s) consisting of the union of this body with the one provided.
Declaration
public bool TryJoin(Body body, bool separateResultingBody, bool nonRegularized, out Body[] joined)
Parameters
Type | Name | Description |
---|---|---|
Body | body | The body to join this body with. |
Boolean | separateResultingBody | If true, creates an array with one element for each disjunct piece in the joined body. If false, creates an array with one element containing the joined body. |
Boolean | nonRegularized | If true, performs a non-regularized boolean operation which keeps all face regions from the two bodies (although it may split them into separate faces). |
Body[] | joined | The array of new Body(s) |
Returns
Type | Description |
---|---|
Boolean |
Examples
Join Body.
Project.UndoContext.BeginUndoStep("BodyJoinSeparate");
try
{
Station station = Station.ActiveStation;
// Create parts and bodies.
#region BodyJoinSeparateStep1
Part p = new Part();
p.Name = "My_Surfaces";
station.GraphicComponents.Add(p);
Body b1 = Body.CreateSurfaceRectangle(Matrix4.Identity, 1, 1);
b1.Name = "Surface 1";
p.Bodies.Add(b1);
Body b2 = Body.CreateSurfaceRectangle(Matrix4.Identity, 1, 1);
b2.Name = "Surface 2";
p.Bodies.Add(b2);
Body b3 = Body.CreateSurfaceRectangle(Matrix4.Identity, 1, 1);
b3.Name = "Surface 3";
p.Bodies.Add(b3);
#endregion
// Place the bodies.
#region BodyJoinSeparateStep2
b1.Transform.X = 0;
b1.Transform.Y = 0;
b2.Transform.X = 2;
b2.Transform.Y = 0;
b3.Transform.X = 2;
b3.Transform.Y = 1;
#endregion
// Join b1 and b2.
// When the second parameter is false, only one element is created.
// This creates a new array b4, with one element, created from b1 and b2.
#region BodyJoinSeparateStep3
Body[] b4 = b1.Join(b2, false);
foreach (Body b in b4)
{
b.Name = "Surface 4: Surface 1 joined with Surface 2.";
p.Bodies.Add(b);
}
#endregion
// Join the first element in b4 with b3.
// This creates a new array b7, with one element, created from b3 and the first element in b4.
#region BodyJoinSeparateStep4
Body[] b7 = b4[0].Join(b3, false);
foreach (Body b in b7)
{
b.Name =
"Surface 5: Surface 1 joined with Surface 2 and Surface 3. Not separated.";
p.Bodies.Add(b);
}
#endregion
// Join the first element in b4 with b3.
// The elements in b5 is created from each disjunct piece in b3 and the first element in b4.
#region BodyJoinSeparateStep5
Body[] b5 = b4[0].Join(b3, true);
foreach (Body b in b5)
{
b.Name = "Surface 6: Surface 1 joined with Surface 2" +
"and Surface 3. Disjunct lumps separated.";
p.Bodies.Add(b);
}
#endregion
// Separate the first element in b7.
// Each disjunct piece in the first element in b7 creates a new element in b8.
#region BodyJoinSeparateStep6
Body[] b8 = b7[0].Separate();
foreach (Body b in b8)
{
b.Name =
"Surface 7: Disjunct lumps separated from Surface 5.";
p.Bodies.Add(b);
}
#endregion
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}