兰州人 发表于 2009-4-28 13:55:00

vba调用lsp涉及到的"""和chr(34)的用法

<p>在VBA中,直接写(command "Stretch" "c" pause pause "")不成立。</p><p>例如语句中的"Stretch"&nbsp;等价写法是chr(34) &amp; "Stretch" &amp; chr(34)</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;也可以等价写法"""Stretch"""&nbsp; ,"""在CAD命令行中得到的结果为一个双引号"</p><p>Sub ls()<br/>&nbsp; With ThisDrawing<br/>&nbsp;&nbsp;&nbsp; .SendCommand "(command " &amp; """Stretch""" &amp; " ""c"" " &amp; "pause pause " &amp; """""" &amp; ")"<br/>&nbsp; End With<br/>End Sub<br/>程序运行结果等价LISP在CAD命令行中的</p><p>(command "Stretch" "c" pause pause "")</p>

兰州人 发表于 2009-4-28 15:47:00

扩展使用

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]
查看完整版本: vba调用lsp涉及到的"""和chr(34)的用法