找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 867|回复: 3

[VBA程序]:请教?

[复制链接]
发表于 2002-10-11 11:42:46 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
请教:如何用sendcommand命令来调用lisp函数?
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

已领礼包: 145个

财富等级: 日进斗金

发表于 2002-10-11 11:47:01 | 显示全部楼层
给你贴个小程序,看看里面的用法


  1. [FONT=courier new]
  2. Private Sub useLispToGetSelectionSet()
  3.    
  4.    ' Declare variables
  5.    Dim ssnew As AcadSelectionSet
  6.    Dim setcount As Integer
  7.    Dim xDel As Integer

  8.    ' Remove all selectionsets, include this
  9.    ' if the SelectionsSet named Layout1 already exists
  10.    setcount = ThisDrawing.SelectionSets.Count
  11.    For xDel = 0 To setcount - 1
  12.         ThisDrawing.SelectionSets.Item(xDel).Delete
  13.    Next xDel
  14.    
  15.    ' Make a new selection set
  16.    Set ssnew = ThisDrawing.SelectionSets.Add("Layout1")
  17.    
  18.    ' Use SendCommand to send a Lisp routine to put the objects
  19.    ' in Model space in a selection set, you can change "Model" to the
  20.    ' name of the Layout to put the entities on that layout in the
  21.    ' selection set
  22.    ThisDrawing.SendCommand ("(Setq ss1(ssget " & Chr(34) & "X" & Chr(34) & _
  23.    "'((410 . " & Chr(34) & "Model" & Chr(34) & "))))" & vbCr)
  24.   
  25.    ' Make the selection set ssnew the last selection set
  26.    ' created above
  27.    ssnew.Select acSelectionSetPrevious
  28.    
  29.    ' Display a message box reporting the number of entities
  30.    ' in the Selection set
  31.    MsgBox "Number of entities in ssnew: " & ssnew.Count
  32.    
  33.    ' Delete the Seletion Set
  34.    ssnew.Delete

  35. End Sub[/FONT]
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 145个

财富等级: 日进斗金

发表于 2002-10-11 11:49:40 | 显示全部楼层
再贴一个,这个里面用了如何调用setvar


  1. [FONT=courier new]
  2. Public Sub getMyEntityData()
  3.     Dim myObj As AcadObject
  4.     Dim ss1 As AcadSelectionSet
  5.     Dim entHandle As String

  6.     Set ss1 = ThisDrawing.SelectionSets.Add("test1")
  7.     ss1.SelectOnScreen

  8.     Set myObj = ss1(0)

  9.     entHandle = myObj.handle

  10.     ' Get the DXF code 0 of the object
  11.     ThisDrawing.SendCommand ("(setvar ""users1"" (cdr (assoc 0 (entget (handent
  12. """ & entHandle & """))))) ")
  13.     Debug.Print "assoc 0 of entity = " & ThisDrawing.GetVariable("users1")

  14.     ThisDrawing.SelectionSets("test1").Delete
  15. End Sub[/FONT]
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2002-10-14 10:20:06 | 显示全部楼层

谢谢

多谢晓东的指点
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2025-9-6 16:17 , Processed in 0.329375 second(s), 36 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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