Jump to content
HQuintas

Desenhar a partir dxf

Recommended Posts

HQuintas

Boas, estou com pequeno problema ao desenhar numa picturebox um ficheiro em dxf. Faz a leitura tudo bem, mas não une as linhas e os arcos, como se pode ver na imagem. Porquê?

Capturar.png

 Private Sub linha(x As Double, y As Double, x_end As Double, y_end As Double, mypen As Pen)
        
   Using g As Graphics = Graphics.FromImage(bm)

            ' Flip the Y-Axis
            g.ScaleTransform(zx, zy)
            ' Translate the drawing area accordingly
            g.TranslateTransform(fx, fy)

            Dim p1 As New Point(x, y)
            Dim p2 As New Point(x_end, y_end)

            ' Create a new pen.
            Dim sPen As New Pen(Brushes.Black)
            ' Set the pen's width.
            sPen.Width = 1.0F

            g.DrawLine(sPen, p1, p2)
        End Using

        'bm.RotateFlip(RotateFlipType.RotateNoneFlipY)
        PictureBox1.Image = bm



    End Sub

    
    Private Sub arco(x As Double, y As Double, r As Double, angS As Single, angE As Single)

       Using g As Graphics = Graphics.FromImage(bm)

            ' Flip the Y-Axis
            g.ScaleTransform(zx, zy)
            ' Translate the drawing area accordingly
            g.TranslateTransform(fx, fy)

            ' Create a new pen.
            Dim sPen As New Pen(Brushes.Red)
            ' Set the pen's width.
            sPen.Width = 1.0F
            cor_perfil = sPen

            Dim p1 As Double = x - r
            Dim p2 As Double = y - r
            Dim p3p4 As Double = 2 * r

            Dim sweep As Single = angE - angS

            If angE < angS Then
                sweep = 360 - angS + angE
            End If

            If sweep < 0 Then sweep = -sweep

            ListBox1.Items.Add(sweep)

           
            Dim rect As New Rectangle(p1, p2, p3p4, p3p4)
                      
            Try
               
                g.DrawArc(cor_perfil, rect, angS, sweep)

            Catch ex As Exception

            End Try


        End Using
        PictureBox1.Image = bm

    End Sub

 

Share this post


Link to post
Share on other sites
zep

Boas, desenhas em *.dxf e depois exportas para a picturebox, certo?

Se sim podes enviar o ficheiro *.dxf?

Edited by zep

Share this post


Link to post
Share on other sites
HQuintas

Boas, sim tenho os ficheiros em dxf e quero lê-los numa picturebox, para posteriormente os guardar como imagem.

E tenho dois tipos de dxf,  uns em que tem ARC e LINES e outro tipo em que estão guardados com VERTEX (estes ficam para uma segunda fase)

Aqui está o ficheiro para esta 1ª fase: 204.dxf

Share this post


Link to post
Share on other sites
zep

Ok já recebi o ficheiro em dxf e o ficheiro está ok.

Mas percebi mal, queres fazer uma imagem de acordo com o dxf e não importar o dxf?

Penso que terás de mudar sPen.Width = 1.0F para 1px (não tenho a certeza), não sei se 0.5px vai resultar.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.