vba调用lsp涉及到的"""和chr(34)的用法
<p>在VBA中,直接写(command "Stretch" "c" pause pause "")不成立。</p><p>例如语句中的"Stretch" 等价写法是chr(34) & "Stretch" & chr(34)</p><p> 也可以等价写法"""Stretch""" ,"""在CAD命令行中得到的结果为一个双引号"</p><p>Sub ls()<br/> With ThisDrawing<br/> .SendCommand "(command " & """Stretch""" & " ""c"" " & "pause pause " & """""" & ")"<br/> End With<br/>End Sub<br/>程序运行结果等价LISP在CAD命令行中的</p><p>(command "Stretch" "c" pause pause "")</p> 扩展使用Sub ls1()
With ThisDrawing
Dim EntAs AcadDimension
Dim kwordList As String
kwordList = "Up Down Left Right"
.Utility.InitializeUserInput 1, kwordList
Dim returnString As String
returnString = .Utility.GetKeyword("Enter a keyword (Up)(Down)(Left)(Right): ")
Dim objDim As AcadDimRotated
.Utility.GetEntity objDim, pt, "ddd"
Debug.Print returnString
With objDim
tt = Abs(.Measurement - .TextOverride)
Select Case returnString
Case "Up"
tt = "@0," & tt
Case "Down"
tt = "@0,-" & tt
Case "Left"
tt = "@-" & tt & ",0"
Case "Right"
tt = "@" & tt & ",0"
End Select
.TextOverride = ""
End With
.SendCommand "(setq ee " & Chr(34) & tt & Chr(34) & ")" & vbCr
'.SendCommand "(command " & """Stretch""" & " ""c"" " & "pause pause " & """""" & " pause " & """""" & " ee)" & vbCr
.SendCommand "(command " & """Stretch""" & " ""c"" " & "pause pause " & """""" & " pause ee)" & vbCr
End With
End Sub
页:
[1]