Possible Bug in ElementTransformUtils.CopyElements?

Possible Bug in ElementTransformUtils.CopyElements?

alanmlevy
Contributor Contributor
377 Views
4 Replies
Message 1 of 5

Possible Bug in ElementTransformUtils.CopyElements?

alanmlevy
Contributor
Contributor

I'm running into a potential bug in Revit 2021.1.7 (confirmed in 2023, see below) when I'm using ElementTransformUtils.CopyElements(Document document, ICollection<ElementId> elementsToCopy, XYZ translation) to copy a List of walls - I have not verified if this occurs in other versions.

For some reason the first set of walls I'm copying is set at Level 2, however, the actual base constraint listed for the wall is at Level 1. After the first copy, all the other walls show up at the correct elevation.

 

alanmlevy_0-1680191311284.png

Actual code doing the copying is similar to this:

 

 

ICollection<ElementId> offsetList = offsetWallList;
XYZ direction = offsetDirection; // location for new copy
XYZ offset = direction; // offset vector           

for (int idx = 0; idx < quantity; idx++)
{
  ElementTransformUtils.CopyElements(rvtDoc, offsetList, direction);
  direction += offset;
}

 

 

 

It appears this also happens if I create a Level 3 and place the walls at Level 3 - the 1st set of walls copied shows up at Level 2 even though the base constraint is set to Level 3.

 

Note that if I use a transform, this doesn't seem to happen:

 

ICollection<ElementId> offsetList = offsetWallList;
XYZ direction = offsetDirection; // location for new copy
XYZ offset = direction; // offset vector           
Transform transform = Transform.CreateTranslation(direction);

for (int idx = 0; idx < quantity; idx++)
{
  ElementTransformUtils.CopyElements(rvtDoc, offsetList, rvtDoc, transform, new CopyPasteOptions());
  direction += offset;
  transform = Transform.CreateTranslation(direction);
}

 

 

So I'm not necessarily looking for a solution, but just wanted to report it.

 

Thanks,

Alan

378 Views
4 Replies
Replies (4)
Message 2 of 5

jeremy_tammik
Alumni
Alumni

Thank you for reporting it. Please let us know what it looks like in Revit 2023. Thank you!

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 3 of 5

alanmlevy
Contributor
Contributor

Yes, it looks like Revit 2023 also produces the same issue:

alanmlevy_0-1680272503089.png

 

0 Likes
Message 4 of 5

jeremy_tammik
Alumni
Alumni

Wow. Thank you very much for checking. Sorry to hear it persists. Can you put together a complete minimal reproducible case to share with the development team for analysis, local debugging, rectification and testing?

  

https://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

  

Thank you and happy weekend!

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 5 of 5

alanmlevy
Contributor
Contributor

Test Case attached.

 

Trying to achieve: Create several walls, saving walls element ids to a list, use that list to use ElementTransformUtils.CopyElements to copy the walls by a set offset several times in one direction (in this specific case, the x direction)

Expected Behavior: All walls are drawn at Level 1, with a height of 10 ft. 10 walls created, starting at 0,0, separated by 10 feet in the y direction. 10 more copies of those walls created in the -x direction, separated by 20 ft, centerline to centerline

Observed Behavior: The first set of walls copied using ElementTransformUtils.CopyElements is shown at Level 2,  however the Base Constraint in properties says Level 1 and there is no offset listed (so it should appear at Level 1). All other walls appear to be shown correctly.

alanmlevy_0-1680279176288.png

 

Directions: Place add-in (found in \TestCase\bin\Debug\net48 in zip file) in Addins folder for Revit 2023. Create a Revit project file (the specific file I created used Imperial Architectural Template and is included in zip). Run "Test Case" from Addins>External Tools drop-down.

0 Likes