.NET

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

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

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

Hello,

 

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,

thenndral

*Expert Elite*
_gile
Posts: 2,084
Registered: ‎04-29-2006
Message 2 of 2 (785 Views)

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

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

Hi,

 

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
                Return
            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
                Return
            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
                space.AppendEntity(circle)
                trans.AddNewlyCreatedDBObject(circle, True)
                'commit the changes to the Database
                trans.Commit()
            End Using

        End Sub

 

Gilles Chanteau
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 or visit the Installation and Licensing Forum to get help installing your software.