- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am currently attempting to insert from file elements from a 2D detail View, much like the one provided by Revit. Except this one points directly to a library that my team has created for our specific Revit Details.
I have been able to successfully copy elements over to the Revit Project, however it creates a new detail view rather than inserting the elements into the Active view. The error I have is with the Transform method. When it is set to null or Transform.Identity it works (but creates a new detail view). When I attempt to insert a non-null Transform I get an error stating the transformation is not within the plane of the destination view.
Any suggestions would be appreciated on how I could correctly identify the plane/xyz coordinates.
using (Transaction tx = new Transaction(toView.Document, "Duplicate View Detailing"))
{
tx.Start();
//Set handler to skip the duplicate types dialog
CopyPasteOptions options = new CopyPasteOptions();
options.SetDuplicateTypeNamesHandler(new HideAndAcceptDuplicateTypeNamesHandler());
Transform transform = ElementTransformUtils.GetTransformFromViewToView(fromView, toView);
XYZ xYZ = transform.Origin;
xYZ = toView.Origin.Subtract(xYZ);
Transform trans = Transform.CreateTranslation(xYZ);
string message = "Difference: " + trans.Origin.ToString();
message += "\nSource: " + fromView.Origin.ToString();
message += "\nDestination: " + toView.Origin.ToString();
TaskDialog.Show("Translation", message);
// Copy the elements using transformation
ICollection<ElementId> copiedElements =
ElementTransformUtils.CopyElements(fromView, toCopy, toView, trans, options);
numberOfCopiedElements = copiedElements.Count;
// Set failure handler to skip any duplicate types warnings that are posted
FailureHandlingOptions failureOptions = tx.GetFailureHandlingOptions();
failureOptions.SetFailuresPreprocessor(new HidePasteDuplicateTypesPreprocessor());
tx.Commit(failureOptions);
}
Solved! Go to Solution.