' View.DrawGrid ' Creates grid lines and/or labels at specified interval inside bounding box ' using the default line and/or text symbol ' Arguments: BndBox = Grid Bounding Box (Rect) ' Int = Grid Interval (Number) ' DrawLine = Draw Grid Lines (Boolean) ' DrawBox = Draw Grid Bounding Box (Boolean) ' DrawText = Draw Grid Labels (Boolean) BndBox = Self.Get(0) Int = Self.Get(1) DrawLine = Self.Get(2) DrawBox = Self.Get(3) DrawText = Self.Get(4) theView = av.GetActiveDoc G_list = theView.GetGraphics G_list.UnselectAll '**** find first gridline locations within bounding box xmin = BndBox.GetLeft ymin = BndBox.GetBottom xmax = BndBox.GetRight ymax = BndBox.GetTop gxmin = xmin + (Int / 10) gymin = ymin + (Int / 10) gxmax = xmax - (Int / 10) gymax = ymax - (Int / 10) if (gxmin >= 0) then xfirst = gxmin - (gxmin mod Int) + Int else xfirst = gxmin + (gxmin.Abs mod Int) end if (gymin >= 0) then yfirst = gymin - (gymin mod Int) + Int else yfirst = gymin + (gymin.Abs mod Int) end '**** draw grid lines if (DrawLine) then i = xfirst while (i < gxmax) p1 = i@ymin p2 = i@ymax theLine = Line.Make(p1,p2) theGraphicShape = GraphicShape.Make(theLine) G_list.Add(theGraphicShape) i = i + Int end i = yfirst while (i < gymax) p1 = xmin@i p2 = xmax@i theLine = Line.Make(p1,p2) theGraphicShape = GraphicShape.Make(theLine) G_list.Add(theGraphicShape) i = i + Int end end '**** draw bounding box if (DrawBox) then theGraphicShape = GraphicShape.Make(BndBox) G_list.Add(theGraphicShape) end '**** draw grid labels if (DrawText) then '**** draw bottom labels prefix = "E" i = xfirst while (i < gxmax) thePoint = i@ymin theText = prefix+i.AsString theGraphicText = GraphicText.Make(theText,thePoint) theGraphicText.SetAngle(90) theGraphicText.SetVisible(TRUE) theGraphicText.SetSelected(FALSE) G_list.Add(theGraphicText) dx = theGraphicText.GetBounds.GetWidth.Negate dy = 0 theGraphicText.Offset(dx@dy) theSymbol = theGraphicText.GetSymbol theView.GetDisplay.Hookupsymbol(theSymbol) i = i + Int end '**** draw left labels prefix = "N" i = yfirst while (i < gymax) thePoint = xmin@i theText = prefix+i.AsString theGraphicText = GraphicText.Make(theText,thePoint) theGraphicText.SetVisible(TRUE) theGraphicText.SetSelected(FALSE) G_list.Add(theGraphicText) theSymbol = theGraphicText.GetSymbol theView.GetDisplay.Hookupsymbol(theSymbol) i = i + Int end '**** draw top labels edge = "TOP" prefix = "E" i = xfirst while (i < gxmax) thePoint = i@ymax theText = prefix+i.AsString theGraphicText = GraphicText.Make(theText,thePoint) theGraphicText.SetAngle(90) theGraphicText.SetVisible(TRUE) theGraphicText.SetSelected(FALSE) G_list.Add(theGraphicText) dx = theGraphicText.GetBounds.GetWidth.Negate dy = theGraphicText.GetBounds.GetHeight.Negate theGraphicText.Offset(dx@dy) theSymbol = theGraphicText.GetSymbol theView.GetDisplay.Hookupsymbol(theSymbol) i = i + Int end '**** draw right labels prefix = "N" i = yfirst while (i < gymax) thePoint = xmax@i theText = prefix+i.AsString theGraphicText = GraphicText.Make(theText,thePoint) theGraphicText.SetVisible(TRUE) theGraphicText.SetSelected(FALSE) G_list.Add(theGraphicText) dx = theGraphicText.GetBounds.GetWidth.Negate dy = 0 theGraphicText.Offset(dx@dy) theSymbol = theGraphicText.GetSymbol theView.GetDisplay.Hookupsymbol(theSymbol) i = i + Int end end theView.GetDisplay.InvalidateRect(BndBox) av.GetProject.SetModified(TRUE) return nil