<?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: Vector problem in CopyElements in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/vector-problem-in-copyelements/m-p/9043300#M39649</link>
    <description>&lt;P&gt;thanks it helps.&lt;/P&gt;&lt;P&gt;I have a one more question. Is there a way to make sure a value of XYZtransaction_vector.Z is always positive? I can't manipulate it like a list.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 24 Sep 2019 12:18:50 GMT</pubDate>
    <dc:creator>lavicka.milan</dc:creator>
    <dc:date>2019-09-24T12:18:50Z</dc:date>
    <item>
      <title>Vector problem in CopyElements</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/vector-problem-in-copyelements/m-p/9042318#M39647</link>
      <description>&lt;P&gt;&lt;SPAN&gt;hi i'm new in Revit API. I am trying to copy rebars from one wall to another above. It works fine but I have a problem with vector in Copy Elements methods. I thing it gives me normalized vector and i can't thing how to get vector as point without normalize function.&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt; def _rebars(self):
        rebars = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rebar).\
                WhereElementIsNotElementType()
        rebarlist = list()
        for rebar in rebars:
            rebar_host_id = rebar.GetHostId()
            if rebar_host_id == self.obj1.Id:
                rebarlist.append(rebar.Id)
                self.itemlist = List[ElementId](rebarlist)
                            
    
    def _vector(self):
        point_obj1 = self.obj1.Location.Curve.GetEndPoint(0)
        point_obj2 = self.obj2.Location.Curve.GetEndPoint(0)
        self.line = Line.CreateUnbound(point_obj1,point_obj2).Direction
        self.line2 = (point_obj1-point_obj2).Normalize()
        print(point_obj1,point_obj2)
        print(self.line)
        print(self.line2)

    def _rcopy(self):
        self._rebars()
        self._vector()
        t = Transaction(doc,"Copy Rebars")
        t.Start()
        newrebars = ElementTransformUtils.CopyElements(doc,self.itemlist,self.line)
        t.Commit()&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="_vector OUTPUT.JPG" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/680213i92F4EED8E2B21E96/image-size/large?v=v2&amp;amp;px=999" role="button" title="_vector OUTPUT.JPG" alt="_vector OUTPUT.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2019 07:20:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/vector-problem-in-copyelements/m-p/9042318#M39647</guid>
      <dc:creator>lavicka.milan</dc:creator>
      <dc:date>2019-09-24T07:20:51Z</dc:date>
    </item>
    <item>
      <title>Re: Vector problem in CopyElements</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/vector-problem-in-copyelements/m-p/9042519#M39648</link>
      <description>&lt;P&gt;The overload of CopyElements that you are using takes a simple XYZ object argument to define the translation vector:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.revitapidocs.com/2020/0e533605-477f-dd92-2376-15ff7cd4411c.htm" target="_blank"&gt;https://www.revitapidocs.com/2020/0e533605-477f-dd92-2376-15ff7cd4411c.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can obtain that simply by subtracting the source point from the target point:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;  XYZ translation_vector 
    = target_element.Location.Curve.GetEndPoint(0)
      - source_element.Location.Curve.GetEndPoint(0)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2019 08:24:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/vector-problem-in-copyelements/m-p/9042519#M39648</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2019-09-24T08:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: Vector problem in CopyElements</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/vector-problem-in-copyelements/m-p/9043300#M39649</link>
      <description>&lt;P&gt;thanks it helps.&lt;/P&gt;&lt;P&gt;I have a one more question. Is there a way to make sure a value of XYZtransaction_vector.Z is always positive? I can't manipulate it like a list.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2019 12:18:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/vector-problem-in-copyelements/m-p/9043300#M39649</guid>
      <dc:creator>lavicka.milan</dc:creator>
      <dc:date>2019-09-24T12:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: Vector problem in CopyElements</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/vector-problem-in-copyelements/m-p/9043449#M39650</link>
      <description>&lt;P&gt;I don't quite understand why you ask, but of course you can always simply say something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;  XYZ v = a vector of some kind
  if 0 &amp;lt; v.Z:
    do something sensible&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2019 12:49:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/vector-problem-in-copyelements/m-p/9043449#M39650</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2019-09-24T12:49:18Z</dc:date>
    </item>
  </channel>
</rss>

