Class GraphicComponentLibrary
A GraphicComponentLibrary allows you to save and load graphic components to and from a library file.
Inherited Members
Namespace: ABB.Robotics.RobotStudio.Stations
Assembly: ABB.Robotics.RobotStudio.Stations.dll
Syntax
sistent("ComponentLibrary")]
public sealed class GraphicComponentLibrary : Project, IGfxObject
Constructors
GraphicComponentLibrary()
Creates and initializes a new GraphicComponentLibrary object.
Declaration
public GraphicComponentLibrary()
Examples
GraphicComponentLibrary Example.
Project.UndoContext.BeginUndoStep("GraphicComponentGroupProperties");
try
{
Station station = Station.ActiveStation;
// Create the GraphicComponentGroup.
GraphicComponentGroup myGCGroup = new GraphicComponentGroup();
myGCGroup.Name = "myGCGroup";
// Add the GraphicComponentGroup to the GraphicComponents of the station.
station.GraphicComponents.Add(myGCGroup);
// Create a part.
Part myPart1 = new Part();
myPart1.Name = "MyPart1";
// Create a box and add it to myPart1.
Body box = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.4, 0.4, 0.4));
box.Name = "MyBox";
myPart1.Bodies.Add(box);
// Add myPart1 to myGCGroup.
myGCGroup.GraphicComponents.Add(myPart1);
// Create another part.
Part myPart2 = new Part();
myPart2.Name = "MyPart2";
//Create a cylinder and add it to myPart2.
Matrix4 origin = new Matrix4(new Vector3(0.5, 0.5, 0.5), 0.0);
Body myCylinder = Body.CreateSolidCylinder(origin, 0.2, 1);
myCylinder.Name = "myCylinder";
myPart2.Bodies.Add(myCylinder);
// Add myPart1 to myGCGroup.
myGCGroup.GraphicComponents.Add(myPart2);
// Create a third part.
Part myPart3 = new Part();
myPart3.Name = "MyPart3";
// Create a box and add it to myPart3.
Body box2 = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.1, 0.1, 0.1));
box2.Name = "MyBox_2";
myPart3.Bodies.Add(box2);
// Add myPart3 to the station.
station.GraphicComponents.Add(myPart3);
// Attach myPart3 to myGCGroup, mount it on top of the cylinder, using an offset matrix.
if (myGCGroup.CanAttachChild(myPart3))
{
myGCGroup.Attach(myPart3, true, new Matrix4(new Vector3(0.0, 0.0, 1.0)));
}
else
{
Logger.AddMessage(new LogMessage("Could not attach myPart3 to myGCGroup"));
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Properties
Classification
Gets or Sets the ComponentLibraryClassification of the library.
Declaration
olete("not used")]
public ComponentLibraryClassification Classification { get; set; }
Property Value
Type | Description |
---|---|
ComponentLibraryClassification |
GraphicComponents
Declaration
olete("Do not use this property, to move an object to the library use MoveDefinitionToLibrary on the GraphicComponents class", false)]
public GraphicComponentCollection GraphicComponents { get; }
Property Value
Type | Description |
---|---|
GraphicComponentCollection |
ReadOnly
Gets or sets a value indicating if the corresponding library file is readonly or in use.
Declaration
public override bool ReadOnly { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Overrides
Remarks
The value can only be set to true. Trying to set the value to false will cause an exception.
Examples
GraphicComponentLibrary Example.
Project.UndoContext.BeginUndoStep("GraphicComponentGroupProperties");
try
{
Station station = Station.ActiveStation;
// Create the GraphicComponentGroup.
GraphicComponentGroup myGCGroup = new GraphicComponentGroup();
myGCGroup.Name = "myGCGroup";
// Add the GraphicComponentGroup to the GraphicComponents of the station.
station.GraphicComponents.Add(myGCGroup);
// Create a part.
Part myPart1 = new Part();
myPart1.Name = "MyPart1";
// Create a box and add it to myPart1.
Body box = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.4, 0.4, 0.4));
box.Name = "MyBox";
myPart1.Bodies.Add(box);
// Add myPart1 to myGCGroup.
myGCGroup.GraphicComponents.Add(myPart1);
// Create another part.
Part myPart2 = new Part();
myPart2.Name = "MyPart2";
//Create a cylinder and add it to myPart2.
Matrix4 origin = new Matrix4(new Vector3(0.5, 0.5, 0.5), 0.0);
Body myCylinder = Body.CreateSolidCylinder(origin, 0.2, 1);
myCylinder.Name = "myCylinder";
myPart2.Bodies.Add(myCylinder);
// Add myPart1 to myGCGroup.
myGCGroup.GraphicComponents.Add(myPart2);
// Create a third part.
Part myPart3 = new Part();
myPart3.Name = "MyPart3";
// Create a box and add it to myPart3.
Body box2 = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.1, 0.1, 0.1));
box2.Name = "MyBox_2";
myPart3.Bodies.Add(box2);
// Add myPart3 to the station.
station.GraphicComponents.Add(myPart3);
// Attach myPart3 to myGCGroup, mount it on top of the cylinder, using an offset matrix.
if (myGCGroup.CanAttachChild(myPart3))
{
myGCGroup.Attach(myPart3, true, new Matrix4(new Vector3(0.0, 0.0, 1.0)));
}
else
{
Logger.AddMessage(new LogMessage("Could not attach myPart3 to myGCGroup"));
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
RootComponent
Get the root GraphicComponent of the library.
Declaration
public GraphicComponent RootComponent { get; set; }
Property Value
Type | Description |
---|---|
GraphicComponent |
Remarks
Do not use the setter of this property, it is obsolete. Instead use GraphicComponent.MoveDefinitionToLibrary() in order to move an object to this library.
Examples
GraphicComponentLibrary Example.
Project.UndoContext.BeginUndoStep("GraphicComponentGroupProperties");
try
{
Station station = Station.ActiveStation;
// Create the GraphicComponentGroup.
GraphicComponentGroup myGCGroup = new GraphicComponentGroup();
myGCGroup.Name = "myGCGroup";
// Add the GraphicComponentGroup to the GraphicComponents of the station.
station.GraphicComponents.Add(myGCGroup);
// Create a part.
Part myPart1 = new Part();
myPart1.Name = "MyPart1";
// Create a box and add it to myPart1.
Body box = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.4, 0.4, 0.4));
box.Name = "MyBox";
myPart1.Bodies.Add(box);
// Add myPart1 to myGCGroup.
myGCGroup.GraphicComponents.Add(myPart1);
// Create another part.
Part myPart2 = new Part();
myPart2.Name = "MyPart2";
//Create a cylinder and add it to myPart2.
Matrix4 origin = new Matrix4(new Vector3(0.5, 0.5, 0.5), 0.0);
Body myCylinder = Body.CreateSolidCylinder(origin, 0.2, 1);
myCylinder.Name = "myCylinder";
myPart2.Bodies.Add(myCylinder);
// Add myPart1 to myGCGroup.
myGCGroup.GraphicComponents.Add(myPart2);
// Create a third part.
Part myPart3 = new Part();
myPart3.Name = "MyPart3";
// Create a box and add it to myPart3.
Body box2 = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.1, 0.1, 0.1));
box2.Name = "MyBox_2";
myPart3.Bodies.Add(box2);
// Add myPart3 to the station.
station.GraphicComponents.Add(myPart3);
// Attach myPart3 to myGCGroup, mount it on top of the cylinder, using an offset matrix.
if (myGCGroup.CanAttachChild(myPart3))
{
myGCGroup.Attach(myPart3, true, new Matrix4(new Vector3(0.0, 0.0, 1.0)));
}
else
{
Logger.AddMessage(new LogMessage("Could not attach myPart3 to myGCGroup"));
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Methods
AfterLoad(PimDocument)
Declaration
protected override void AfterLoad(PimDocument doc)
Parameters
Type | Name | Description |
---|---|---|
RobotStudio.API.Persistence.PimDocument | doc |
Overrides
Load(String, Boolean)
Creates and initializes a GraphicComponentLibrary from a file.
Declaration
public static GraphicComponentLibrary Load(string fileName, bool asReadOnly)
Parameters
Type | Name | Description |
---|---|---|
String | fileName | The filename of the libarary to load. |
Boolean | asReadOnly | Specifies whether or not the library should be loaded in read only mode. |
Returns
Type | Description |
---|---|
GraphicComponentLibrary |
Examples
GraphicComponentLibrary Example.
Project.UndoContext.BeginUndoStep("GraphicComponentGroupProperties");
try
{
Station station = Station.ActiveStation;
// Create the GraphicComponentGroup.
GraphicComponentGroup myGCGroup = new GraphicComponentGroup();
myGCGroup.Name = "myGCGroup";
// Add the GraphicComponentGroup to the GraphicComponents of the station.
station.GraphicComponents.Add(myGCGroup);
// Create a part.
Part myPart1 = new Part();
myPart1.Name = "MyPart1";
// Create a box and add it to myPart1.
Body box = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.4, 0.4, 0.4));
box.Name = "MyBox";
myPart1.Bodies.Add(box);
// Add myPart1 to myGCGroup.
myGCGroup.GraphicComponents.Add(myPart1);
// Create another part.
Part myPart2 = new Part();
myPart2.Name = "MyPart2";
//Create a cylinder and add it to myPart2.
Matrix4 origin = new Matrix4(new Vector3(0.5, 0.5, 0.5), 0.0);
Body myCylinder = Body.CreateSolidCylinder(origin, 0.2, 1);
myCylinder.Name = "myCylinder";
myPart2.Bodies.Add(myCylinder);
// Add myPart1 to myGCGroup.
myGCGroup.GraphicComponents.Add(myPart2);
// Create a third part.
Part myPart3 = new Part();
myPart3.Name = "MyPart3";
// Create a box and add it to myPart3.
Body box2 = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.1, 0.1, 0.1));
box2.Name = "MyBox_2";
myPart3.Bodies.Add(box2);
// Add myPart3 to the station.
station.GraphicComponents.Add(myPart3);
// Attach myPart3 to myGCGroup, mount it on top of the cylinder, using an offset matrix.
if (myGCGroup.CanAttachChild(myPart3))
{
myGCGroup.Attach(myPart3, true, new Matrix4(new Vector3(0.0, 0.0, 1.0)));
}
else
{
Logger.AddMessage(new LogMessage("Could not attach myPart3 to myGCGroup"));
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Load(String, Boolean, ProgressNotification)
Creates and initializes a GraphicComponentLibrary from a file.
Declaration
public static GraphicComponentLibrary Load(string fileName, bool asReadOnly, ProgressNotification progressDelegate)
Parameters
Type | Name | Description |
---|---|---|
String | fileName | The filename of the libarary to load. |
Boolean | asReadOnly | Specifies whether or not the library should be loaded in read only mode. |
ProgressNotification | progressDelegate | Specifies a ProgressNotification delegate to handle the progress notification events. |
Returns
Type | Description |
---|---|
GraphicComponentLibrary |
Examples
GraphicComponentLibrary Example.
Project.UndoContext.BeginUndoStep("GraphicComponentGroupProperties");
try
{
Station station = Station.ActiveStation;
// Create the GraphicComponentGroup.
GraphicComponentGroup myGCGroup = new GraphicComponentGroup();
myGCGroup.Name = "myGCGroup";
// Add the GraphicComponentGroup to the GraphicComponents of the station.
station.GraphicComponents.Add(myGCGroup);
// Create a part.
Part myPart1 = new Part();
myPart1.Name = "MyPart1";
// Create a box and add it to myPart1.
Body box = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.4, 0.4, 0.4));
box.Name = "MyBox";
myPart1.Bodies.Add(box);
// Add myPart1 to myGCGroup.
myGCGroup.GraphicComponents.Add(myPart1);
// Create another part.
Part myPart2 = new Part();
myPart2.Name = "MyPart2";
//Create a cylinder and add it to myPart2.
Matrix4 origin = new Matrix4(new Vector3(0.5, 0.5, 0.5), 0.0);
Body myCylinder = Body.CreateSolidCylinder(origin, 0.2, 1);
myCylinder.Name = "myCylinder";
myPart2.Bodies.Add(myCylinder);
// Add myPart1 to myGCGroup.
myGCGroup.GraphicComponents.Add(myPart2);
// Create a third part.
Part myPart3 = new Part();
myPart3.Name = "MyPart3";
// Create a box and add it to myPart3.
Body box2 = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.1, 0.1, 0.1));
box2.Name = "MyBox_2";
myPart3.Bodies.Add(box2);
// Add myPart3 to the station.
station.GraphicComponents.Add(myPart3);
// Attach myPart3 to myGCGroup, mount it on top of the cylinder, using an offset matrix.
if (myGCGroup.CanAttachChild(myPart3))
{
myGCGroup.Attach(myPart3, true, new Matrix4(new Vector3(0.0, 0.0, 1.0)));
}
else
{
Logger.AddMessage(new LogMessage("Could not attach myPart3 to myGCGroup"));
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Load(String, Boolean, ProgressNotification, Boolean)
Creates and initializes a GraphicComponentLibrary from a file.
Declaration
public static GraphicComponentLibrary Load(string fileName, bool asReadOnly, ProgressNotification progressDelegate, bool loadGeometry)
Parameters
Type | Name | Description |
---|---|---|
String | fileName | The filename of the library to load. |
Boolean | asReadOnly | Specifies whether or not the library should be loaded in read only mode. |
ProgressNotification | progressDelegate | Specifies a ProgressNotification delegate to handle the progress notification events. |
Boolean | loadGeometry | Specifies whether or not the geometry should be loaded from the Library. |
Returns
Type | Description |
---|---|
GraphicComponentLibrary |
Examples
GraphicComponentLibrary Example.
Project.UndoContext.BeginUndoStep("GraphicComponentGroupProperties");
try
{
Station station = Station.ActiveStation;
// Create the GraphicComponentGroup.
GraphicComponentGroup myGCGroup = new GraphicComponentGroup();
myGCGroup.Name = "myGCGroup";
// Add the GraphicComponentGroup to the GraphicComponents of the station.
station.GraphicComponents.Add(myGCGroup);
// Create a part.
Part myPart1 = new Part();
myPart1.Name = "MyPart1";
// Create a box and add it to myPart1.
Body box = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.4, 0.4, 0.4));
box.Name = "MyBox";
myPart1.Bodies.Add(box);
// Add myPart1 to myGCGroup.
myGCGroup.GraphicComponents.Add(myPart1);
// Create another part.
Part myPart2 = new Part();
myPart2.Name = "MyPart2";
//Create a cylinder and add it to myPart2.
Matrix4 origin = new Matrix4(new Vector3(0.5, 0.5, 0.5), 0.0);
Body myCylinder = Body.CreateSolidCylinder(origin, 0.2, 1);
myCylinder.Name = "myCylinder";
myPart2.Bodies.Add(myCylinder);
// Add myPart1 to myGCGroup.
myGCGroup.GraphicComponents.Add(myPart2);
// Create a third part.
Part myPart3 = new Part();
myPart3.Name = "MyPart3";
// Create a box and add it to myPart3.
Body box2 = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.1, 0.1, 0.1));
box2.Name = "MyBox_2";
myPart3.Bodies.Add(box2);
// Add myPart3 to the station.
station.GraphicComponents.Add(myPart3);
// Attach myPart3 to myGCGroup, mount it on top of the cylinder, using an offset matrix.
if (myGCGroup.CanAttachChild(myPart3))
{
myGCGroup.Attach(myPart3, true, new Matrix4(new Vector3(0.0, 0.0, 1.0)));
}
else
{
Logger.AddMessage(new LogMessage("Could not attach myPart3 to myGCGroup"));
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
LoadAsync(String, Boolean)
Creates and initializes a GraphicComponentLibrary from a file.
Declaration
public static Task<GraphicComponentLibrary> LoadAsync(string fileName, bool asReadOnly)
Parameters
Type | Name | Description |
---|---|---|
String | fileName | The filename of the libarary to load. |
Boolean | asReadOnly | Specifies whether or not the library should be loaded in read only mode. |
Returns
Type | Description |
---|---|
Task<GraphicComponentLibrary> |
Examples
GraphicComponentLibrary Example.
Project.UndoContext.BeginUndoStep("GraphicComponentGroupProperties");
try
{
Station station = Station.ActiveStation;
// Create the GraphicComponentGroup.
GraphicComponentGroup myGCGroup = new GraphicComponentGroup();
myGCGroup.Name = "myGCGroup";
// Add the GraphicComponentGroup to the GraphicComponents of the station.
station.GraphicComponents.Add(myGCGroup);
// Create a part.
Part myPart1 = new Part();
myPart1.Name = "MyPart1";
// Create a box and add it to myPart1.
Body box = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.4, 0.4, 0.4));
box.Name = "MyBox";
myPart1.Bodies.Add(box);
// Add myPart1 to myGCGroup.
myGCGroup.GraphicComponents.Add(myPart1);
// Create another part.
Part myPart2 = new Part();
myPart2.Name = "MyPart2";
//Create a cylinder and add it to myPart2.
Matrix4 origin = new Matrix4(new Vector3(0.5, 0.5, 0.5), 0.0);
Body myCylinder = Body.CreateSolidCylinder(origin, 0.2, 1);
myCylinder.Name = "myCylinder";
myPart2.Bodies.Add(myCylinder);
// Add myPart1 to myGCGroup.
myGCGroup.GraphicComponents.Add(myPart2);
// Create a third part.
Part myPart3 = new Part();
myPart3.Name = "MyPart3";
// Create a box and add it to myPart3.
Body box2 = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.1, 0.1, 0.1));
box2.Name = "MyBox_2";
myPart3.Bodies.Add(box2);
// Add myPart3 to the station.
station.GraphicComponents.Add(myPart3);
// Attach myPart3 to myGCGroup, mount it on top of the cylinder, using an offset matrix.
if (myGCGroup.CanAttachChild(myPart3))
{
myGCGroup.Attach(myPart3, true, new Matrix4(new Vector3(0.0, 0.0, 1.0)));
}
else
{
Logger.AddMessage(new LogMessage("Could not attach myPart3 to myGCGroup"));
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
LoadAsync(String, Boolean, ProgressNotification, Boolean)
Creates and initializes a GraphicComponentLibrary from a file.
Declaration
public static Task<GraphicComponentLibrary> LoadAsync(string fileName, bool asReadOnly, ProgressNotification progressDelegate, bool loadGeometry)
Parameters
Type | Name | Description |
---|---|---|
String | fileName | The filename of the library to load. |
Boolean | asReadOnly | Specifies whether or not the library should be loaded in read only mode. |
ProgressNotification | progressDelegate | Specifies a ProgressNotification delegate to handle the progress notification events. |
Boolean | loadGeometry | Specifies whether or not the geometry should be loaded from the Library. |
Returns
Type | Description |
---|---|
Task<GraphicComponentLibrary> |
Examples
GraphicComponentLibrary Example.
Project.UndoContext.BeginUndoStep("GraphicComponentGroupProperties");
try
{
Station station = Station.ActiveStation;
// Create the GraphicComponentGroup.
GraphicComponentGroup myGCGroup = new GraphicComponentGroup();
myGCGroup.Name = "myGCGroup";
// Add the GraphicComponentGroup to the GraphicComponents of the station.
station.GraphicComponents.Add(myGCGroup);
// Create a part.
Part myPart1 = new Part();
myPart1.Name = "MyPart1";
// Create a box and add it to myPart1.
Body box = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.4, 0.4, 0.4));
box.Name = "MyBox";
myPart1.Bodies.Add(box);
// Add myPart1 to myGCGroup.
myGCGroup.GraphicComponents.Add(myPart1);
// Create another part.
Part myPart2 = new Part();
myPart2.Name = "MyPart2";
//Create a cylinder and add it to myPart2.
Matrix4 origin = new Matrix4(new Vector3(0.5, 0.5, 0.5), 0.0);
Body myCylinder = Body.CreateSolidCylinder(origin, 0.2, 1);
myCylinder.Name = "myCylinder";
myPart2.Bodies.Add(myCylinder);
// Add myPart1 to myGCGroup.
myGCGroup.GraphicComponents.Add(myPart2);
// Create a third part.
Part myPart3 = new Part();
myPart3.Name = "MyPart3";
// Create a box and add it to myPart3.
Body box2 = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.1, 0.1, 0.1));
box2.Name = "MyBox_2";
myPart3.Bodies.Add(box2);
// Add myPart3 to the station.
station.GraphicComponents.Add(myPart3);
// Attach myPart3 to myGCGroup, mount it on top of the cylinder, using an offset matrix.
if (myGCGroup.CanAttachChild(myPart3))
{
myGCGroup.Attach(myPart3, true, new Matrix4(new Vector3(0.0, 0.0, 1.0)));
}
else
{
Logger.AddMessage(new LogMessage("Could not attach myPart3 to myGCGroup"));
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
SaveAs(String)
Saves a GraphicComponentLibrary to a file.
Declaration
public override void SaveAs(string fileName)
Parameters
Type | Name | Description |
---|---|---|
String | fileName | The filename of the libarary to save. |
Overrides
Examples
GraphicComponentLibrary Example.
Project.UndoContext.BeginUndoStep("GraphicComponentGroupProperties");
try
{
Station station = Station.ActiveStation;
// Create the GraphicComponentGroup.
GraphicComponentGroup myGCGroup = new GraphicComponentGroup();
myGCGroup.Name = "myGCGroup";
// Add the GraphicComponentGroup to the GraphicComponents of the station.
station.GraphicComponents.Add(myGCGroup);
// Create a part.
Part myPart1 = new Part();
myPart1.Name = "MyPart1";
// Create a box and add it to myPart1.
Body box = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.4, 0.4, 0.4));
box.Name = "MyBox";
myPart1.Bodies.Add(box);
// Add myPart1 to myGCGroup.
myGCGroup.GraphicComponents.Add(myPart1);
// Create another part.
Part myPart2 = new Part();
myPart2.Name = "MyPart2";
//Create a cylinder and add it to myPart2.
Matrix4 origin = new Matrix4(new Vector3(0.5, 0.5, 0.5), 0.0);
Body myCylinder = Body.CreateSolidCylinder(origin, 0.2, 1);
myCylinder.Name = "myCylinder";
myPart2.Bodies.Add(myCylinder);
// Add myPart1 to myGCGroup.
myGCGroup.GraphicComponents.Add(myPart2);
// Create a third part.
Part myPart3 = new Part();
myPart3.Name = "MyPart3";
// Create a box and add it to myPart3.
Body box2 = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.1, 0.1, 0.1));
box2.Name = "MyBox_2";
myPart3.Bodies.Add(box2);
// Add myPart3 to the station.
station.GraphicComponents.Add(myPart3);
// Attach myPart3 to myGCGroup, mount it on top of the cylinder, using an offset matrix.
if (myGCGroup.CanAttachChild(myPart3))
{
myGCGroup.Attach(myPart3, true, new Matrix4(new Vector3(0.0, 0.0, 1.0)));
}
else
{
Logger.AddMessage(new LogMessage("Could not attach myPart3 to myGCGroup"));
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}