Error in ElementTransformUtils.CopyElements

Error in ElementTransformUtils.CopyElements

gbouletgercourt
Observer Observer
560 Views
1 Reply
Message 1 of 2

Error in ElementTransformUtils.CopyElements

gbouletgercourt
Observer
Observer

Hi,

 

I use the method to copy one element from a project to an empty document file (that will be used after for some things).

It works with some kind of elements, such as Wall, Floors, etc.

But with Pipes for exemple, the methode throws an InvalidOperationException exception.

 

Here is the code I use :

 

 

 ICollection<ElementId> types = inFamilySystem.GetValidTypes();

                    List<ElementId> collect = new List<ElementId>();

                    foreach (ElementId id in types)
                    {
                        ElementType eT = inDoc.GetElement(id) as ElementType;

                        if (eT != null)
                        {
                            if (XXX)
                            {
                                collect.Add(eT.Id);
                            }
                        }
                    }
                    collect.Add(inFamilySystem.Id);
                    CopyPasteOptions opts = new CopyPasteOptions();
                    opts.SetDuplicateTypeNamesHandler(new RevitSession.DuplicateHandler());
                    
                    ICollection<ElementId> copiedElems = ElementTransformUtils.CopyElements(inDoc, collect, newDoc, Transform.Identity, opts);

 

The exception throwed is an "InvalidOperationException", and I can not know why it failes. 

If the element was view-specific, it should be an "ArgumentException" exception no ? 

 

Do you have an idea ? 

 

Regards,

 

GBG

 

 

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

JimJia
Alumni
Alumni

Hi, 

 

Are the pipes connects with other, e.g. elbow\tee\cross fitting or pipe accessories? 

 

I couldn't find problem in your code, can you provide a reproducible case for it?


In order to explore this matter further, we will need to provide a minimal reproducible case for the development team to analyse in depth.


In order to understand exactly what you mean and be able to research possible reasons for the discrepancy between the observed and expected behaviour, they require: 
· A short exact description of what you are trying to achieve.
· The behavior you observe versus what you expect, and why this is a problem.
· A complete yet minimal Revit sample model to run a test in.
· A complete yet minimal macro embedded in the sample model or Visual Studio solution with add-in manifest that can be compiled, loaded, run and debugged with a single click to analyse its behavior live in the sample model.
· Detailed step-by-step instructions for reproducing the issue, e.g. which element to pick, what command to launch etc.
· http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 

 


Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
0 Likes