Jump to content

Recommended Posts

Posted

Hi

i got a problem what should i do if i want to go through that lines when the user select nothing. It would be nice if lCmd.GetEntity(entOpt) returns nothing or something in that case

 

           
Dim lCmd As Editor = Application.DocumentManager.MdiActiveDocument.Editor
Dim entOpt As PromptEntityOptions = New PromptEntityOptions("Select Line")
    Dim line As PromptEntityResult = lCmd.GetEntity(entOpt)

Posted

Hi

 

Have a look at PromptEntityOptions properties

If you don't want to allow the user to select nothing, set the entOpt.AllowNone property to false.

 

If you want to do something in case the user select nothing, set it to true and test if the PromptEntityResult.Status equals PromptStatus.None.

Posted

i wrote some code using your advice but somehow it wont work same situation as before

          Dim entOpt As PromptEntityOptions = New PromptEntityOptions("Select Line")
           entOpt.AllowNone = True
           Dim line2 As PromptEntityResult = lCmd.GetEntity(entOpt)
           If line2.Status = PromptStatus.None Then
               lCmd.WriteMessage("you select nothing")
           End If

Posted

Hi,

 

Not certain about VB syntax

Dim entOpt As PromptEntityOptions = New PromptEntityOptions("Select Line")
           entOpt.AllowNone = True
           Dim line2 As PromptEntityResult = lCmd.GetEntity(entOpt)
           If line2.Status = PromptStatus.None Then
               lCmd.WriteMessage("you select nothing")
           End If
           Else If line2.Status = PromptStatus.OK Then
               ' Do your stuff here
           End If

Here's a more complete C# example

 

Point3d ucsPt1, ucsPt2, ucsPt3;
PromptPointOptions ppo;
PromptPointResult ppr;
double width = getWidth();
bool loop = true;
ed.WriteMessage("\nCurrent with = " + width.ToString());
do
{
   ppo = new PromptPointOptions("\nSpecify a point or [Width]<W>:", "Width");
   ppo.AllowNone = true;
   ppr = ed.GetPoint(ppo);
   if (ppr.Status == PromptStatus.Keyword || ppr.Status == PromptStatus.None)
   {
       PromptDistanceOptions pdo = new PromptDistanceOptions("\nSpecify the width: ");
       pdo.AllowNegative = false;
       pdo.AllowNone = false;
       pdo.AllowZero = false;
       PromptDoubleResult pdr = ed.GetDistance(pdo);
       if (pdr.Status == PromptStatus.OK)
       {
           width = pdr.Value;
           setWidth(width);
       }
       else
           return;
   }
   else if (ppr.Status == PromptStatus.OK)
   {
       ucsPt1 = ppr.Value;
       loop = false;
   }
   else
       return;
} while (loop);

Posted

When i debug that code the debuger stuck on the line so there is no chance to check the status

Dim line2 As PromptEntityResult = lCmd.GetEntity(entOpt)

i thing that i have to figure out something else ;p

Posted

I can't say why it bugs.

I tried this snippet, it works fine:

If the user click on an entity the command line displays "Entity selected"

If the user click an empty space the command line displays: "Pas de sélection" (which means "None selection") and loops : "Select a line: "

If the use right click or type Enter the command line displays "None entity selected".

 

PromptEntityOptions entOpt = new PromptEntityOptions("\nSelect a line: ");
entOpt.AllowNone = true;
PromptEntityResult line2 = ed.GetEntity(entOpt);
if (line2.Status == PromptStatus.None)
   ed.WriteMessage("\nNone entity selected");
else if (line2.Status == PromptStatus.OK)
   ed.WriteMessage("\nEntity selected");

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...