I am trying to find a way to send a cell value to a activated command at the command line.
Basically, I have a excel file with structure names in Column A1- A20. I want to select the cell of A2 and send that cell value to a lisp routine which is ready to go at the command line with the A2 value.
I am having a dog of a time trying to piece all of this together to work. So the code i have with the Excel Macro is the following:
Excel file is saved as a xlsm. with the References - VBAProject as (AutoCAD 2019 Type Library)
Sub Zoom2Structure()
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
AcadApp.ActiveDocument.SendCommand "zm2st" & vbCr
End Sub
The following lisp routine which works.
(defun c:zm2st (/ C3D C3DDOC LOCATION NTWRK
NTWRKS PROD PRODSTR PT STRC
STRCNAME STRUCTURES
)
(vl-load-com)
(if (setq C3D (strcat "HKEY_LOCAL_MACHINE\\"
(if vlax-user-product-key
(vlax-user-product-key)
(vlax-product-key)
)
)
C3D (vl-registry-read C3D "Release")
C3D (substr
C3D
1
(vl-string-search "." C3D (+ (vl-string-search "." C3D) 1))
)
C3D (vla-getinterfaceobject
(vlax-get-acad-object)
(strcat "AeccXUiPipe.AeccPipeApplication." C3D)
)
C3Ddoc (vla-get-activedocument C3D)
)
(progn
(setq ntwrks (vlax-get c3ddoc 'pipenetworks))
(setq strcname (getstring "\nStructure name to zoom to: " t))
(vlax-for ntwrk ntwrks
(if (not strc)
(progn
(vl-catch-all-apply
'(lambda ()
(setq structures (vlax-get ntwrk 'structures))
(setq strc (vlax-invoke structures 'item strcname))
)
'()
)
)
)
)
(if strc
(progn
(setq location (vlax-get strc 'position))
(setq pt (list (vlax-get location 'x) (vlax-get location 'y)))
(command "zoom" "c" pt "40")
)
(progn
(princ (strcat "\nStructure \"" strcname "\" not found."))
)
)
)
)
(princ)
)
Its great when you can reference old posts lol. Here are the two that the examples came from.
http://www.theswamp.org/index.php?topic=55042.0http://www.theswamp.org/index.php?topic=50025.0Thank you for any guidance! Again, i have no clue how to make these functions to work together.