明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2798|回复: 12

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

  [复制链接]
发表于 2005-5-7 13:05:00 | 显示全部楼层 |阅读模式
本人用以下两种方法欲使用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 " "
发表于 2005-5-7 13:12:00 | 显示全部楼层
acad_iso10w100 还没有加载吧?
 楼主| 发表于 2005-5-7 14:00:00 | 显示全部楼层
行吗?怎样加载?
发表于 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 19:20:27 编辑

谢谢了!可是上面的方法由于我是新手,感觉很麻烦,很难理解,我就想用我的那种方法,可以吗?哪位高手能指教一下啊?非常感谢!!
 楼主| 发表于 2005-5-7 23:54:00 | 显示全部楼层
怎么没有人回答了,我急啊!
发表于 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 | 显示全部楼层
郁闷!!!!
发表于 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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-27 17:44 , Processed in 0.172713 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表