Active Contributor
Posts: 48
Registered: ‎04-01-2013
Message 1 of 2 (829 Views)

get input from user and Draw circle using vb.net 2010.

829 Views, 1 Replies
07-02-2013 12:36 AM



I have a question. I'm using VB.Net 2010 with Autocad2012.

How to make code for promt input user.


Get input points from user and draw circle using VB.Net 2010 with Autocad2012.


Please give me some source help.


Thanks in advance,


*Expert Elite*
Posts: 2,104
Registered: ‎04-29-2006
Message 2 of 2 (819 Views)

Re : get input from user and Draw circle using vb.net 2010.

07-02-2013 02:05 AM in reply to: thenndral



Here's a basic sample.


        <CommandMethod("CircleCmd")> _
        Public Sub DrawCircle()
            ' get the current Database and Editor instances
            Dim doc As Document = AcApp.DocumentManager.MdiActiveDocument
            Dim db As Database = doc.Database
            Dim ed As Editor = doc.Editor

            ' Prompt the user for the circle center (see PromptPointOptions for more options)
            Dim ppr As PromptPointResult = ed.GetPoint(vbLf & "Specify the circle center: ")
            ' if the user escaped, quit the command
            If ppr.Status <> PromptStatus.OK Then
            End If
            ' store the specified point
            Dim center As Point3d = ppr.Value

            ' prompting the user for the circle radius
            ' set some input options
            Dim opt As PromptDistanceOptions = New PromptDistanceOptions(vbLf & "Specify the circle radius: ")
            opt.AllowNegative = False
            opt.AllowZero = False
            opt.BasePoint = center
            opt.UseBasePoint = True
            opt.DefaultValue = 10.0
            opt.UseDefaultValue = True
            Dim pdr As PromptDoubleResult = ed.GetDistance(opt)
            ' if the user escaped, quit the command
            If pdr.Status <> PromptStatus.OK Then
            End If
            ' store the specified distance
            Dim radius As Double = pdr.Value

            ' transform the center point from current UCS to WCS
            center = center.TransformBy(ed.CurrentUserCoordinateSystem)

            ' start a transaction to add the circle to the current space
            Using trans As Transaction = db.TransactionManager.StartTransaction()
                ' open the current space for write
                Dim space As BlockTableRecord = trans.GetObject(db.CurrentSpaceId, OpenMode.ForWrite)
                ' create a new circle object
                Dim circle As Circle = New Circle(center, Vector3d.ZAxis, radius)
                ' add the newly created circle to the space
                trans.AddNewlyCreatedDBObject(circle, True)
                'commit the changes to the Database
            End Using

        End Sub


Gilles Chanteau
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.