Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Failure of using "Addcoping, Setcopings"

1 REPLY 1
Reply
Message 1 of 2
Anonymous
269 Views, 1 Reply

Failure of using "Addcoping, Setcopings"

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

}

1 REPLY 1
Message 2 of 2
Joe.Ye
in reply to: Anonymous

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community