親記事 / 返信無し
■103783 / 親階層) |
Visual Basicで簡易CADを作成 |
□投稿者/ shiro (1回)-(2025/07/25(Fri) 20:50:26)
|
分類:[VB.NET/VB2005 以降]
Visual Basicで簡易CADを作成したいため、下記のようにグリッド座標を作成しました。 18*18個のマス目が出来ます。点線は半分ズレた柱を配置するためです。
最初に「柱」を選択し、柱を配置したい線の交点にマウスを近づけると、一番近い交点を認識し、そこに柱の■を配置したいです。 柱の数だけ連続して処理したいです。
その後、「壁」を選択し、柱■の2点間をラバーバンド機能でマウスで長方形で配置したいです。
グリッド座標を作成するまでは出来たのですが、その後の処理をするコードで失敗していました。 どのようなコードで記述すれば上手く行くか、アドバイス頂けると有難いです。
記
Private Sub PictureBox1_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox1.Paint
Dim i As Integer Dim j As Integer
Dim pen As New Pen(Color.Black, 1)
For i = 0 To 36 If (i Mod 2 = 1) Then pen.DashStyle = Drawing2D.DashStyle.Dot e.Graphics.DrawLine(pen, 100, 100 + 10 * i, 460, 100 + 10 * i) Else pen.DashStyle = Drawing2D.DashStyle.Solid e.Graphics.DrawLine(pen, 100, 100 + 10 * i, 460, 100 + 10 * i) End If Next
For j = 0 To 36 If (j Mod 2 = 1) Then pen.DashStyle = Drawing2D.DashStyle.Dot e.Graphics.DrawLine(pen, 100 + 10 * j, 100, 100 + 10 * j, 460) Else pen.DashStyle = Drawing2D.DashStyle.Solid e.Graphics.DrawLine(pen, 100 + 10 * j, 100, 100 + 10 * j, 460) End If Next
End Sub
|
|