Failure of using "Addcoping, Setcopings"

Failure of using "Addcoping, Setcopings"

Anonymous
Not applicable
573 Views
1 Reply
Message 1 of 2

Failure of using "Addcoping, Setcopings"

Anonymous
Not applicable

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;
}

}

0 Likes
574 Views
1 Reply
Reply (1)
Message 2 of 2

Joe.Ye
Alumni
Alumni

The code itself looks fine.

I am not sure the transaction mode you used.  It seems you used the automatic mode. If you used the manual model, then you need to start  a transaction, then do the coping. Finally sumbit the transaction.

If the transanction doesn;t help, any detailed information about the failure?

 



Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
0 Likes