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

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

1 REPLY 1
Reply
Message 1 of 2
thenndral
2007 Views, 1 Reply

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

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

1 REPLY 1
Message 2 of 2
_gile
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
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

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