kunekainen Posted March 14, 2015 Share Posted March 14, 2015 Hi everyone; I am trying to write a plugin which asks me to select some lines and while doing it asks for a keyword to show some application forms. Here is the code I have written so far: Public Class Test Dim keyword as string = nothing Public Sub VOLengthtoBlock() Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument Dim db As Database = doc.Database Dim ed As Editor = doc.Editor tlinelen = 0 lenmultiplier = frmTools.TextBox1.Text Try Dim tr As Transaction = db.TransactionManager.StartTransaction() Using tr 'Select Objects Dim opt As New PromptSelectionOptions() opt.SetKeywords("[Options/Scale]", "Options Scale") opt.MessageForAdding = vbLf & "Select objects or " & opt.Keywords.GetDisplayString(True) AddHandler opt.KeywordInput, AddressOf onKeywordInput Select Case keyword Case "Options" frmTools.ShowDialog() Case "Scale" frmScale.ShowDialog() End Select Dim selres As PromptSelectionResult = Nothing selres = ed.GetSelection(opt) If selres.Status <> PromptStatus.OK Then Return End If Dim selset As SelectionSet = selres.Value 'Get Line Lengths If selres.Status = PromptStatus.OK Then For Each selobj As SelectedObject In selset Dim sent As Entity = DirectCast(tr.GetObject(selobj.ObjectId, OpenMode.ForWrite), Entity) If TypeOf sent Is Line Then Dim curline As Line = TryCast(sent, Line) tlinelen = tlinelen + curline.Length ElseIf TypeOf sent Is Polyline Then Dim curline As Polyline = TryCast(sent, Polyline) tlinelen = tlinelen + curline.Length End If Next tlinelen = CInt(tlinelen * lenmultiplier) bBlockLength = True VOMEditBlock() bBlockLength = False End If tr.Commit() End Using Catch ex As Autodesk.AutoCAD.Runtime.Exception MsgBox(ex.ToString) End Try End Sub Private Sub onKeywordInput(sender As Object, e As SelectionTextInputEventArgs) Me.keyword = e.Input End Sub End class It does not show my form until I exit from the sub and call it again. When i call it again, it just shows the form. I couldn't find the error. Please help. Quote Link to comment Share on other sites More sharing options...
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.