重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

vb.netdxf文件的简单介绍

vb.net如何在编程中获取CAD对象的DXF组码

感觉 vb.net对象中根本不存在组码这个东西,一切皆对象。直接遍历访问,要对应组码有何用?如果你想获取组码一句简单lsp语句就行了。

创新互联建站专注为客户提供全方位的互联网综合服务,包含不限于网站制作、网站建设、甘孜州网络推广、小程序设计、甘孜州网络营销、甘孜州企业策划、甘孜州品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;创新互联建站为所有大学生创业者提供甘孜州建站搭建服务,24小时服务热线:028-86922220,官方网址:www.cdcxhl.com

vb.net能否生成dxf文件?

从你贴的链接教程来看,所谓的dxf文件本质上就是文本文件,因此扩展名可以是任意的,完全没问题。

VB.net 导入DXF文件

Imports System.IO

Imports System.Drawing

Public Class PreViewDWG

Private Structure BITMAPFILEHEADER

Dim bfType As Short

Dim bfSize As Integer

Dim bfReserved1 As Short

Dim bfReserved2 As Short

Dim bfOffBits As Integer

End Structure

Public Function GetDwgImage(ByVal FileName As String) As Image

If Not File.Exists(FileName) Then Exit Function

Dim DwgF As FileStream    '文件流

Dim PosSentinel As Integer  '文件描述块的位置

Dim br As BinaryReader  '读取二进制文件

Dim TypePreview As Integer '缩略图格式

Dim PosBMP As Integer '缩略图位置

Dim LenBMP As Integer '缩略图大小

Dim biBitCount As Short '缩略图比特深度

Dim biH As BITMAPFILEHEADER 'BMP文件头,DWG文件中不包含位图文件头,要自行加上去

Dim BMPInfo() As Byte  '包含在DWG文件中的BMP文件体

Dim BMPF As New MemoryStream  '保存位图的内存文件流

Dim bmpr As New BinaryWriter(BMPF) '写二进制文件类

Dim myImg As Image

Try

DwgF = New FileStream(FileName, FileMode.Open, FileAccess.Read)    '文件流

br = New BinaryReader(DwgF)

DwgF.Seek(13, SeekOrigin.Begin) '从第十三字节开始读取

PosSentinel = br.ReadInt32 '第13到17字节指示缩略图描述块的位置

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 biBitCount  9 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

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读取一个dxf格式的图形文件的数据

dxf文件是AutoCad的交换文件,可以直接用AutoCad打开。dxf文件是明码文件,在vb环境下按顺序文件读取就可以了。

例如:在C盘根目录下有一个文件“1.dxf”

启动vb后,建立一个按钮:Command1

并双击此按钮,对其输入以下代码:

Private Sub Command1_Click()

Dim a As String '读取文件一行的内容

Dim i As Long '用于记录行数

Dim j As Long '用于记录用户如何响应提示

Open "c:\1.dxf" For Input As #1

i = 0

While Not EOF(1)

Line Input #1, a

i = i + 1

j = MsgBox("第 " i " 行内容为:" a, vbOKCancel + vbInformation)

'运行到此步时,如果用户输入“确定”则继续,如果用户输入“取消”则结束本程序

'用户可以在此输入处理代码,对读入的字串进行处理

If j = vbCancel Then

End

End If

Wend

close #1

End Sub

用VB读dxf文件时,用什么程序读取一段圆弧的起点和终点的坐标?

dxf中你看entity字段

关于arc的描述

ARC

以下组码适用于圆弧图元。除此处所述的组码以外,另请参见常用图元组码。关于此表中使用的缩写和格式方面的信息,请参见本参考的格式惯例。

圆弧组码

组码说明

100

子类标记

(AcDbCircle)

39

厚度(可选;默认值

=

0)

10

中心点(在

OCS

中)DXF:X

值;APP:三维点

20,

30

DXF:中心点的

Y

值和

Z

值(在

OCS

中)

40

半径

100

子类标记

(AcDbArc)

50

起点角度

51

端点角度

210

拉伸方向(可选;默认值

=

0,

0,

1)DXF:X

值;APP:三维矢量

220,

230

DXF:拉伸方向的

Y

值和

Z

值(可选)


当前名称:vb.netdxf文件的简单介绍
转载源于:http://cqcxhl.com/article/hphhgg.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP