public static void ObjectAddTest() { Scene s = new Scene(); SimulationObject o = s.AddObject(); Console.WriteLine(o.GetType().Name); Console.WriteLine(o); }
// Attempts to add a simulation object into the simulation // Returns true if successful, and false if not private bool CreateNewObject(SimulationObject @object) { // Check if new object should be automatically named if (preferences.AutoName) { // Get list of already used names List <string> usedNames = new List <string>(); foreach (SimulationObject existingObject in simulation.GetObjects()) { usedNames.Add(existingObject.Name); } // Continue to attempt to generate new unique object name until it is unique string name = @object.GetType().Name; int i = 1; while (usedNames.Contains(name)) { // Generate new name name = @object.GetType().Name + i.ToString(); i++; } // Apply unique name @object.Name = name; } else { // Open object creation form to get user to enter name ObjectCreationBox objectCreationBox = new ObjectCreationBox(simulation.GetObjectsToSave()); if (objectCreationBox.ShowDialog(this) == DialogResult.OK) { // Apply unique name @object.Name = objectCreationBox.ObjectName; } else { return(false); } } // Add object to simulation simulation.AddObject(@object); inspector.SelectedObject = @object; return(true); }
public static void ObjectDestroyTest() { Scene s = new Scene(); SimulationObject o = s.AddObject(); ETE.Engine.Object.DestroyImmediate(o); Console.WriteLine(o.GetType().Name); Console.WriteLine(o); }