.NET
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Interactio n between Winform and Acad
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
90 Views, 2 Replies
10-08-2007 11:34 AM
Hi:
I have a winform which I invoke (as a modeless form) from within AutoCad. The User makes a selection in the listbox of the form and clicks on the button. On button click, the form is minimised and the user is prompted to Select a point on the screen upon which a MText and DbText are inserted (text is governed by the list box selection).
On clicking the form button, I have to click 3 times on the Autocad window to actually do the insertion (even though the selection for a point is prompted at the first click). I would like to transfer control from form to Autocad in 1 click. Below is my code:
Private Sub cmdInsert_Click(ByVal sender As System.Object, ByVal e _
As System.EventArgs) Handles cmdInsert.Click
Dim db As Database = Nothing
Dim promptPoint As PromptPointOptions = Nothing
Dim promptResult As PromptPointResult = Nothing
Dim ptMText As Point3d = Nothing
Dim ptDText As Point3d = Nothing
Dim ed As Editor = Nothing
Try
Me.TopMost = False
Me.TopLevel = False
HostApplicationServices.WorkingDatabase = Autodesk.AutoCAD.ApplicationServices _
.Application.DocumentManager.MdiActiveDocument.Dat abase
db = HostApplicationServices.WorkingDatabase
ed = Autodesk.AutoCAD.ApplicationServices.Application.D ocumentManager. _
MdiActiveDocument.Editor
'Prompt the user to select the point where the Material Item is to be imported.
promptPoint = New PromptPointOptions("Select the Insertion Point")
promptResult = ed.GetPoint(promptPoint)
If promptResult.Status = PromptStatus.OK Then
ptMText = promptResult.Value
'call the function to Create MText.
CreateMText(ptMText)
'call the function to Create DText. Calculate the position of the DText relative
'to the MTexy chosen.
ptDText = New Point3d(ptMText.X - 0.5625 * db.Dimscale, _
ptMText.Y - 0.25 * db.Dimscale, 0)
CreateDText(ptDText)
_SelectedNode = Nothing
Autodesk.AutoCAD.ApplicationServices.Application.U pdateScreen()
End If
Catch ex As Exception
MessageBox.Show(ex.Message & vbNewLine & ex.StackTrace)
Finally
Me.TopMost = True
Me.TopLevel = True
_SelectedNode = Nothing
db = Nothing
ed = Nothing
ptMText = Nothing
ptDText = Nothing
End Try
End Sub
I have a winform which I invoke (as a modeless form) from within AutoCad. The User makes a selection in the listbox of the form and clicks on the button. On button click, the form is minimised and the user is prompted to Select a point on the screen upon which a MText and DbText are inserted (text is governed by the list box selection).
On clicking the form button, I have to click 3 times on the Autocad window to actually do the insertion (even though the selection for a point is prompted at the first click). I would like to transfer control from form to Autocad in 1 click. Below is my code:
Private Sub cmdInsert_Click(ByVal sender As System.Object, ByVal e _
As System.EventArgs) Handles cmdInsert.Click
Dim db As Database = Nothing
Dim promptPoint As PromptPointOptions = Nothing
Dim promptResult As PromptPointResult = Nothing
Dim ptMText As Point3d = Nothing
Dim ptDText As Point3d = Nothing
Dim ed As Editor = Nothing
Try
Me.TopMost = False
Me.TopLevel = False
HostApplicationServices.WorkingDatabase = Autodesk.AutoCAD.ApplicationServices _
.Application.DocumentManager.MdiActiveDocument.Dat
db = HostApplicationServices.WorkingDatabase
ed = Autodesk.AutoCAD.ApplicationServices.Application.D
MdiActiveDocument.Editor
'Prompt the user to select the point where the Material Item is to be imported.
promptPoint = New PromptPointOptions("Select the Insertion Point")
promptResult = ed.GetPoint(promptPoint)
If promptResult.Status = PromptStatus.OK Then
ptMText = promptResult.Value
'call the function to Create MText.
CreateMText(ptMText)
'call the function to Create DText. Calculate the position of the DText relative
'to the MTexy chosen.
ptDText = New Point3d(ptMText.X - 0.5625 * db.Dimscale, _
ptMText.Y - 0.25 * db.Dimscale, 0)
CreateDText(ptDText)
_SelectedNode = Nothing
Autodesk.AutoCAD.ApplicationServices.Application.U
End If
Catch ex As Exception
MessageBox.Show(ex.Message & vbNewLine & ex.StackTrace)
Finally
Me.TopMost = True
Me.TopLevel = True
_SelectedNode = Nothing
db = Nothing
ed = Nothing
ptMText = Nothing
ptDText = Nothing
End Try
End Sub
*Tony Tanzillo
Re: Interactio n between Winform and Acad
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
10-08-2007 11:41 AM in reply to:
Saumitra
Don't minimize the form, hide it.
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com
wrote in message news:5743547@discussion.autodesk.com...
Hi:
I have a winform which I invoke (as a modeless form) from within AutoCad. The User makes a selection in the listbox of the form and clicks on the button. On button click, the form is minimised and the user is prompted to Select a point on the screen upon which a MText and DbText are inserted (text is governed by the list box selection).
On clicking the form button, I have to click 3 times on the Autocad window to actually do the insertion (even though the selection for a point is prompted at the first click). I would like to transfer control from form to Autocad in 1 click. Below is my code:
Private Sub cmdInsert_Click(ByVal sender As System.Object, ByVal e _
As System.EventArgs) Handles cmdInsert.Click
Dim db As Database = Nothing
Dim promptPoint As PromptPointOptions = Nothing
Dim promptResult As PromptPointResult = Nothing
Dim ptMText As Point3d = Nothing
Dim ptDText As Point3d = Nothing
Dim ed As Editor = Nothing
Try
Me.TopMost = False
Me.TopLevel = False
HostApplicationServices.WorkingDatabase = Autodesk.AutoCAD.ApplicationServices _
.Application.DocumentManager.MdiActiveDocument.Dat abase
db = HostApplicationServices.WorkingDatabase
ed = Autodesk.AutoCAD.ApplicationServices.Application.D ocumentManager. _
MdiActiveDocument.Editor
'Prompt the user to select the point where the Material Item is to be imported.
promptPoint = New PromptPointOptions("Select the Insertion Point")
promptResult = ed.GetPoint(promptPoint)
If promptResult.Status = PromptStatus.OK Then
ptMText = promptResult.Value
'call the function to Create MText.
CreateMText(ptMText)
'call the function to Create DText. Calculate the position of the DText relative
'to the MTexy chosen.
ptDText = New Point3d(ptMText.X - 0.5625 * db.Dimscale, _
ptMText.Y - 0.25 * db.Dimscale, 0)
CreateDText(ptDText)
_SelectedNode = Nothing
Autodesk.AutoCAD.ApplicationServices.Application.U pdateScreen()
End If
Catch ex As Exception
MessageBox.Show(ex.Message & vbNewLine & ex.StackTrace)
Finally
Me.TopMost = True
Me.TopLevel = True
_SelectedNode = Nothing
db = Nothing
ed = Nothing
ptMText = Nothing
ptDText = Nothing
End Try
End Sub
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com
Hi:
I have a winform which I invoke (as a modeless form) from within AutoCad. The User makes a selection in the listbox of the form and clicks on the button. On button click, the form is minimised and the user is prompted to Select a point on the screen upon which a MText and DbText are inserted (text is governed by the list box selection).
On clicking the form button, I have to click 3 times on the Autocad window to actually do the insertion (even though the selection for a point is prompted at the first click). I would like to transfer control from form to Autocad in 1 click. Below is my code:
Private Sub cmdInsert_Click(ByVal sender As System.Object, ByVal e _
As System.EventArgs) Handles cmdInsert.Click
Dim db As Database = Nothing
Dim promptPoint As PromptPointOptions = Nothing
Dim promptResult As PromptPointResult = Nothing
Dim ptMText As Point3d = Nothing
Dim ptDText As Point3d = Nothing
Dim ed As Editor = Nothing
Try
Me.TopMost = False
Me.TopLevel = False
HostApplicationServices.WorkingDatabase = Autodesk.AutoCAD.ApplicationServices _
.Application.DocumentManager.MdiActiveDocument.Dat
db = HostApplicationServices.WorkingDatabase
ed = Autodesk.AutoCAD.ApplicationServices.Application.D
MdiActiveDocument.Editor
'Prompt the user to select the point where the Material Item is to be imported.
promptPoint = New PromptPointOptions("Select the Insertion Point")
promptResult = ed.GetPoint(promptPoint)
If promptResult.Status = PromptStatus.OK Then
ptMText = promptResult.Value
'call the function to Create MText.
CreateMText(ptMText)
'call the function to Create DText. Calculate the position of the DText relative
'to the MTexy chosen.
ptDText = New Point3d(ptMText.X - 0.5625 * db.Dimscale, _
ptMText.Y - 0.25 * db.Dimscale, 0)
CreateDText(ptDText)
_SelectedNode = Nothing
Autodesk.AutoCAD.ApplicationServices.Application.U
End If
Catch ex As Exception
MessageBox.Show(ex.Message & vbNewLine & ex.StackTrace)
Finally
Me.TopMost = True
Me.TopLevel = True
_SelectedNode = Nothing
db = Nothing
ed = Nothing
ptMText = Nothing
ptDText = Nothing
End Try
End Sub
Re: Interactio n between Winform and Acad
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
10-08-2007 11:56 AM in reply to:
Saumitra
Hey Tony,
That worked. Thanks a lot. I was grappling with this issue for 1 and a half days.
Thanks
Saumitra
That worked. Thanks a lot. I was grappling with this issue for 1 and a half days.
Thanks
Saumitra
