Author Topic: Best way to ask for dimensions  (Read 1448 times)

0 Members and 1 Guest are viewing this topic.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Best way to ask for dimensions
« on: December 30, 2011, 01:33:15 PM »
Assuming you wanted to ask your user to provide the length and width of a rectangle, what would be the best way to ask and process this information?  For obvious reasons, asking the user to provide in inches as apposed to feet-inches is easier, but what if you wanted to give that option?


Second, is there a PromptDoubleXXX that would capture both or would it be easier to have 2?  I have done this so far
Code: [Select]

PromptDoubleOptions pdoL = new PromptDoubleOptions("Length: ");
pdoL.AllowNone = false;
pdoL.AllowZero = false;
PromptDoubleResult pdrL = ed.GetDouble(pdoL);


PromptDoubleOptions pdoW = new PromptDoubleOptions("Width: ");
pdoW.AllowNone = false;
pdoW.AllowZero = false;
PromptDoubleResult pdrW = ed.GetDouble(pdoW);



Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Jeff_M

  • King Gator
  • Posts: 4100
  • C3D user & customizer
Re: Best way to ask for dimensions
« Reply #1 on: December 30, 2011, 03:17:26 PM »
I'd use the GetDistance method in lieu of GetDouble. I'd also just re-use the PromptDistanceOptions:
Code: [Select]
            PromptDistanceOptions distOpt = new PromptDistanceOptions("Length?: ");
            distOpt.AllowNegative = false;
            distOpt.AllowNone = false;
            distOpt.AllowZero = false;
            PromptResult prL = ed.GetDistance(distOpt);
            distOpt.Message = "...Width? ";
            PromptResult prW = ed.GetDistance(distOpt);

fixo

  • Guest
Re: Best way to ask for dimensions
« Reply #2 on: December 30, 2011, 05:24:08 PM »
Thought this will be inresting for you too, value is pulled byRef
Code: [Select]
       Public Function GetDoubleOut(ByVal msg As String, ByRef dblnum As Double) As Boolean
            Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
            Dim pdo As New PromptDoubleOptions(msg)
            pdo.AllowNone = False
            pdo.UseDefaultValue = False

            Dim res As PromptDoubleResult
            res = ed.GetDouble(pdo)
            If res.Status <> PromptStatus.OK Then
                Return False
            End If
            dblnum = res.Value
            Return True

        End Function

Happy New Year, Commander and Jeff :))

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: Best way to ask for dimensions
« Reply #3 on: January 03, 2012, 08:33:42 AM »
Thanks Jeff and Fixo!  I will have a go at these today.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)