VLA- newbie question

VLA- newbie question

Anonymous
Not applicable
187 Views
1 Reply
Message 1 of 2

VLA- newbie question

Anonymous
Not applicable
I tried asking this over in Customization Lisp ng. Didn't get one response. Maybe I can get someone here to help me.
Since the VLA functions are based on VBA expressions then I don't guess this would be considered too off topic.

I'm trying my hand for the first time at the VLA- functions. I'm trying to make it open up the current directory when I want to attach an xref. Kind of like Frank Whaleys opendwg function, only I want to use more of the VLA functions instead of mixing plain autolisp within it.
Here's what I've done, so far.

(defun C:XRFDR ()
(vl-load-com)
(setq xrfpic (getfiled "Select Dwg" (getvar "dwgprefix") "dwg" 16)
(if (= 0 (getvar "SDI"))
(command
"_.VBASTMT"
(strcat ("AcadApplication.Documents.open \"" xrfpic "\"")
)
(vla-sendcommand
(vla-get-ModelSpace
(vla-get-activedocument (vlax-get-acad-object))
)
(vla-AttachExternalReference (xrfpic "0,0" "" "" "" ""))
)
)
)
)
(princ)
)

TIA
Robert Davis
0 Likes
188 Views
1 Reply
Reply (1)
Message 2 of 2

Ed__Jobe
Mentor
Mentor
I don't have too much time right now, but here's a quick reply to get you started. The vba SendCommand method you're using works alot differently than the lisp (command) function. First, it only takes string arguments. Second, is runs asyncronously, you don't know when it will run, usually after all other code is finished. Finally, you can't use the SendCommand method to run methods, just what you would type at the command line. A method, like AttachExternalReference must be executed using the object that owns it. In vba the syntax is Object.Method (arguments). In lisp, the syntax is usually (method (object)(arguments)).

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes