我正在处理 Excel 电子表格来生成 DXF。到目前为止,我已经能够生成直线、折线、多边形、圆形和简单文本的函数,但我正在努力编写 MTEXT 函数。
这就是我现在所拥有的:
Function DXF_MTEXTO(ByRef DXF_TEXT As String, ByVal CAPA As String, _
ByVal CX As Single, ByVal CY As Single, ByVal
miTexto As String, _
ByVal miAltura As Single, ByVal ang As Single) As String
DXF_TEXT = DXF_TEXT & 0 & vbCrLf 'Entidad
DXF_TEXT = DXF_TEXT & "MTEXT" & vbCrLf
DXF_TEXT = DXF_TEXT & 8 & vbCrLf 'Capa
DXF_TEXT = DXF_TEXT & CAPA & vbCrLf
DXF_TEXT = DXF_TEXT & 10 & vbCrLf 'Coordenada X del texto
DXF_TEXT = DXF_TEXT & CX & vbCrLf
DXF_TEXT = DXF_TEXT & 20 & vbCrLf 'Coordenada Y del texto
DXF_TEXT = DXF_TEXT & CY & vbCrLf
DXF_TEXT = DXF_TEXT & 1 & vbCrLf 'Texto
DXF_TEXT = DXF_TEXT & miTexto & vbCrLf
DXF_TEXT = DXF_TEXT & 40 & vbCrLf 'Altura de texto
DXF_TEXT = DXF_TEXT & miAltura & vbCrLf
DXF_TEXT = DXF_TEXT & 41 & vbCrLf ' Ancho de rectángulo de referencia
DXF_TEXT = DXF_TEXT & 16 & vbCrLf
DXF_TEXT = DXF_TEXT & 71 & vbCrLf ' Punto de anclaje: 1 Top Left
DXF_TEXT = DXF_TEXT & 1 & vbCrLf
DXF_TEXT = DXF_TEXT & 72 & vbCrLf ' Dirección del texto: 5 By Style
DXF_TEXT = DXF_TEXT & 5 & vbCrLf
DXF_TEXT = DXF_TEXT & 50 & vbCrLf ' Rotación del texto
DXF_TEXT = DXF_TEXT & ang & vbCrLf
DXF_TEXT = DXF_TEXT & 90 & vbCrLf ' Background fill: 0 = Off
DXF_TEXT = DXF_TEXT & 0 & vbCrLf
DXF_MTEXTO = DXF_TEXT
End Function
有人可以帮我吗?一段代码,一个参考(与AutoDesk DXF参考不同)
提前致谢!
我阅读了 DXF 参考资料并尝试修改其他函数,认为它可以根据 AutoDesk pdf 工作。
例如,这是简单文本的函数(效果很好):
Function DXF_TEXTO(ByRef DXF_TEXT As String, ByVal CAPA As String, _
ByVal CX As Single, ByVal CY As Single, ByVal miTexto As String, _
ByVal miAltura As Single, ByVal ang As Single) As String
DXF_TEXT = DXF_TEXT & 0 & vbCrLf
DXF_TEXT = DXF_TEXT & "TEXT" & vbCrLf
DXF_TEXT = DXF_TEXT & 8 & vbCrLf
DXF_TEXT = DXF_TEXT & CAPA & vbCrLf
DXF_TEXT = DXF_TEXT & 10 & vbCrLf
DXF_TEXT = DXF_TEXT & CX & vbCrLf
DXF_TEXT = DXF_TEXT & 20 & vbCrLf
DXF_TEXT = DXF_TEXT & CY & vbCrLf
DXF_TEXT = DXF_TEXT & 1 & vbCrLf
DXF_TEXT = DXF_TEXT & miTexto & vbCrLf
DXF_TEXT = DXF_TEXT & 40 & vbCrLf
DXF_TEXT = DXF_TEXT & miAltura & vbCrLf
DXF_TEXT = DXF_TEXT & 50 & vbCrLf
DXF_TEXT = DXF_TEXT & ang & vbCrLf
DXF_TEXTO = DXF_TEXT
End Function
MTEXT
实体要求您指定子类标记,例如:
Function DXF_MTEXTO(ByRef DXF_TEXT As String, ByVal CAPA As String, _
ByVal CX As Single, ByVal CY As Single, ByVal miTexto As String, _
ByVal miAltura As Single, ByVal ang As Single) As String
DXF_TEXT = DXF_TEXT & 0 & vbCrLf 'Entidad
DXF_TEXT = DXF_TEXT & "MTEXT" & vbCrLf
DXF_TEXT = DXF_TEXT & 100 & vbCrLf 'Subclass marker
DXF_TEXT = DXF_TEXT & "AcDbEntity" & vbCrLf 'Subclass marker
DXF_TEXT = DXF_TEXT & 100 & vbCrLf 'Subclass marker
DXF_TEXT = DXF_TEXT & "AcDbMText" & vbCrLf 'Subclass marker
DXF_TEXT = DXF_TEXT & 8 & vbCrLf 'Capa
DXF_TEXT = DXF_TEXT & CAPA & vbCrLf
DXF_TEXT = DXF_TEXT & 10 & vbCrLf 'Coordenada X del texto
DXF_TEXT = DXF_TEXT & CX & vbCrLf
DXF_TEXT = DXF_TEXT & 20 & vbCrLf 'Coordenada Y del texto
DXF_TEXT = DXF_TEXT & CY & vbCrLf
DXF_TEXT = DXF_TEXT & 1 & vbCrLf 'Texto
DXF_TEXT = DXF_TEXT & miTexto & vbCrLf
DXF_TEXT = DXF_TEXT & 40 & vbCrLf 'Altura de texto
DXF_TEXT = DXF_TEXT & miAltura & vbCrLf
DXF_TEXT = DXF_TEXT & 41 & vbCrLf ' Ancho de rectángulo de referencia
DXF_TEXT = DXF_TEXT & 16 & vbCrLf
DXF_TEXT = DXF_TEXT & 71 & vbCrLf ' Punto de anclaje: 1 Top Left
DXF_TEXT = DXF_TEXT & 1 & vbCrLf
DXF_TEXT = DXF_TEXT & 72 & vbCrLf ' Dirección del texto: 5 By Style
DXF_TEXT = DXF_TEXT & 5 & vbCrLf
DXF_TEXT = DXF_TEXT & 50 & vbCrLf ' Rotación del texto
DXF_TEXT = DXF_TEXT & ang & vbCrLf
DXF_TEXT = DXF_TEXT & 90 & vbCrLf ' Background fill: 0 = Off
DXF_TEXT = DXF_TEXT & 0 & vbCrLf
DXF_MTEXTO = DXF_TEXT
End Function