PanHasan Posted September 15, 2009 Posted September 15, 2009 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) Quote
gile Posted September 16, 2009 Posted September 16, 2009 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. Quote
PanHasan Posted September 16, 2009 Author Posted September 16, 2009 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 Quote
gile Posted September 16, 2009 Posted September 16, 2009 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); Quote
PanHasan Posted September 16, 2009 Author Posted September 16, 2009 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 Quote
gile Posted September 16, 2009 Posted September 16, 2009 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"); Quote
Recommended Posts
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.