What I am doing is trying to place views on a sheet in Revit, either center page or center of one of four quadrants. But I have no experience building classes and I am struggling. I want to set all my properties upon initialization and they should not change once the pickbox outline has been drawn.
I can draw the pick box with ViewPortOutline(UIDocument UIDoc) and if I taskDialog a pickBox.Min.X will return its values
but when I get to the 'setXYZParameter' this locks me in the pickbox and will not move to the dialogbox
if I comment out the 'setXYZParameter' the code moves forward to the dialog box but the ReturnOutline() pickBox.Min.X is null because the 'setXYZParameter' is commented out.
public class ViewPortOutline { public static XYZ VP_CenterPoint { get; set; } public static XYZ VP_CenterPoint_Q1 { get; set; } public static XYZ VP_CenterPoint_Q2 { get; set; } public static XYZ VP_CenterPoint_Q3 { get; set; } public static XYZ VP_CenterPoint_Q4 { get; set; } private static UIDocument _UIDoc { get; set; } public static PickedBox pickBox { get; set; }
public ViewPortOutline(UIDocument UIDoc) { _UIDoc = UIDoc; PickBox(); } public static void PickBox() { Selection selection = _UIDoc.Selection; PickedBox pickBox = selection.PickBox(PickBoxStyle.Directional);//<<< Problem Here setXYZParameters(); } public static Outline ReturnOutline() { double minX = pickBox.Min.X;//<<< Null double minY = pickBox.Min.Y; double maxX = pickBox.Max.X; double maxY = pickBox.Max.Y; double sminX = Math.Min(minX, maxX); double sminY = Math.Min(minY, maxY); double smaxX = Math.Max(minX, maxX); double smaxY = Math.Max(minY, maxY); Outline outline = new Outline(new XYZ(sminX, sminY, 0), new XYZ(smaxX, smaxY, 0)); return outline; } public static void ReturnCenterPoints(UIDocument uidoc, Outline outline, out XYZ midpoint, out XYZ q1c, out XYZ q2c, out XYZ q3c, out XYZ q4c) { double outlineDiagonal = outline.GetDiagonalLength(); double outlineCenter = outline.GetDiagonalLength() / 2; XYZ bottomleft = (outline.MinimumPoint); XYZ topleft = new XYZ(outline.MinimumPoint[0], outline.MaximumPoint[1], 0); XYZ topright = (outline.MaximumPoint); XYZ bottomright = new XYZ(outline.MaximumPoint[0], outline.MinimumPoint[1], 0); midpoint = new XYZ((outline.MaximumPoint[0]) / 2, (outline.MaximumPoint[1]) / 2, 0); XYZ midleft = new XYZ(outline.MinimumPoint[0], outline.MaximumPoint[1] / 2, 0); XYZ midtop = new XYZ(outline.MaximumPoint[0] / 2, outline.MaximumPoint[1], 0); XYZ midright = new XYZ(outline.MaximumPoint[0], outline.MaximumPoint[1] / 2, 0); XYZ midbottom = new XYZ(outline.MaximumPoint[0] / 2, outline.MinimumPoint[1], 0); Outline q1 = new Outline(midpoint, topright); q1c = new XYZ( q1.MaximumPoint[0] / 2, q1.MaximumPoint[1] / 2, 0); Outline q2 = new Outline(midleft, midtop); q2c = new XYZ( q2.MaximumPoint[0] / 2, q2.MaximumPoint[1] / 2, 0); Outline q3 = new Outline(bottomleft, midpoint); q3c = new XYZ( q3.MaximumPoint[0] / 2, q3.MaximumPoint[1] / 2, 0); Outline q4 = new Outline(midbottom, midright); q4c = new XYZ( q4.MaximumPoint[0] / 2, q4.MaximumPoint[1] / 2, 0); } public static void setXYZParameters() { XYZ mp; XYZ q1c; XYZ q2c; XYZ q3c; XYZ q4c; ReturnCenterPoints(_UIDoc, ReturnOutline(), out mp, out q1c, out q2c, out q3c, out q4c); VP_CenterPoint = mp; VP_CenterPoint_Q1 = q1c; VP_CenterPoint_Q2 = q2c; VP_CenterPoint_Q3 = q3c; VP_CenterPoint_Q4 = q4c; }}
ViewPortOutline outline = new ViewPortOutline(uidoc); UnitSetup_Form form = new UnitSetup_Form(commandData); form.ShowDialog();
I didn't pass my arguments...
Programming is stressful, I spend more time debugging then creating...