Failure of using "Addcoping, Setcopings"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The function is used to Coping the structure framing (steel). However, the program is fail.
Could anyone help me to check out the problem? Thanks!
public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
try
{
//Document document = commandData.Application.ActiveUIDocument.Document;
UIApplication app = commandData.Application;
Document document = app.ActiveUIDocument.Document;
UIDocument uidoc = new UIDocument(document);
SelElementSet collection = uidoc.Selection.Elements;
Reference ref1 = app.ActiveUIDocument.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element, "Please pick a beam1");
Element elem1 = ref1.Element;
Reference ref2 = app.ActiveUIDocument.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element, "Please pick a beam2");
Element elem2 = ref2.Element;
FamilyInstance beam = elem1 as FamilyInstance;
FamilyInstance bar = elem2 as FamilyInstance;
if (bar != null && beam != null)
{
TaskDialog.Show("erreer", "start coping" + "bar" + collection.Size + "beam "+ elem1.Id);
beam.AddCoping(bar);
}
else
{
TaskDialog.Show("erreer", "no inst." );
}
TaskDialog.Show("erreer", "elem1" +elem1.Id);
return Autodesk.Revit.UI.Result.Succeeded;
}
catch (Exception e)
{
TaskDialog.Show("erreer", "fail");
return Autodesk.Revit.UI.Result.Failed;
}
}