Is there a way, using the SDK, to get the the object another object is attached too. Also in reverse, is there a way to get a list of all objects attached to an object?
I have looked through all the methods and properties of parts\graphic component\project objects and can not find anything
Hey Simon, I am not quite sure, but it should be something with ChildInstances. What exactly do you need? The name or the object itself?
Hello
Use the class attachementCollection. Exemple :
Station station = Station.ActiveStation;
foreach (Attachment attach in stn.Attachments.ToArray())
{
MessageBox.Show( attach.AttachmentChild.ToString());
}
Didn’t realise that attachments are held at station level and not at component level. Two simple functions with linQ queries returning either the part you are attached to, or the children parts attached to the specified part fixed this problem
private ProjectObject GetAttachedParent(ProjectObject part)
{
Station station = Project.ActiveProject as Station;
var attachements = station.Attachments;
ProjectObject parent = (from a in attachements
where a.AttachmentChild.DisplayName == part.DisplayName
select a.AttachmentParent).FirstOrDefault();
return parent;
}
private IEnumerable GetAttachedChildren(ProjectObject part)
{
Station station = Project.ActiveProject as Station;
var attachements = station.Attachments;
var child = (from a in attachements
where a.AttachmentParent.DisplayName == part.DisplayName
select a.AttachmentChild);
return child;
}