<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: copyElement to same view, but different XYZ? in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/copyelement-to-same-view-but-different-xyz/m-p/9001356#M40118</link>
    <description>&lt;P&gt;Your list of&amp;nbsp;&amp;nbsp;chiller.Loc's contains 3D points. Every element in a 2D view needs to placed on the "sketchplane of the view". So you need to project the chiller.Loc unto the sketchplane.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;SketchPlane skPlane = doc.ActiveView.SketchPlane;
Plane plane = skPlane == null? Plane.CreateByNormalAndOrigin(XYZ.BasisZ,XYZ.Zero) : skPlane.GetPlane();
double distanceToPlane = plane.Normal.DotProduct(endpoint);
XYZ projectedPoint = endpoint.Subtract( plane.Normal.Multiply(distanceToPlane));
Transform transform = Transform.CreateTranslation(projectedPoint.Subtract(startpoint));&lt;/PRE&gt;</description>
    <pubDate>Mon, 02 Sep 2019 14:09:23 GMT</pubDate>
    <dc:creator>FAIR59</dc:creator>
    <dc:date>2019-09-02T14:09:23Z</dc:date>
    <item>
      <title>copyElement to same view, but different XYZ?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/copyelement-to-same-view-but-different-xyz/m-p/8995405#M40112</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to do something that seems pretty straightforward. Using C#.&lt;/P&gt;&lt;P&gt;I have a list of XYZ locations that I have pulled already from revit (the locations of chilled beams).&lt;/P&gt;&lt;P&gt;I am trying to now create OR copy OR duplicate 3 port valves and place them on/near to the XYZ.&lt;/P&gt;&lt;P&gt;I was hoping it would be as easy as looping through the list of XYZ and using&amp;nbsp;ElementTransformUtils.CopyElement(doc, valveId, chiller.Loc); (chiller.Loc being the XYZs we are looping through).&lt;/P&gt;&lt;P&gt;Unfortunately this method only copies the elements to the 3D view... and this is all done/needs to be done in a 2D schematic.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to use CopyElements(view, ICollection&amp;lt;id&amp;gt;, view, transform, CopyPasteOptions) (with last 2 null) which uses the activeView, and it correctly placed them on the right view, but unfortunately they are all being placed on top of each other. As the xyz isn't being used.. Not to mention I am only copying ONE element, so this seems a bit silly to use a collection of one element.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am fairly new to revit api, so please go easy on me &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hopefully I am looking for a way to use the CopyElement method and keep it on the correct view. If not, for a way to create a Transform to fill into the CopyElements method that will simply move the element to the right XYZs. Or perhaps a way to create the elements new?&lt;/P&gt;&lt;P&gt;Thanks for any help in advanced.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2019 13:56:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/copyelement-to-same-view-but-different-xyz/m-p/8995405#M40112</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-08-29T13:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: copyElement to same view, but different XYZ?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/copyelement-to-same-view-but-different-xyz/m-p/8995582#M40113</link>
      <description>&lt;P&gt;Why do you say it only works in a 3D view?&amp;nbsp; It should also work in a 2D view.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've used:&lt;/P&gt;&lt;P&gt;point1 = selection.PickPoint("Please pick a base point.");&lt;/P&gt;&lt;P&gt;point2 = selection.PickPoint("Please pick a point to place elements");&lt;/P&gt;&lt;P&gt;point3 = point2.Subtract(point1);&lt;/P&gt;&lt;P&gt;ICollection&amp;lt;ElementId&amp;gt; pastedIds = ElementTransformUtils.CopyElements(doc, selectedIds, point3);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in a routine almost exclusively for copy and paste for the last couple of years.&amp;nbsp; The only caveat is that to use PickPoint, a work plane has be be set for the current view.&amp;nbsp; If its not set, use the "Set Workplane" button on the Architecture ribbon panel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2019 14:57:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/copyelement-to-same-view-but-different-xyz/m-p/8995582#M40113</guid>
      <dc:creator>stever66</dc:creator>
      <dc:date>2019-08-29T14:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: copyElement to same view, but different XYZ?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/copyelement-to-same-view-but-different-xyz/m-p/8995612#M40114</link>
      <description>&lt;P&gt;What are point1-3? XYZs? What is selection?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using copyElements only copies my valves to a new blank 3D view... not to the current 2D view..&lt;/P&gt;&lt;P&gt;I also don't want to pick a point. I already have the XYZ that I want the valve to be placed on or near to.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried even using CopyElements to copy to the same view, then individually moving the elements with MoveElement but it does the same thing and moves them to the wrong view, because only doc is specified here.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2019 15:24:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/copyelement-to-same-view-but-different-xyz/m-p/8995612#M40114</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-08-29T15:24:06Z</dc:date>
    </item>
    <item>
      <title>Re: copyElement to same view, but different XYZ?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/copyelement-to-same-view-but-different-xyz/m-p/9000800#M40115</link>
      <description>&lt;P&gt;Bump, any help for this? :S&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2019 08:55:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/copyelement-to-same-view-but-different-xyz/m-p/9000800#M40115</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-09-02T08:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: copyElement to same view, but different XYZ?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/copyelement-to-same-view-but-different-xyz/m-p/9001038#M40116</link>
      <description>&lt;P&gt;the&amp;nbsp;&lt;SPAN&gt;CopyElements(view, ICollection&amp;lt;id&amp;gt;, view, transform, CopyPasteOptions)&amp;nbsp; method is the right one to use, only tramsform shouldn't be null.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;As in the UI , you copy from someplace to another. So you have to supply a translation / or transform to method. If you use [ transform = null ] however, Revit uses the Transform.Identity, resulting in a copy to the same place.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;To determine the translation:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;XYZ startpoint;  // is the location of the element you copy.
XYZ endpoint = chiller.Loc;			
Transform transform = Transform.CreateTranslation(endpoint.Subtract(startpoint));&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2019 11:15:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/copyelement-to-same-view-but-different-xyz/m-p/9001038#M40116</guid>
      <dc:creator>FAIR59</dc:creator>
      <dc:date>2019-09-02T11:15:39Z</dc:date>
    </item>
    <item>
      <title>Re: copyElement to same view, but different XYZ?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/copyelement-to-same-view-but-different-xyz/m-p/9001060#M40117</link>
      <description>&lt;P&gt;Hello thanks for your solution, I have attempted something similar already. The issue is I get an error when running the software:&lt;/P&gt;&lt;P&gt;---------------------------&lt;/P&gt;&lt;P&gt;---------------------------&lt;BR /&gt;Exception The transformation is not within the plane of the destination view.&lt;BR /&gt;Parameter name: additionalTransform&lt;BR /&gt;---------------------------&lt;/P&gt;&lt;P&gt;Please let me know if you understand this one?&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2019 11:43:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/copyelement-to-same-view-but-different-xyz/m-p/9001060#M40117</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-09-02T11:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: copyElement to same view, but different XYZ?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/copyelement-to-same-view-but-different-xyz/m-p/9001356#M40118</link>
      <description>&lt;P&gt;Your list of&amp;nbsp;&amp;nbsp;chiller.Loc's contains 3D points. Every element in a 2D view needs to placed on the "sketchplane of the view". So you need to project the chiller.Loc unto the sketchplane.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;SketchPlane skPlane = doc.ActiveView.SketchPlane;
Plane plane = skPlane == null? Plane.CreateByNormalAndOrigin(XYZ.BasisZ,XYZ.Zero) : skPlane.GetPlane();
double distanceToPlane = plane.Normal.DotProduct(endpoint);
XYZ projectedPoint = endpoint.Subtract( plane.Normal.Multiply(distanceToPlane));
Transform transform = Transform.CreateTranslation(projectedPoint.Subtract(startpoint));&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 Sep 2019 14:09:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/copyelement-to-same-view-but-different-xyz/m-p/9001356#M40118</guid>
      <dc:creator>FAIR59</dc:creator>
      <dc:date>2019-09-02T14:09:23Z</dc:date>
    </item>
    <item>
      <title>Re: copyElement to same view, but different XYZ?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/copyelement-to-same-view-but-different-xyz/m-p/9001436#M40119</link>
      <description>&lt;P&gt;Well this solution didn't error thankfully, once I had corrected the transform to&amp;nbsp;Transform.CreateTranslation(projectedPoint);&lt;/P&gt;&lt;P&gt;Unfortunately it still creates the new valves on the wrong view...&lt;/P&gt;&lt;P&gt;My code is as follows:&lt;/P&gt;&lt;PRE&gt;SketchPlane skPlane = doc.ActiveView.SketchPlane;
            Plane plane = skPlane == null ? Plane.CreateByNormalAndOrigin(XYZ.BasisZ, XYZ.Zero) : skPlane.GetPlane();
            double distanceToPlane = plane.Normal.DotProduct(endLoc);
            XYZ projectedPoint = endLoc.Subtract(plane.Normal.Multiply(distanceToPlane));
            Transform transform = Transform.CreateTranslation(projectedPoint); 
            ElementTransformUtils.CopyElements(doc.ActiveView, eleIds, doc.ActiveView, transform, null);&lt;/PRE&gt;&lt;P&gt;Images below of outcome, my schematic I want the valves to appear on (next to the chilled beams), and the new view they are being created in...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cooling System, Chilled Beams" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/673198iE3AA3DBCE3A43A53/image-size/large?v=v2&amp;amp;px=999" role="button" title="cooling.png" alt="Cooling System, Chilled Beams" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Cooling System, Chilled Beams&lt;/span&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Wrong View Copied..." style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/673199i1011B7133B5EB861/image-size/large?v=v2&amp;amp;px=999" role="button" title="wrong-view.png" alt="Wrong View Copied..." /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Wrong View Copied...&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2019 14:50:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/copyelement-to-same-view-but-different-xyz/m-p/9001436#M40119</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-09-02T14:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: copyElement to same view, but different XYZ?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/copyelement-to-same-view-but-different-xyz/m-p/9001487#M40120</link>
      <description>&lt;P&gt;PS. After logging out the projected point and the chilled beam xyz, there is a disparity in their Z coordinate as suspected... the projected point has 0 while the chilled beam has 0.9234232, I've tried just using the xyz from the chilled beam as the transformation but it does that same error as before, "The transformation is not within the plane of the destination view".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help and hope we can get to the bottom of this!&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2019 15:23:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/copyelement-to-same-view-but-different-xyz/m-p/9001487#M40120</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-09-02T15:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: copyElement to same view, but different XYZ?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/copyelement-to-same-view-but-different-xyz/m-p/9005100#M40121</link>
      <description>&lt;P&gt;Bump still require some assistance here if anyone has any idea? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 09:07:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/copyelement-to-same-view-but-different-xyz/m-p/9005100#M40121</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-09-04T09:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: copyElement to same view, but different XYZ?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/copyelement-to-same-view-but-different-xyz/m-p/9005301#M40122</link>
      <description>&lt;P&gt;I found the solution!&lt;/P&gt;&lt;P&gt;For anyone else having similar issues:&lt;/P&gt;&lt;P&gt;I found out that the location of the copied element (valve) was being added to the destination point (chilled beam) and therefore giving me a large coordinate (with higher Z coordinate) putting it on a seperate view entirely.&amp;nbsp;&lt;/P&gt;&lt;P&gt;After simply adding&amp;nbsp;XYZ combLoc = endLoc.Subtract(startLoc); and using this combLoc as the copyElement XYZ, it worked perfectly.&lt;/P&gt;&lt;P&gt;Thanks for anyones help,&lt;/P&gt;&lt;P&gt;Cheers.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 10:55:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/copyelement-to-same-view-but-different-xyz/m-p/9005301#M40122</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-09-04T10:55:25Z</dc:date>
    </item>
  </channel>
</rss>

