Friday, 19 January 2024
  4 Replies
  327 Visits
0
Votes
Undo
Hello,

I want to connect a task to an ObjectItem (in this case a cable). I tried it through EngineeringBase.Interop.dll and through an EB assistent. Both ways did not work. I get an exception, that the method is not allowed.
Below you find the code of the assistant. Am I doing something wrong or is this operation not supported (yet)? I can perform this operation through the GUI.
I am using EB Version 7.2.0 Build 1385.


public class MyPlugIn : PlugInWizard
{
/// <summary>
/// Runs the wizard.
/// </summary>
/// <param name="myApplication">Application object instance</param>
public override void Run(Application myApplication)
{

var task = myApplication.ActiveProject.ExecutionTasksFolder.NewChild((ObjectKind)431, (ObjectType)2433, false);
task.Attributes.FindById(AttributeId.Designation).Value = "Testaufgabe";
task.Store();

var cable = myApplication.ActiveProject.EquipmentFolder.NewChild(ObjectKind.Cable, ObjectType.CableUnspecified, false);
cable.Attributes.FindById(AttributeId.Designation).Value = "Testkabel";
cable.Store();

try
{
task?.SourceAssociations.Add((AssociationRole)146, cable);
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
throw;
}
}
}


Best regards
Matthias