Problem by PromptResult in combi of getDistance

Problem by PromptResult in combi of getDistance

jan_tappenbeck
Collaborator Collaborator
208 Views
1 Reply
Message 1 of 2

Problem by PromptResult in combi of getDistance

jan_tappenbeck
Collaborator
Collaborator

Hi

 

this post is in connection to https://forums.autodesk.com/t5/net/getdistance-in-combination-of-using-a-rubber-band/td-p/11553064.

 

my code is currently

 

Dim Radius_1 As Double = 10.0
Dim pDistOpts_1 As PromptDistanceOptions = New PromptDistanceOptions(vbLf &
												String.Format("Radius 1 <{0}>: ", Radius_1.ToString("0.000"))) With {.AllowNone = True,
																													 .BasePoint = Point_1,
																													 .UseBasePoint = True,
																													 .UseDashedLine = True,
																													 .Only2d = True}

Dim pStrRes_1 As PromptResult = AcEditor.GetDistance(pDistOpts_1)

Select Case pStrRes_1.Status
	Case PromptStatus.OK ' der erfasste Abstand
		'Radius_1 = pStrRes_1.
		Dim Value_1 As String = pStrRes_1.StringResult

		If IsNumeric(Value_1) = True Then
			Radius_1 = Math.Abs(CDbl(Value_1))
		Else
			_AcLog.Write("keine gültige nummerische Eingabe für Punkt 1!")
			Exit Sub
		End If


	Case PromptStatus.None ' hier wird die Vorgabe übernommen


	Case Else 'bevor es zu einem Fehler kommt
		Exit Sub
End Select

till line 11 everything is ok.

 

but then when i want to access to the result pStrRes_1.StringResult will be nothing and in context-menu there is a property value.

 

2022-11-16_07h04_47.png

 

but when i code in ide pStrRes_1.value i get the message "value is not a member of PromptResult" !

 

i did not understand....

 

regards Jan

 

 

0 Likes
209 Views
1 Reply
Reply (1)
Message 2 of 2

_gile
Consultant
Consultant

Hi,

 

The following code should suit your needs. It also uses the PromptDistanceOptions.DefaultValue property so that the PromptDistanceResult.Status cannot be anything else than OK or Cancel.

If PromptDistanceResult.Status equals OK, the PromptDistanceResult.Value is always a double.

 

            var distanceOptions = new PromptDistanceOptions("\nRadius 1:")
            {
                AllowNone = true,
                BasePoint = point1,
                UseBasePoint = true,
                UseDashedLine = true,
                Only2d = true,
                DefaultValue = radius1,
                UseDefaultValue = true
            };
            var distanceResult = ed.GetDistance(distanceOptions);

            // the PromptDistanceResult.Status is either OK or Cancel
            switch (distanceResult.Status)
            {
                case PromptStatus.OK:
                    radius1 = distanceResult.Value; // this value is always a double
                    break;
                default:
                    return;
            }


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes