明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1979|回复: 1

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

[复制链接]
发表于 2009-4-28 13:55:00 | 显示全部楼层 |阅读模式

在VBA中,直接写(command "Stretch" "c" pause pause "")不成立。

例如语句中的"Stretch" 等价写法是chr(34) & "Stretch" & chr(34)

           也可以等价写法"""Stretch"""  ,"""在CAD命令行中得到的结果为一个双引号"

Sub ls()
  With ThisDrawing
    .SendCommand "(command " & """Stretch""" & " ""c"" " & "pause pause " & """""" & ")"
  End With
End Sub
程序运行结果等价LISP在CAD命令行中的

(command "Stretch" "c" pause pause "")

 楼主| 发表于 2009-4-28 15:47:00 | 显示全部楼层
扩展使用
  1. Sub ls1()
  2.   With ThisDrawing
  3.      Dim Ent  As AcadDimension
  4.    Dim kwordList As String
  5.     kwordList = "Up Down Left Right"
  6.     .Utility.InitializeUserInput 1, kwordList
  7.     Dim returnString As String
  8.     returnString = .Utility.GetKeyword("Enter a keyword (Up)(Down)(Left)(Right): ")
  9.    
  10.     Dim objDim As AcadDimRotated
  11.     .Utility.GetEntity objDim, pt, "ddd"
  12.    
  13.     Debug.Print returnString
  14.     With objDim
  15.       tt = Abs(.Measurement - .TextOverride)
  16.       Select Case returnString
  17.         Case "Up"
  18.           tt = "@0," & tt
  19.         Case "Down"
  20.           tt = "@0,-" & tt
  21.         Case "Left"
  22.           tt = "@-" & tt & ",0"
  23.         Case "Right"
  24.           tt = "@" & tt & ",0"
  25.       End Select
  26.       
  27.       .TextOverride = ""
  28.     End With
  29.     .SendCommand "(setq ee " & Chr(34) & tt & Chr(34) & ")" & vbCr
  30.     '.SendCommand "(command " & """Stretch""" & " ""c"" " & "pause pause " & """""" & " pause " & """""" & " ee)" & vbCr
  31.     .SendCommand "(command " & """Stretch""" & " ""c"" " & "pause pause " & """""" & " pause ee)" & vbCr
  32.    End With
  33. End Sub
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-26 03:37 , Processed in 0.152344 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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