关于vb.net输出dxf的信息( 二 )


DwgF.Seek(PosSentinel + 30, SeekOrigin.Begin) '将指针移到缩略图描述块的第31字节
TypePreview = br.ReadByte '第31字节为缩略图格式信息,2 为BMP格式,3为WMF格式
Select Case TypePreview
Case 1
Case 2, 3
PosBMP = br.ReadInt32 'DWG文件保存的位图所在位置
LenBMP = br.ReadInt32 '位图的大小
DwgF.Seek(PosBMP + 14, SeekOrigin.Begin) '移动指针到位图块
biBitCount = br.ReadInt16 '读取比特深度
DwgF.Seek(PosBMP, SeekOrigin.Begin) '从位图块开始处读取全部位图内容备用
BMPInfo = br.ReadBytes(LenBMP)'不包含文件头的位图信息
br.Close()
DwgF.Close()
With biH'建立位图文件头
.bfType = H4D42
If biBitCount9 Then .bfSize = 54 + 4 * (2 ^ biBitCount) + LenBMP Else .bfSize = 54 + LenBMP
.bfReserved1 = 0 '保留字节
.bfReserved2 = 0 '保留字节
.bfOffBits = 14 + H28 + 1024 '图像数据偏移
End With
'以下开始写入位图文件头
bmpr.Write(biH.bfType) '文件类型
bmpr.Write(biH.bfSize) '文件大小
bmpr.Write(biH.bfReserved1) '0
bmpr.Write(biH.bfReserved2) '0
bmpr.Write(biH.bfOffBits) '图像数据偏移
bmpr.Write(BMPInfo) '写入位图
BMPF.Seek(0, SeekOrigin.Begin) '指针移到文件开始处
myImg = Image.FromStream(BMPF) '创建位图文件对象
Return myImg
bmpr.Close()
BMPF.Close()
End Select
Catch ex As Exception
Return Nothing
End Try
End Function
End Class
你好 请问下我用VB提取DXF文件中信息然后导出到EXCEL怎么弄啊Private Sub GetLWPOLYLINECoordinates()
Dim ss_dim As AcadSelectionSet, ent As AcadEntity
【关于vb.net输出dxf的信息】Dim dxf_code() As Integer, dxf_value() As Variant
Dim i As Long, j As Long
Dim dbCor As Variant, x As Double, y As Double, z As Double
On Error GoTo ErrExit
Set ss_dim = ThisDrawing.SelectionSets.Add("sPolyLines")
ReDim dxf_code(3), dxf_value(3)
dxf_code(0) = -4: dxf_value(0) = "OR"
dxf_code(1) = 0: dxf_value(1) = "LWPOLYLINE" '这里表示2D多义线
dxf_code(2) = 0: dxf_value(2) = "POLYLINE" '这里表示3D多义线
dxf_code(3) = -4: dxf_value(3) = "OR"
ss_dim.Select acSelectionSetAll, , , dxf_code, dxf_value
Open "d:\\aaaaa.txt" For Append As #1
'"AcDb3dPolyline","AcDbPolyline"
For Each ent In ss_dim
Select Case ent.ObjectName
Case "AcDb3dPolyline"'这里处理3D多义线坐标
Dim ent3D As Acad3DPolyline
Set ent3D = ent
For j = 0 To UBound(ent3D.Coordinates) \\ 3
x = ent3D.Coordinates(j * 3)
y = ent3D.Coordinates(j * 3 + 1)
z = ent3D.Coordinates(j * 3 + 2)
Print #1, "X"x",Y"y",Z"z
Next
Case "AcDbPolyline"'这里处理2D多义线坐标
Dim ent2D As AcadLWPolyline
Set ent2D = ent
For j = 0 To UBound(ent2D.Coordinates) \\ 2
x = ent2D.Coordinates(j * 2)
y = ent2D.Coordinates(j * 2 + 1)
Print #1, "X"x",Y"y",Z"ent2D.Elevation
Next
End Select
Next
ErrExit:
ss_dim.Clear
ss_dim.Delete
Close #1
End Sub
vb.net输出dxf的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于、vb.net输出dxf的信息别忘了在本站进行查找喔 。

推荐阅读