Interaction between userform and model space

Interaction between userform and model space

Anonymous
Not applicable
1,103 Views
4 Replies
Message 1 of 5

Interaction between userform and model space

Anonymous
Not applicable

Hi All,

 

How can we made interactive between user form button and model space? When I click a button in user form, it needs me to click the model space first. Only after that the task will begin.

 

I want it to be like what autocad have. Click on the button and directly begin the work in the model space, without needing to click the model space first.

 

Here is my code :

 

User Form setting :

 

Public Class UICall

    Implements Autodesk.AutoCAD.Runtime.IExtensionApplication

 

    Friend Shared AcPs As Autodesk.AutoCAD.Windows.PaletteSet = Nothing

    Private UIClass As LogicUI = Nothing

 

    <CommandMethod("LogicUI")> _

    Public Sub CallLogicUserInterface()

        If AcPs = Nothing Then

            AcPs = New Autodesk.AutoCAD.Windows.PaletteSet("Logic User Interface", New Guid("{3AD1B2B3-8194-4FA9-B91E-91BBB45279E3}"))

            AcPs.Style = Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowCloseButton

            UIClass = New LogicUI

            AcPs.Add("Logic UI", UIClass)

            AcPs.Size = New Drawing.Size(200, 700)

        End If

        AcPs.Visible = False : AcPs.Visible = True

        AcPs.WindowState = Autodesk.AutoCAD.Windows.Window.State.Normal

        AcPs.Dock = Autodesk.AutoCAD.Windows.DockSides.Left

    End Sub

 

 

    Public Sub Initialize() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Initialize

        CallLogicUserInterface()

    End Sub

 

    Public Sub Terminate() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Terminate

        AcPs = Nothing

        AcPs.Dispose()

    End Sub

End Class

 

Click Event in the userform :

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

        Dim cl As Class1 = New Class1

        cl.CreateLine()

    End Sub

 

Cad function :

 

Public Sub CreateLine()

        Dim ed As Editor = App.DocumentManager.MdiActiveDocument.Editor

        Dim db As Database = HostApplicationServices.WorkingDatabase

        Using tr As Transaction = db.TransactionManager.StartTransaction

            Dim ppr As PromptPointResult = ed.GetPoint(vbLf & "Specify base point")

            Dim pt1 As Point3d = ppr.Value

            ppr = ed.GetPoint(vbLf & "Specify next point")

            Dim pt2 As Point3d = ppr.Value

            Dim acLine As Line = New Line(pt1, pt2)

            Dim btr As BlockTableRecord = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite)

            btr.AppendEntity(acLine)

            tr.AddNewlyCreatedDBObject(acLine, True)

            tr.Commit()

        End Using

    End Sub

 

0 Likes
Accepted solutions (1)
1,104 Views
4 Replies
Replies (4)
Message 2 of 5

Balaji_Ram
Alumni
Alumni

Hello Abu,

 

Please try this :

http://adndevblog.typepad.com/autocad/2013/03/use-of-windowfocus-in-autocad-2014.html

 

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

Message 3 of 5

Keith.Brown
Advisor
Advisor
Accepted solution

I would also add that it might be better if you put your logic to draw the line inside of a command and then have your button call the command.  This will give your power users the opportunity to use the keyboard instead of using your form if they want.

Message 4 of 5

Anonymous
Not applicable

@Balaji_Ram wrote:

Hello Abu,

 

Please try this :

http://adndevblog.typepad.com/autocad/2013/03/use-of-windowfocus-in-autocad-2014.html

 

Regards,

Balaji


Hi Balaji,

 

This use for Autocad 2014 and above. Mine is 2013 version.

Sorry not inform this before

0 Likes
Message 5 of 5

Anonymous
Not applicable

@Keith.Brown wrote:

I would also add that it might be better if you put your logic to draw the line inside of a command and then have your button call the command.  This will give your power users the opportunity to use the keyboard instead of using your form if they want.


  Thanks for the idea keith. I'll do it that way then

0 Likes