internal void UpdatePoints(PointMeasurements?pm, Util.VType vtype, XYZ normal, XYZ origin, string planeName, Units units) { if (pm == null) { ClearText(); lblMessage.Content = "Please Select Two Points to Measure"; return; } lblMessage.Content = "View is a " + vtype.VTName; if (planeName != null) { lblMessage.Content += " plane name: " + planeName; } lblP1X.Content = FormatLengthNumber(pm.Value.P1.X, units); lblP1Y.Content = FormatLengthNumber(pm.Value.P1.Y, units); lblP1Z.Content = FormatLengthNumber(pm.Value.P1.Z, units); lblP2X.Content = FormatLengthNumber(pm.Value.P2.X, units); lblP2Y.Content = FormatLengthNumber(pm.Value.P2.Y, units); lblP2Z.Content = FormatLengthNumber(pm.Value.P2.Z, units); lblDistX.Content = FormatLengthNumber(pm.Value.delta.X, units); lblDistY.Content = FormatLengthNumber(pm.Value.delta.Y, units); lblDistZ.Content = FormatLengthNumber(pm.Value.delta.Z, units); lblDistXY.Content = FormatLengthNumber(pm.Value.distanceXY, units); lblDistXZ.Content = FormatLengthNumber(pm.Value.distanceXZ, units); lblDistYZ.Content = FormatLengthNumber(pm.Value.distanceYZ, units); lblDistXYZ.Content = FormatLengthNumber(pm.Value.distanceXYZ, units); lblWpOriginX.Content = FormatLengthNumber(origin.X, units); lblWpOriginY.Content = FormatLengthNumber(origin.Y, units); lblWpOriginZ.Content = FormatLengthNumber(origin.Z, units); lblWpNormalX.Content = $"{normal.X:F4}"; lblWpNormalY.Content = $"{normal.Y:F4}"; lblWpNormalZ.Content = $"{normal.Z:F4}"; }
public bool Measure(UIApplication uiApp) { SetInfo(uiApp); _form = new FormDlxMeasure(); View av = _doc.ActiveView; Util.VType vtype = GetViewType(av); if (vtype.VTCat == Util.VTtypeCat.OTHER) { return(false); } Plane plane; // get the current sketch / work plane plane = av.SketchPlane?.GetPlane(); if (plane == null && (vtype.VTCat == Util.VTtypeCat.D2_WITHPLANE || vtype.VTCat == Util.VTtypeCat.D3_WITHPLANE)) { using (Transaction t = new Transaction(_doc, "measure points")) { t.Start(); plane = Plane.CreateByNormalAndOrigin( _doc.ActiveView.ViewDirection, new XYZ(0, 0, 0)); SketchPlane sp = SketchPlane.Create(_doc, plane); av.SketchPlane = sp; t.Commit(); } } MeasurePointsSetup(av, vtype); return(true); }
private static bool MeasurePoints(XYZ workingOrigin, Util.VType vtype, string planeName) { bool again = true; PointMeasurements?pm; while (again) { pm = GetPts(workingOrigin); if (pm != null) { _form.UpdatePoints(pm, vtype, planeName); DialogResult result = _form.ShowDialog(); switch (result) { case DialogResult.Cancel: again = false; break; } } else { TaskDialog td = new TaskDialog("No Points Selected"); td.MainIcon = TaskDialogIcon.TaskDialogIconWarning; td.MainInstruction = "Please select two points to proceed"; td.CommonButtons = TaskDialogCommonButtons.Cancel | TaskDialogCommonButtons.Retry; td.DefaultButton = TaskDialogResult.Retry; TaskDialogResult result = td.Show(); if (result == TaskDialogResult.Cancel) { break; } } } return(true); }
private static bool MeasurePointsSetup(View av, Util.VType vtype) { bool again = true; XYZ normal = XYZ.BasisZ; XYZ workingOrigin = XYZ.Zero; XYZ actualOrigin = XYZ.Zero; if (RvtLibrary.IsPlaneOrientationAcceptable(_uiDoc)) { Plane p = av.SketchPlane?.GetPlane(); string planeName = av.SketchPlane?.Name ?? "No Name"; if (p != null) { normal = p.Normal; actualOrigin = p.Origin; if (vtype.VTSub != VTypeSub.D3_VIEW) { workingOrigin = p.Origin; } } return(MeasurePoints(workingOrigin, vtype, planeName)); } else { TaskDialog td = new TaskDialog("Workplane Orientation"); td.MainIcon = TaskDialogIcon.TaskDialogIconWarning; td.MainInstruction = "The angle of the Worlplane is too steep in this view. " + "Please adjust the Workplane's orientation or " + "make a different Workplane active in order to proceed"; td.CommonButtons = TaskDialogCommonButtons.Cancel; td.DefaultButton = TaskDialogResult.Cancel; TaskDialogResult result = td.Show(); } return(false); }