ACAD 2000 - Point manipulation and Line drawing with VB.Net

ACAD 2000 - Point manipulation and Line drawing with VB.Net

Anonymous
Not applicable
991 Views
2 Replies
Message 1 of 3

ACAD 2000 - Point manipulation and Line drawing with VB.Net

Anonymous
Not applicable

I'll just start this out with this... I'm still really new to VB.Net in general, and very new from a "lets use this to do stuff in ACAD" standpoint. Google and the search function here have left me empty handed.  

  

I am trying to get a point from the user, then use and manipulate the X and Y values to draw lines based on those manipulated values. I have gotten as far as the code below, and I'm totally lost when it comes to the syntax of reading and manipulating point values.  

  

How would I turn the code example into something that:   

-accepts a point input from user  

-adds a variable to the X dimension to create a new point  

-draws a line between these 2 points  

  

The project is a bit more complicated than that, but sample code doing what is described above would get me pointed in the right direction.  

  

Thanks in advance!  

-Mitch  

 

PS. This is for Mechanical Desktop (ACAD 2000)

  

Imports AutoCAD


    Private Sub BendLineButton_Click(sender As Object, e As EventArgs) Handles BendLineButton.Click

        Dim AcadApp As AcadApplication

        Try
            AcadApp = GetObject(, "AutoCAD.Application")
            Threading.Thread.Sleep(500)

        Catch ex As Exception
            AcadApp = CreateObject("AutoCAD.Application")

        End Try

        Dim acCurDoc As AcadDocument = AcadApp.ActiveDocument

        acCurDoc.Utility.Prompt("Select start point for bend lines.")
        Dim startpoint As AcadPoint = acCurDoc.Utility.GetPoint()

        'Do Stuff, magical stuff, right here.
      

    End Sub
0 Likes
Accepted solutions (1)
992 Views
2 Replies
Replies (2)
Message 2 of 3

ActivistInvestor
Mentor
Mentor
Accepted solution

See >this topic< in the online docs, and search those same docs for other example code showing what you need to do.

 

You are trying to assign the result of a call to GetPoint() to an AcadPoint.  An AcadPoint represent a POINT entity in AutoCAD (which you create using the POINT command), it doesn't represent a 3D coordinate. The result of GetPoint() is a variant that contains an array of Double(3) (three doubles representing the X, Y and Z components). That's what you have to assign the result to. From there, it's just a matter of manipulating the array elements as needed, and then using the array in a call to AddLine() or whatever else you want to do.

 

 


@Anonymous wrote:

I'll just start this out with this... I'm still really new to VB.Net in general, and very new from a "lets use this to do stuff in ACAD" standpoint. Google and the search function here have left me empty handed.  

  

I am trying to get a point from the user, then use and manipulate the X and Y values to draw lines based on those manipulated values. I have gotten as far as the code below, and I'm totally lost when it comes to the syntax of reading and manipulating point values.  

  

How would I turn the code example into something that:   

-accepts a point input from user  

-adds a variable to the X dimension to create a new point  

-draws a line between these 2 points  

  

The project is a bit more complicated than that, but sample code doing what is described above would get me pointed in the right direction.  

  

Thanks in advance!  

-Mitch  

 

PS. This is for Mechanical Desktop (ACAD 2000)

  

Imports AutoCAD


    Private Sub BendLineButton_Click(sender As Object, e As EventArgs) Handles BendLineButton.Click

        Dim AcadApp As AcadApplication

        Try
            AcadApp = GetObject(, "AutoCAD.Application")
            Threading.Thread.Sleep(500)

        Catch ex As Exception
            AcadApp = CreateObject("AutoCAD.Application")

        End Try

        Dim acCurDoc As AcadDocument = AcadApp.ActiveDocument

        acCurDoc.Utility.Prompt("Select start point for bend lines.")
        Dim startpoint As AcadPoint = acCurDoc.Utility.GetPoint()

        'Do Stuff, magical stuff, right here.
      

    End Sub

 

0 Likes
Message 3 of 3

Anonymous
Not applicable

Thanks, I was able to get it pretty quickly with your answer. 

0 Likes