流浪狗 发表于 2005-5-7 13:05:00

[求助]急!求助!关于在VBA中使用ACAD命令行的问题

本人用以下两种方法欲使用ACAD命令行建立虚线图层
可是没有成功,不知道问题所在,
请高手指教,帮忙!谢谢!
一,
ThisDrawing.SendCommand "-layer m 1 c 2 1 l acad_iso10w100       1       "
二,
ThisDrawing.SendCommand "-layer "
ThisDrawing.SendCommand "m               "
ThisDrawing.SendCommand "1       "
ThisDrawing.SendCommand ""
ThisDrawing.SendCommand "c "
ThisDrawing.SendCommand " "
ThisDrawing.SendCommand "2 "
ThisDrawing.SendCommand " "
ThisDrawing.SendCommand "1 "
ThisDrawing.SendCommand " "
ThisDrawing.SendCommand "l "
ThisDrawing.SendCommand "acad_iso10w100 "
ThisDrawing.SendCommand "1"
ThisDrawing.SendCommand " "

lonelyhero 发表于 2005-5-7 13:12:00

acad_iso10w100 还没有加载吧?

流浪狗 发表于 2005-5-7 14:00:00

行吗?怎样加载?

hangc 发表于 2005-5-7 18:00:00

你使用如下方法:
Public Function SetCurLinetype(ByVal LineTypeName As String, ByVal strFile As String)
On Error goto hangc' trap any load errors
AcadDoc.Linetypes.Load LineTypeName, strFile '"acadiso.lin"
'=====================================================
Dim entry As Variant, found As Boolean
Dim newLineType As Variant
For Each entry In AcadDoc.Linetypes
                       If StrComp(entry.Name, LineTypeName, 1) = 0 Then
                                                       Set newLineType = entry
                                                       AcadDoc.ActiveLinetype = newLineType
                                                       Exit For
                       End If
Next
exit function
hangc:
               msgbox err
End Function
调用方法:
Dim curLineType As Variant
Set curLineType = AcadDoc.ActiveLinetype
SetCurLinetype "acad_iso10w100 ", "acadiso.lin"

流浪狗 发表于 2005-5-7 18:19:00


谢谢了!可是上面的方法由于我是新手,感觉很麻烦,很难理解,我就想用我的那种方法,可以吗?哪位高手能指教一下啊?非常感谢!!

流浪狗 发表于 2005-5-7 23:54:00

怎么没有人回答了,我急啊!

lonelyhero 发表于 2005-5-8 08:48:00

Dim entry As AcadLineType
                       Dim found As Boolean
                       found = False
                       For Each entry In ThisDrawing.Linetypes
                                                       If StrComp(entry.Name, "ACAD_ISO10W100", 1) = 0 Then
                                                                                       found = True
                                                                                       Exit For
                                                       End If
                       Next
                       If Not (found) Then ThisDrawing.Linetypes.Load "ACAD_ISO10W100", "acad.lin"

流浪狗 发表于 2005-5-8 19:09:00

我要的不是这个程序,而是我我最上面的那种方法能不能行的通?乐筑天下的高手在哪啊?

流浪狗 发表于 2005-5-8 19:42:00

郁闷!!!!

ljpnb 发表于 2005-5-8 20:20:00

7楼的是加载线型程序,如果没有加载过,当然需要这一步。我看1楼的格式也不对,当然不能正常运行。
Sub test()
        Dim entry As AcadLineType
                       Dim found As Boolean
                       found = False
                       For Each entry In ThisDrawing.Linetypes
                                                       If StrComp(entry.Name, "ACAD_ISO10W100", 1) = 0 Then
                                                                                       found = True
                                                                                       Exit For
                                                       End If
                       Next
                       If Not (found) Then ThisDrawing.Linetypes.Load "ACAD_ISO10W100", "acad.lin"
ThisDrawing.SendCommand "-layer" & vbCr & "m" & vbCr & "1" & vbCr & "c" & vbCr & "2" _
       & vbCr & "1" & vbCr & "l" & vbCr & "acad_iso10w100" & vbCr & "1" & vbCr & "" & vbCr
End Sub
页: [1]
查看完整版本: [求助]急!求助!关于在VBA中使用ACAD命令行的问题