Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have some code that will center a title on a viewport in a sheet. It works just fine, but it requires that the user size the underline to the title before running the command. Is there a way I can get the width, so that I can automatically size the underline before centering it. I saw that geometry is part of element, but I haven't figured out how it works. This is the working code that I have.
//vp is the viewport I am editing
Outline boxOutline = vp.GetBoxOutline();
Outline labelOutline = vp.GetLabelOutline();
//The label position is equal to the centerpoint minus half the width of the title
double labelOffest = Math.Abs((labelOutline.MaximumPoint.X - labelOutline.MinimumPoint.X) / 2);
vp.LabelOffset = new XYZ(vp.GetBoxCenter().X - boxOutline.MinimumPoint.X - labelOffest, -0.040, 0);
Solved! Go to Solution.