integrate options into getpoint-function

integrate options into getpoint-function

jan_tappenbeck
Collaborator Collaborator
1,828 Views
4 Replies
Message 1 of 5

integrate options into getpoint-function

jan_tappenbeck
Collaborator
Collaborator

Hi !

 

in Lisp it is possible to add options into getpoint-function by initget and the []-text. code looks like

 

 

(initget "Arc")
  (setq LAST_PT (GetPoint "\nSpecify cloud starting point or [Arc length]: "))


  (if (= LAST_PT "Arc")
    (progn
      (initget 6)
      (setq TMP (getdist (strcat "\nSpecify arc length <" (rtos ARC_DIST 2 3) ">: ")))
      (if TMP
        (Progn
          (setq ARC_DIST TMP)
          (setenv "AC_Bonus_Revcloud_Bulge" (rtos (/ ARC_DIST DIM_SCALE) 2))
        )
      )
      (setq LAST_PT (getpoint "\nSpecify cloud start point: "))
    ) ;;end STR "RADIUS" test
  )

now i want to make this in vb. net - but i did not found code!

 

could somebody help to me?

 

reagards Jan

0 Likes
1,829 Views
4 Replies
Replies (4)
Message 2 of 5

_gile
Consultant
Consultant

Hi,

 

Here's a C# equivalent.

You should be able to easily convert it to VB, but if you're starting with .NET, you'd rather learn C#...

 

var ppo = new PromptPointOptions("\nSpecify cloud starting point or [Arc length]: ", "Arc");
var ppr = ed.GetPoint(ppo);
if (ppr.Status == PromptStatus.Keyword)
{
    var pdo = new PromptDistanceOptions("\nSpecify arc length: ");
    pdo.AllowNegative = false;
    pdo.AllowZero = false;
    pdo.DefaultValue = arcDist;
    var pdr = ed.GetDistance(pdo);
    if (pdr.Status == PromptStatus.OK)
        arcDist = pdr.Value;
    ppr = ed.GetPoint("\nSpecify cloud starting point: ");
    if (ppr.Status != PromptStatus.OK)
        return;
}
if (ppr.Status != PromptStatus.OK)
    return;
var lastPoint = ppr.Value; 

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 5

jan_tappenbeck
Collaborator
Collaborator

hi !

 

this was very nice and helpfull - but i have a Little additional question: how would you integrate a secound (third) Option like:

 

Specify cloud starting point or [Arc length,option2,option3]:

 

regards Jan

0 Likes
Message 4 of 5

_gile
Consultant
Consultant

Hi,

 

Just add the options in the PromptPointOptions parameters and then, you can loop while prompt result status is Keyword and check for the prompt result StringResult value.

 

            // set message and keywords
            var ppo = new PromptPointOptions(
                "\nSpecify cloud starting point or [Arc length/Second option/Third option]: ", // message
                "Arc Second Third"); // keywords
            Point3d lastPoint;
            // loop while PromptResult.Status is Keyword
            while (true)
            {
                var ppr = ed.GetPoint(ppo);
                // user choosed an option
                if (ppr.Status == PromptStatus.Keyword)
                {
                    switch (ppr.StringResult)
                    {
                        case "Arc":
                            var pdo = new PromptDistanceOptions("\nSpecify arc length: ");
                            pdo.AllowNegative = false;
                            pdo.AllowZero = false;
                            pdo.DefaultValue = arcDist;
                            var pdr = ed.GetDistance(pdo);
                            if (pdr.Status == PromptStatus.OK)
                                arcDist = pdr.Value;
                            break;
                        case "Second":
                            // do what you have to do with "Second" option here
                            break;
                        case "Third":
                            // do what you have to do with "Third" option here
                            break;
                    }
                }
                // user specified a point
                else if (ppr.Status == PromptStatus.OK)
                {
                    lastPoint = ppr.Value;
                    break; // exit the loop
                }
                // user cancelled
                else
                {
                    return;
                }
            }

 

VB conversion

 

            ' set message and keywords
            Dim ppo As PromptPointOptions =
                New PromptPointOptions(vbLf & "Specify cloud starting point or [Arc length/ Second option/Third option]: ", "Arc Second Third")
            Dim lastPoint As Point3d
            ' loop while PromptResult.Status is Keyword
            While True
                Dim ppr As PromptPointResult = ed.GetPoint(ppo)
                If ppr.Status = PromptStatus.Keyword Then 'user choosed an option
                    Select Case ppr.StringResult
                        Case "Arc"
                            Dim pdo As PromptDistanceOptions = New PromptDistanceOptions(vbLf & "Specify arc length: ")
                            pdo.AllowNegative = False
                            pdo.AllowZero = False
                            pdo.DefaultValue = arcDist
                            Dim pdr As PromptDoubleResult = ed.GetDistance(pdo)
                            If pdr.Status = PromptStatus.OK Then
                                arcDist = pdr.Value
                            End If
                            Exit Select
                        Case "Second"
                            ' do what you have to do with "Second" option here
                            Exit Select
                        Case "Third"
                            ' do what you have to do with "Third" option here
                            Exit Select
                    End Select
                ElseIf ppr.Status = PromptStatus.OK Then 'user specified a point
                    lastPoint = ppr.Value
                    Exit While 'exit the loop
                Else 'user cancelled
                    Return
                End If
            End While

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 5 of 5

ceethreedee.com
Collaborator
Collaborator

I keep forgetting about

While (true)

thanks @_gile  

also a really good example for how to implement a simple "option" based command using c#

in for anyone is unsure what this means... it means "loop forever" so make sure you have all your exits covered!

Civil 3D 2025 / Infraworks 2025
Win 10 -DELL Precision Notebook 7680

Want FREE TOOLS! Come get my free productivity tools for civil 3d from the appstore here Ceethreedee tools
Or from my website below!
https://ceethreedee.com/ceethreedee-tools
0 Likes