Moving a color fill legend instance

Moving a color fill legend instance

Anonymous
Not applicable
598 Views
3 Replies
Message 1 of 4

Moving a color fill legend instance

Anonymous
Not applicable

The location object of a ColorFillLegend instance (BuiltInCategory.OST_ColorFillLegends) returns null.

While the bounding box is valid and could be used to determine the transformation, using the "ElementTransformUtils.MoveElement" function doesn't seem to change the position. No exception is thrown.

 

Is it even possible ?

0 Likes
599 Views
3 Replies
Replies (3)
Message 2 of 4

jeremytammik
Autodesk
Autodesk

Dear Wouter,

 

Thank you for your query.

 

I am not sure whether it is possible or not.

 

Can you move it manually through the user interface?

 

In general, if a feature is not available in the Revit product manually through the user interface, then the Revit API will not provide it either.

 

As usual, you should set up the required situation manually through the user interface first and then explore it using RevitLookup, the BipChecker, the interactive Python or Ruby shell, and any other tools that you find useful to detect the differences.

 

http://thebuildingcoder.typepad.com/blog/2013/11/intimate-revit-database-exploration-with-the-python...

 

That will tell you how to achieve your manual adjustment programmatically as well, if you are lucky and it is possible at all.

 

There may be several different database elements related to each other, and the displacement may be stored in a different one than the one you currently are looking at.

 

On the other hand, some Revit elements do indeed not have an API-accessible location at all.

 

Please do let us know how you end up solving this, since it will certainly be of interest to others as well. Thank you!

 

I hope this helps.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 4

Anonymous
Not applicable

Well I found the solution by using the Location.Move function.

Before I tried to get the LocationPoint from the location object which always returns null, the solution was easier as I'd think.

 

            if (E.ViewSpecific)
            {
                ElementId OwnerID = E.OwnerViewId;
                // Legend belongs to this view...
                if (OwnerID == OnView.Id)
                {
                    BoundingBoxXYZ Box = E.get_BoundingBox(OnView);
                    XYZ Current = new XYZ(Box.Min.X, Box.Max.Y, 0);

                    Location Loc = E.Location;
                    if (Loc != null)
                    {
                        XYZ Mover = LP - Current;
                        Loc.Move(Mover);
                    }

                    return true;

                }
            }
Message 4 of 4

jeremytammik
Autodesk
Autodesk

Dear Wouter,

 

Thank you very much for your nice clean solution.

 

I was not aware that Location.Move works even if Location cannot be cast to a point or a curve.

 

Very good to know.

  

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes