Announcements
Autodesk Community will be read-only between April 26 and April 27 as we complete essential maintenance. We will remove this banner once completed. Thanks for your understanding
Announcements
We are currently migrating data within this board to improve the community. During this process, posting, replying, editing and other features are temporarily disabled. We sincerely apologize for any inconvenience caused and appreciate your understanding. Thank you for your patience and support.

Viewport label size and location

BobbyC.Jones
Advocate Advocate
3,182 Views
6 Replies
Message 1 of 7

Viewport label size and location

BobbyC.Jones
Advocate
Advocate

How can I adjust the location and size of a Viewport label?  This is what I've tried without success:

 

using (var trans = new Transaction(activeDoc))
{
    trans.Start("Reset Label");

    Outline labelOutline = newViewport.GetLabelOutline();

    labelOutline.MinimumPoint = desiredMinXyz;
    labelOutline.MinimumPoint = desiredMaxXyz;
                    
    trans.Commit();
}

 

 Thanks!

--
Bobby C. Jones
Reply
Reply
3,183 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable

Hi Bobby C. Jones ,

 

Did you try with different value in Outline.MaximumPoint and Outline.MinimumPoint ?

 

And for the size, this should have worked Outline.Scale (double scale) -> Scales the bounding box by given scale.

 

Code snippet in Jeremy's blog might be useful here -

http://thebuildingcoder.typepad.com/blog/2010/09/view-location-on-sheet.html

 

Does it help ?

Partha

Reply
Reply
0 Likes
Message 3 of 7

BobbyC.Jones
Advocate
Advocate

Hi Partha,

I've tried modifying both the Min & Max points and I've tried scaling the label outline to no avail.  The view label does not change size or location.

 

Jeremy's code does work to position views, but it doesn't address the labels.

 

 

        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            Document activeDoc = commandData.Application.ActiveUIDocument.Document;

            using (var trans = new Transaction(activeDoc))
            {
                trans.Start("Scale Viewport Label");

                ViewSheet activeSheet = commandData.Application.ActiveUIDocument.ActiveView as ViewSheet;

                Viewport firstViewPort = activeSheet.GetAllViewports().Select(activeDoc.GetElement).First() as Viewport;

                Outline firstViewPortLabelOutline = firstViewPort.GetLabelOutline();

                firstViewPortLabelOutline.Scale(2.0);

                trans.Commit();
            }

            return Result.Succeeded;
        }

 

 

 

 

        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            Document activeDoc = commandData.Application.ActiveUIDocument.Document;

            using (var trans = new Transaction(activeDoc))
            {
                trans.Start("Scale Viewport Label");

                ViewSheet activeSheet = commandData.Application.ActiveUIDocument.ActiveView as ViewSheet;

                Viewport firstViewPort = activeSheet.GetAllViewports().Select(activeDoc.GetElement).First() as Viewport;

                Outline firstViewPortLabelOutline = firstViewPort.GetLabelOutline();

                XYZ currentMinPoint = firstViewPortLabelOutline.MinimumPoint;
                XYZ currentMaxPoint = firstViewPortLabelOutline.MaximumPoint;

                XYZ newMinPoint = currentMinPoint + new XYZ(1, 1, 0);
                XYZ newMaxPoint = currentMaxPoint + new XYZ(1, 1, 0);

                firstViewPortLabelOutline.MinimumPoint = newMinPoint;
                firstViewPortLabelOutline.MaximumPoint = newMaxPoint;

                trans.Commit();
            }

            return Result.Succeeded;
        }

 

--
Bobby C. Jones
Reply
Reply
0 Likes
Message 4 of 7

Anonymous
Not applicable
 
HI BobbyC.Jones , Are you solved that problem, i still have same problem with you.I want to use API to move instance Label of viewport no need to edit family, in API has method ViewPort.GetLabelOutline, this method to get the Outline of Label of ViewPort, i think we must to have solution to set the Outline of Label, if not the method ViewPort.GetLabelOutline is no meaning.
P/s: i make a code to duplicate view and place duplicated view on new sheet with same location, everything is ok, just the location of label still not same location (because original label'location moved so duplicated viewport'label can not same).
Reply
Reply
0 Likes
Message 5 of 7

BobbyC.Jones
Advocate
Advocate
Sorry, I still have no solution to this problem.
--
Bobby C. Jones
Reply
Reply
0 Likes
Message 6 of 7

Revitalizer
Advisor
Advisor

Hi Bobby C. Jones and others,

 

seems that this thread's topic is similar to this thread's, since both are about modifications of the label:

 

http://forums.autodesk.com/t5/revit-api/move-title-of-a-viewport/td-p/5598602

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Reply
Reply
0 Likes
Message 7 of 7

miguelmachadoecosta
Advocate
Advocate
Reply
Reply
0 Likes