Moving Multi Segment Dimension - MoveElement

Moving Multi Segment Dimension - MoveElement

mark.gouveia
Contributor Contributor
845 Views
5 Replies
Message 1 of 6

Moving Multi Segment Dimension - MoveElement

mark.gouveia
Contributor
Contributor

I am trying to move a multi-segment group of dimensions as show in the figure below using this general code.

 

When run nothing happens and I don't get any errors. It just completes the command and keeps going. I must be missing something fundamental,  but there is so little to change I just can't figure out what I am missing.

 

Element lastdime = GetLastElement(uidoc);
Dimension lastdim = lastdime as Dimension;
ElementId lastdimid = lastdim.GetTypeId();

Line dimLine = lastdim.Curve as Line;
XYZ dimEnd = dimLine.Origin;
XYZ temp = new XYZ(0, 10, 0);
XYZ Shift = dimEnd + temp;

using (Transaction tx = new Transaction(doc))
{
  tx.Start("Move Dimension Above Pipe");
  ElementTransformUtils.MoveElement(doc, lastdimid, Shift);
  tx.Commit();
}
 

Capture.PNG

0 Likes
Accepted solutions (1)
846 Views
5 Replies
Replies (5)
Message 2 of 6

jeremy_tammik
Alumni
Alumni

Maybe the dimension is 100% defined by other constraints that are not affected by your call to MoveElement. So, you tell it to move, it moves, and then it immediately updates to fulfil its constraints, which put it right back into the original position. Have you tried moving it manually through the end user interface and analysing what modifications that causes and are actually stored in the database to make the movement persistent?

  

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

mark.gouveia
Contributor
Contributor

Appreciate the simple trouble shooting idea. I believe only the 'line' inside the dimension has changed when I use the REVIT Lookup Addin to investigate. See breakdown below:

 

Dimension, Properties, Curve

Line.Origin ( 1, 1, 8 )<-- BEFORE
Line.Origin ( 1, 2, 8 ) <-- AFTER

 

Do I need to move the Curve/Line inside the dimension similar to the following? I am currently getting a C# error of "The input curve is not bound" on the very first line. Not sure how else I can get the end of the dimension line/curve to test the rest of it.

 

XYZ pt1 = dimLine.GetEndPoint(0);
XYZ pt2 = dimLine.GetEndPoint(1);
pt1 = new XYZ(pt1.X, pt1.Y + 10, pt1.Z);
pt2 = new XYZ(pt2.X, pt2.Y + 10, pt2.Z);
Line newLine = Line.CreateBound(pt1, pt2);
lastdim.Curve = newLine;

 

 

0 Likes
Message 4 of 6

RPTHOMAS108
Mentor
Mentor

I believe using ElementTransformUtils would be like trying to move the whole dimension with the move command rather than dragging the dimension line (such dragging features would not have equivalents in the API). So if you can not find a property on the class object to adjust then you'll have to recreate the dimension using the reference collection and a new line location, then delete the old dimension.

 

0 Likes
Message 5 of 6

mark.gouveia
Contributor
Contributor
Accepted solution

That is making more sense to me with the additional explanation.

 

For reference this previous post had me optimistic that I could just move the dimension. But it is unclear that the solution actual worked based upon our conversation.

 

 

Also in doing some more digging, I found this post which moves internal point to adjust the dimension. I will be trying this option later tonight and report on what works. 

 

dim.Location.Move(point);

 

0 Likes
Message 6 of 6

mark.gouveia
Contributor
Contributor

Confirmed - To move a dimension you must move the location point inside.

 

Appreciate the support in getting me pointed in the correct direction.

0 Likes