Load CAD files from Stream

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
Dmitrij
Posts: 1
Joined: 30 May 2014, 14:45

Load CAD files from Stream

Post by Dmitrij » 30 May 2014, 14:58

Hi,

I'm totally new in your control. And at the moment I'm trying to create prototype where I can download CAD files from our filestore into stream and then view these files by using your control.
I want to skip saving file to disk and open directly from stream.

I made following steps:
1. Placed CADPictureBox on form.
2. Downloding files into stream by using our framework. Some of the code is based on your example:
Private WithEvents cadPictBox As CADPictureBox
Private cadImageFld As CADImage
Private lForm As New LayerForm
Dim vStream As Stream = New MemoryStream()
Dim vFileStoreLayer As afStoreLayer = New afStoreLayer()
vFileStoreLayer.GetFile(vStream, TableName, FilePrimKey)
vStream.Position = 0
Select Case atbv_Testing_CadFileConversion.CurrentRow("Extension").ToString
Case "dwg"
cadImageFld = New DWGImage()
Case "dxf"
cadImageFld = New CADImage()
End Select

If TypeOf Me.cadImageFld Is CADRasterImage Then
CType(Me.cadImageFld, CADRasterImage).Control = Me.cadPictBox
End If

If (Not Me.cadImageFld Is Nothing) Then
Me.cadImageFld.LoadFromStream(vStream)
End If
Me.SetCADImageOptions()

And the the end I'm getting error message
[Arithmetic operation resulted in an overflow.] at App.Testing.CadFilesConversion.Form1.SetPictureBoxPosition(PointF value) in C:\CR4 Development\Pims R4 Dev\WinProjects\App.Testing.CadFilesConversion\Form1.vb:line 232
at App.Testing.CadFilesConversion.Form1.DrawCADImage(Graphics gr) in C:\CR4 Development\Pims R4 Dev\WinProjects\App.Testing.CadFilesConversion\Form1.vb:line 213

in following method:
Public Sub DrawCADImage(ByVal gr As Graphics)
Try
Me.Shift()
Dim tmp As RectangleF = Me.ImageRectangleF
Me.SetSizePictureBox(New Size(CInt(tmp.Width), CInt(tmp.Height)))
Me.SetPictureBoxPosition(Me.Position)
Me.cadImageFld.Draw(gr, tmp, Me.cadPictBox)
Catch e1 As Exception
HandleException(e1)
End Try
End Sub


Not sure where I made mistake. Appreciate for your help.

Best regards,
Dmitrij

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Load CAD files from Stream

Post by support » 30 May 2014, 15:55

Hello Dmitrij,

Arithmetic overflow happens when you perform an operation with a data type and the result of this operation exceeds the size of a storage for this datatype. Please, check a value of Me.Position in Form1.SetPictureBoxPosition() method.


Mikhail.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply