translation parameter in ElementTransformUtils.MoveElement?

translation parameter in ElementTransformUtils.MoveElement?

dirk.neethling
Advocate Advocate
1,559 Views
5 Replies
Message 1 of 6

translation parameter in ElementTransformUtils.MoveElement?

dirk.neethling
Advocate
Advocate

I want to move a selected Element to a new location (XYZ).

The translation parameter would be the vector from the origin to the new location, right?

The Element does not end up where expected.

Surely the new location should be (0.000000000, 0.227996169, 0.000000000), instead of (0.000000000, 0.227996169, 0.000000000)?

 

Code:

XYZ segment_midpoint_0 = locationCurve.Point;

ElementTransformUtils.MoveElement(doc, elem.Id, segment_midpoint_0.Negate());

XYZ segment_midpoint_1 = locationCurve.Point;

 

Result:

+  segment_midpoint_0 {(-31.409068165, 0.227996169, 0.000000000)} Autodesk.Revit.DB.XYZ
+  segment_midpoint_1 {(0.000000000, 0.227996169, 0.000000000)} Autodesk.Revit.DB.XYZ

0 Likes
1,560 Views
5 Replies
Replies (5)
Message 2 of 6

rosalesduquej
Alumni
Alumni

Hi Dirk,

 

I'm not sure I understand your post other than wanting to move an element to a new location. See code below.

 

 

public void MoveColumn(Autodesk.Revit.DB.Document document, FamilyInstance column)
{
        // get the column current location
        LocationPoint columnLocation = column.Location as LocationPoint;

        XYZ oldPlace = columnLocation.Point;

        // Move the column to new location.
        XYZ newPlace = new XYZ(10, 20, 30);
        ElementTransformUtils.MoveElement(document, column.Id, newPlace);

        // now get the column's new location
        columnLocation = column.Location as LocationPoint;
        XYZ newActual = columnLocation.Point;

        string info = "Original Z location: " + oldPlace.Z + 
                        "\nNew Z location: " + newActual.Z;

        TaskDialog.Show("Revit",info);
}

The two coordinates you mentioned seem exactly the same to me, unless my eyes are playing games to me today :). 

 

If you want to learn more about this check this link http://help.autodesk.com/view/RVT/2016/ENU/?guid=GUID-CD3B9A83-8DBC-418E-8099-D655AB3DA010

 

Cheers,

 

 

 

 

 

 

 

 

 

 

 



Jaime Rosales D.
Sr. Developer Consultant
Twitter | AEC ADN DevBlog
0 Likes
Message 3 of 6

dirk.neethling
Advocate
Advocate

Hello rosalesduquej,


thanks for the answer. I want to move the element back to the origin, hence

 

segment_midpoint_0.Negate()

 

On the end user side I noticed the Element is constrained along the X-Axis, ie it cannot move in Y or Z, only in X. I could not disable this "feature", either through the end-user controls or programmatically. I think that is the problem. That's why it only reacts to MoveElement in the X dimension.

 

Greetings, DIrk

0 Likes
Message 4 of 6

rosalesduquej
Alumni
Alumni

Hi dirk,

 

Ok remember that the API will mimic most of the functionality that the Revit UI is capable of. Being that said, based on your comment it seems like since you are not able to recreate your desire workflow from the end-user, most likely you will not be able to do it from the API. 

 

Cheers,



Jaime Rosales D.
Sr. Developer Consultant
Twitter | AEC ADN DevBlog
0 Likes
Message 5 of 6

dirk.neethling
Advocate
Advocate

I asked our superuser. He says that he copies a FamilyInstance (.rfa) into a project file (.rvt), and then attaches the reference point of that FamilyInstance to a line, or a curve.

So the problem is, that when I work in a .rvt file, where the FamilyInstance has already been attached to a line, then I can only move it along that line.

So I need to copy a FamilyInstance onto the new curve from a .rfa file. How do I do that?

0 Likes
Message 6 of 6

dirk.neethling
Advocate
Advocate

It's an adaptive FamilyInstance, so the question is irrelevant.

0 Likes