.NET

Reply
Contributor
scottocad
Posts: 17
Registered: ‎10-28-2004
Message 1 of 4 (197 Views)

Select Point From Modal Form

197 Views, 3 Replies
06-10-2005 05:42 AM
Ahhh.. The dreaded modal form questions persist....

I need to have a form displayed that does not allow the user to interact with AutoCAD while it is visible. But, when they click a button to select objects, a point or whatever, the form will disappear, roll up, whatever, allow the user to perform the action, then reappear. I seen other questions like this and the responses on how to handle it but I think .NET is different.

Example:

Public Class Commands
<CommandMethod("MyCommand")> _
Public Sub MyCommand ()

Try
Dim Fp As New Form

Fp.ShowDialog()

'if I hide the form at anytime while it is displayed
'like when the user clicks a button to select a point
'this next line is executed and an exception is thrown
'saying: AutoCAD main window is invisible

MessageBox.show("You picked point: " fp.InsertionPoint)

Catch ex As Exception
Throw ex

End Try
End Sub


Public Class FormIP
Public Insertionpoint As String

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim pt As Double()
Me.Hide()

AcadTlc.ActiveDrawing.Utility.GetPoint(pt, "Select a point: ")

Insertionpoint = pt(0).ToString & ", " & pt(1).ToString

Me.Show()

End Sub
End Class


Any help would be greatly appreciated… Thanks in advance.
Distinguished Contributor
Mikko
Posts: 212
Registered: ‎10-03-2003
Message 2 of 4 (197 Views)

Re: Select Point From Modal Form

06-10-2005 06:27 AM in reply to: scottocad
Imports Autodesk.AutoCAD.Runtime

Public Class Class1

<CommandMethod("form1")> _
Public Sub form1()
Dim f1 As New Form1
f1.ShowDialog()
End Sub

End Class


========================================================================

Imports Autodesk.AutoCAD.DatabaseServices
Imports DBTransMan = Autodesk.AutoCAD.DatabaseServices.TransactionManager
Imports Autodesk.AutoCAD.EditorInput

Public Class Form1

Inherits System.Windows.Forms.Form

Dim Pt1 As New PromptPointOptions("Start: ")
Dim Pt2 As New PromptPointOptions("End: ")
Dim Pt1Res As PromptPointResult
Dim Pt2Res As PromptPointResult

Public Function drawLine()
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim tm As DBTransMan = db.TransactionManager
Dim myT As Transaction = tm.StartTransaction()
Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
Try
Pt1Res = ed.GetPoint(Pt1)
Pt2.BasePoint = Pt1Res.Value
Pt2.UseBasePoint = True
Pt2Res = ed.GetPoint(Pt2)
Dim line As New Line(Pt1Res.Value, Pt2Res.Value)
Dim bt As BlockTable = CType(tm.GetObject(db.BlockTableId, OpenMode.ForRead, False), BlockTable)
Dim btr As BlockTableRecord = CType(tm.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite, False), BlockTableRecord)
btr.AppendEntity(line)
tm.AddNewlyCreatedDBObject(line, True)
myT.Commit()
Catch ex As Exception
myT.Abort()
Finally
myT.Dispose()
End Try
End Function

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Visible = False
Call drawLine()
Me.Visible = True
TextBox1.Text = Pt1Res.Value.ToString
TextBox2.Text = Pt2Res.Value.ToString
End Sub

End Class
Contributor
scottocad
Posts: 17
Registered: ‎10-28-2004
Message 3 of 4 (197 Views)

Re: Select Point From Modal Form

06-10-2005 06:43 AM in reply to: scottocad
What files do I need to have referenced for this Import

Imports Autodesk.AutoCAD.EditorInput

Also, I am on ABS2005 Do I need 2006 for this to work?
Distinguished Contributor
Mikko
Posts: 212
Registered: ‎10-03-2003
Message 4 of 4 (197 Views)

Re: Select Point From Modal Form

06-10-2005 06:49 AM in reply to: scottocad
You need to reference both these:
acdbmgd.dll and acmdg.dll found the your CAD root directory.
I'm using 2006. I don't have 2005 loaded at the moment.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community