太棒了。从我所看到的来看,我想我已经有了那部分代码。
这是VBA,我选择A20的单元格值“10”,然后选择功能区中的按钮。它现在激活CAD。
- Public Sub Test()
- Call MyFunction("test string")
- End Sub
-
- Public Function MyFunction(str As String)
- Debug.Print str
- End Function
- Public Sub Z2S(call as iRibbon)
- Call Z2STR("structName String")
- End Sub
- Public Function Z2STR(structName As String)
- On Error Resume Next
- Set AcadApp = GetObject(, "AutoCAD.Application")
- If Err Then
- Err.Clear
- Set AcadApp = CreateObject("AutoCAD.Application")
- End If
- AppActivate AcadApp.Caption
- AcadApp.Visible = True
- AcadApp.Application.WindowState = acNorm
- AcadApp.ActiveSpace = acModelSpace
- If AcadApp.Documents.Count = 0 Then
- AcadApp.Documents.Add
- End If
- '' Add this line
- ThisDrawing.SetVariable "USERS1", strucName
- AcadApp.ActiveDocument.SendCommand "zm2st" & vbCr
- End Function
但是,修改后的代码添加了“USERS1”变量,似乎会在lisp端出错。
- (defun c:zm2st (/ C3D C3DDOC LOCATION NTWRK
- NTWRKS PROD PRODSTR PT STRC
- STRCNAME STRUCTURES USERS1
- )
- ....
- (setq ntwrks (vlax-get c3ddoc 'pipenetworks))
- ;;(setq strcname (getstring "\nStructure name to zoom to: " t))
- (setq strucname (getvar "USERS1"))
- (vlax-for ntwrk ntwrks
- ....
- command:.... ; error: bad argument type: stringp nil
越来越近lol。
|