control machine arm with drawing?

newbievbnet

New member
Joined
May 15, 2010
Messages
4
Programming Experience
Beginner
hey guys..i want to make a vb.net program to let users control a machine arm to draw on a paper based on what he draw in the program form.
basically i want to design a control form with small dots on it(grid)
and every dot represent a coordiantion point of my machine
and a drawing function provide to user to draw anything on the dots,after that the machine can move to specified location based on the dots being link/draw by user.

so first..how can i make small dots on a vb.net form?
second...how can i provide a control button for user to draw line or input text on that form?do i need shape powerpack or something??
third...how can i detect the dots(which represent the coordinates) that had been link/draw by users?

so many subforum here...if wrong place pls help to move my thread..thanks..
 
Hi newbievbnet,

For drawing stuff on the screen -- on a form or on a picturebox for example -- you don't need any special power packs in VB.Net. It's all built into VB.Net under the name GDI+. And that's the bread and butter of this forum.

It has a bunch of routines for drawing things on controls and on memory bitmaps. It includes commands for drawing lines, rectangles, ellipses (including circles), curves, text, compounds of all these (called paths) and images. One thing missing is a command for drawing a point -- you do that by drawing a 1 x 1 pixel rectangle.

If you want to learn how to make a drawing program using GDI+ and graphics, you could start with a simple example like the one by Jmcilhinney, here. If you have any questions about it, this is a good place to come.

Controlling a machine arm is a different matter. You'll need to know how its interface works, and as far as I know there isn't a standard for that. But I've seen people doing various remote control projects through the computer's serial port, so I'm sure it's possible in VB.Net with GDI+. Perhaps someone else here knows more about that area or can point you to a suitable forum.

BB
 
thx for ur reply

i can now provide a drawing program now , but another problem :assume that user draw a line on 1,1 to 10,10 and i wan to record down all the coordinates the line pass through(smallest is 1),i can easily record down the line start point and end point,but if i wan to get the point between start and end points(2,2 3,3 4,4 5,5 6,6 7,7 8,8 9,9 ),what can i do??for straight line it is easily to get the points between by using simple math calculation,but if it is not a straight line...

anyone can give me recommendations on how to record down the draw shape coordinates?i need to get all coordination because i need to write it out on a textfile and convert it to a valid tp file(for my fanuc robot arm)by send it thorugh RS232.
 
Are you talking about hand-drawn lines? If so, you should keep a record of the points while the line is being drawn. For example, you could add successive mouse positions to a List(Of Point) in the MouseMove event sub. Or are you using some other kind of line?

BB
 
izit temporary record down the mouse position in an array or watever when in mousemove evnt and confirm store the points when the line is "real created"?

i know this but if i have many line how should i store the points ?i dont noe how many line i will have,if i put all the point in one array,how can i retrive the points i store as i dont know which line have which points?if i have to store the points in different array or watever,i still dont noe how many line will be create and so i cant assisgn the points to store where,i also dont noe how many array have to be create .

i hope to develop a program that will let users draw all the line first.after he/she click ok den i store the number of lines that he created and the corresponding points of that line
in a textfile just below format:
line1 1,1 2,2 3,3 4,4
line2 2,3 4,6 7,8 x,x

linex x,x x,x x,x
 
Arrays are best when you know in advance how many items you want to store. But you don't know that. So use Lists instead.

You need a List(Of Point) for each line. You add new points whenever you need with List.Add. It would be neat to put that in a little Class of its own like this:
VB.NET:
Public Class Line
 Inherits List(Of Point)
End Class
Now you use Lines as a new kind of object, like this:
VB.NET:
Dim AllLines As New List(Of Line)
Dim CurrentLine As Line
To start drawing a new line, you would do this in the MouseDown sub (check for e.Button=MouseButtons.Left):
VB.NET:
CurrentLine = New Line
AllLines.Add(CurrentLine)
To build a line you could put this in the MouseMove event sub (check here too for MouseButtons.Left):
VB.NET:
CurrentLine.Add(e.Location)
Me.Invalidate
Then you can display all the lines that have been drawn by doing this in the Paint event sub:
VB.NET:
If AllLines.Count > 0 Then 
  For Each lin As Line in AllLines
    If lin.Count > 2 Then e.Graphics.DrawCurve(Pens.Black, lin.ToArray)
  Next
End If
Finally, you can get the data for your text file whenever you want from the contents of AllLines.

As you can see, using Lists is much easier than using Arrays. When the data must be in an array, as in the DrawCurve command above, put ToArray after the name of the List.

BB
 
Back
Top