Insert 2D Elements from File

Insert 2D Elements from File

Anonymous
Not applicable
1,881 Views
2 Replies
Message 1 of 3

Insert 2D Elements from File

Anonymous
Not applicable

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

 

 

0 Likes
Accepted solutions (1)
1,882 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Accepted solution

I figured out why I was getting this error "Transformation not within destination view", for anyone who happens to have the same error. I would recommend double checking your Z coordinate value. This value was what was causing my error. It now works as expected with the adjustments I made.

Message 3 of 3

d6222300060
Contributor
Contributor

Hello,
I would like to know how did you fixed the error. I am also getting the same error. I have check the z axis as you mention and i set it to the same value but still coudn't solve the problem.

0 Likes