- 积分
- 24557
- 明经币
- 个
- 注册时间
- 2004-3-17
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2004-5-12 01:17:00
|
显示全部楼层
本帖最后由 作者 于 2004-5-12 15:39:02 编辑
将VLAX类的EvalLispExpression子程改动一下可以实现- Public Function EvalLispExpression(lispStatement As String)
- On Error GoTo ErrClear
- Dim sym As Object, ret As Object, retVal
- EvalLispExpression = ""
- Set sym = VLF.Item("read").funcall(lispStatement)
- retVal = VLF.Item("eval").funcall(sym)
- EvalLispExpression = retVal
- ErrClear:
- Err.Clear
- End Function
总觉得VLAX类不太健壮测试(插入一个块,拖动并旋转):先导入Lisp函数dd,再生成一个名为"123"的块- Sub Test()
- On Error Resume Next
- Dim obj As VLAX, retVal
- Dim a As String, b
- Dim c(2) As Double, d(2) As Double
- Dim pObj As AcadBlockReference, pLine As AcadLine
- Set obj = New VLAX
- retVal = obj.EvalLispExpression("(dd)")
- Set obj = Nothing
- a = Split(retVal, ",")(0)
- Err.Clear
- Set pObj = ThisDrawing.ModelSpace.InsertBlock(c, "123", 1, 1, 1, 0)
- ThisDrawing.Utility.Prompt vbCr & "请输入插入点:" & vbCr
- Do While a <> "3"
- Set obj = New VLAX
- retVal = obj.EvalLispExpression("(dd)")
- Set obj = Nothing
- a = Split(retVal, ",")(0)
- Err.Clear
- If a = 5 Then
- b = Split(retVal, ",")
- Err.Clear
- c(0) = b(1)
- c(1) = b(2)
- pObj.InsertionPoint = c
- Err.Clear
- End If
- Loop
- a = 5
- ThisDrawing.Utility.Prompt vbCr & "请输入旋转角度:" & vbCr
- Set pLine = ThisDrawing.ModelSpace.AddLine(c, d)
- Do While a <> "3"
- Set obj = New VLAX
- retVal = obj.EvalLispExpression("(dd)")
- Set obj = Nothing
- a = Split(retVal, ",")(0)
- Err.Clear
- If a = 5 Then
- b = Split(retVal, ",")
- Err.Clear
- c(0) = b(1)
- c(1) = b(2)
- pLine.EndPoint = c
- pObj.Rotation = ThisDrawing.Utility.AngleFromXAxis(pObj.InsertionPoint, c)
- Err.Clear
- End If
- Loop
- pLine.Delete
- End Sub
Lisp函数- (defun dd()
- (setq a (grread t))
- (if (OR (= 3 (car a)) (= 5 (car a)))
- (setq str (strcat (itoa (car a))
- ","
- (rtos (caadr a) 2 4)
- ","
- (rtos (cadadr a) 2 4)
- ","
- (rtos (cadr (cdadr a)) 2 4)
- )
- )
- )
- (IF (OR (= 2 (car a)) (= 11 (car a)))
- (setq str (strcat (itoa (car a))
- ","
- (itoa (cadr a))
- )
- )
- )
- str
- )
|
评分
-
参与人数 1 | 威望 +1 |
金钱 +10 |
贡献 +5 |
激情 +5 |
收起
理由
|
mccad
| + 1 |
+ 10 |
+ 5 |
+ 5 |
【精华】好程序 |
查看全部评分
|