excel - 使用excel vba加载线型autocad
问题描述
我尝试使用 excel VBA 作为加载线类型:
Call acadDoc.ModelSpace.Linetypes.Load("HIDDEN", "acad.lin")
Or
Set acadLineTypes = acadDoc.ModelSpace.Linetypes.Load("HIDDEN", "acad.lin")
但不可能。
解决方案
以下内容是从Linetype Property (ActiveX)的示例中修改的。
Sub Example_Linetype()
' This example searches for the linetype Hidden. If it is
' not found, it is added from the acad.lin file. Then a
' line is created and changed to the Hidden linetype.
' Search the linetypes collection for the Hidden linetype.
Dim entry As AcadLineType
Dim found As Boolean
found = False
For Each entry In acadDoc.Linetypes
If StrComp(entry.name, "HIDDEN", 1) = 0 Then
found = True
Exit For
End If
Next
If Not (found) Then acadDoc.Linetypes.Load "HIDDEN", "acad.lin"
' Create the line
Dim lineObj As AcadLine
Dim startPoint(0 To 2) As Double
Dim endPoint(0 To 2) As Double
startPoint(0) = 1#: startPoint(1) = 1#: startPoint(2) = 0#
endPoint(0) = 4#: endPoint(1) = 4#: endPoint(2) = 0#
Set lineObj = acadDoc.ModelSpace.AddLine(startPoint, endPoint)
' Change the linetype of the line
lineObj.Linetype = "HIDDEN"
ZoomAll
End Sub
推荐阅读
- java - Spring Boot Jpa:我可以将 JSON 文件配置为数据库吗?
- mongoose - 猫鼬排序对象的子数组
- java - HarmonyOS 中用于 Android OS 中 onMeasure 的替代功能是什么?
- excel - 引用的工作表未激活时出现 VBA 错误 1004
- javascript - 在 XMLHttpRequest 完成后运行 then 方法
- loops - 使用 ffmpeg 仅使用某些帧创建无限循环动画
- javascript - 在 javascript / node js 中编写处理错误处理 then-catch 或 try-catch 是最佳实践
- reactjs - 从 API 渲染时数据重复 - Material UI Tabs React
- push-notification - Blazor Web 程序集推送通知
- python-3.x - 散列与python中的预期值不匹配的元组