BIGAL 发表于 2022-7-6 15:20:53

在文件中加载所有线型

我有一个问题,我正在尝试加载中的所有线型。LIN文件中的一些线型已经存在,因此加载停止并询问Y或N如何在VBA中不停止地对所有线型回答“是”?
 
此图纸。SendCommand“-linetype”&vbCr&“l”&vbCr&“*”&vbCr&“s:\Autodesk\supportfiles\custom.lin”&vbCr&vbCr

ASMI 发表于 2022-7-6 15:37:36

如果有用于线型加载的标准方法Load,并且您可以检查线型集合中是否存在任何线型,那么使用SendCommand做什么?在任何情况下,如果没有其他方法,可以使用最差的解决方案。

TommyG 发表于 2022-7-6 15:42:27

此图纸。线型。加载“Linestyle”,文件名

BIGAL 发表于 2022-7-6 15:53:10

谢谢Tommyg
 
已尝试右声道
 
FileName=“s:\autodesk\supportfiles\custom.lin”
此图纸。线型。加载“*”,文件名
 
没有工作,我想一次加载所有的线型,我没有得到任何错误,所以不知道下一步要做什么。

TommyG 发表于 2022-7-6 16:05:06

从阅读帮助中,你将无法做到这一点。
 
这可能很有趣,取自帮助文件
 
Sub Example_Linetype()
   ' This example searches for the linetype DashDot. If it is
   ' not found, it is added from the acad.lin file. Then a
   ' line is created and changed to the DashDot linetype.
   
   ' Search the linetypes collection for the DashDot linetype.
   Dim entry As AcadLineType
   Dim found As Boolean
   found = False
   For Each entry In ThisDrawing.Linetypes
       If StrComp(entry.name, "DASHDOT", 1) = 0 Then
         found = True
         Exit For
       End If
   Next
   If Not (found) Then ThisDrawing.Linetypes.Load "DASHDOT", "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 = ThisDrawing.ModelSpace.AddLine(startPoint, endPoint)
   
   ' Change the linetype of the line
   lineObj.Linetype = "DASHDOT"
   ZoomAll
   
End Sub

BIGAL 发表于 2022-7-6 16:20:21

Thnaks Tommyg我将只添加我知道需要的所有特定线型,这些线型是非标准Autocad,可以使其适合我。把同一行写几次不会花太长时间,至少这样它就会起作用。

TommyG 发表于 2022-7-6 16:29:54

别担心。我只是在一个单独的模块中加载线型,所以每次创建宏并需要加载线型时,我都会对该模块进行“调用”
页: [1]
查看完整版本: 在文件中加载所有线型