.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Select Point From Modal Form

3 REPLIES 3
Reply
Message 1 of 4
scottocad
346 Views, 3 Replies

Select Point From Modal Form

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.
3 REPLIES 3
Message 2 of 4
Mikko
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
Message 3 of 4
scottocad
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?
Message 4 of 4
Mikko
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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost