Jump to content

Commands vrom VLX in Lisp


M76

Recommended Posts

Hi

 

I'm trying to run a command inside a lisp, that is loaded from a vlx file into autocad. But it gives me an unkown command error. If I simply run it from the command line it works, but not through a lisp. Do I need to do something extra for the command to be avaialable from a lisp? I don't have access to the source of the vlx.

Link to comment
Share on other sites

  • 6 months later...

So you are stuck with this construct?

 

[b][color=Blue](defun c:test (/ str)
 (setq str (getstring "\nEnter a String: "))
 (print str)
 (princ))[/color][/b]

(defun CallTest nil
[b][color=Red]  (c:test)[/color][/b]
 [b][color=Green](princ)[/color][/b])

This causes a problem as when the 'test' function is called (red), the blue code is evaluated, and the green code is not evaluated until the blue code is completed.

 

Lee

Link to comment
Share on other sites

You're not giving a lot of information. However, it sounds like the vlx prompts for selection and a few questions.

 

What you could do is create your selection, then feed the selection and other required parameters to the routine through vla-sendcommand (I know I plug this command a lot).

 

eg.

 

ssget (no pickfirst)

(defun c:Test (/ ss)
 (if (setq ss (ssget "_:L"))
   (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "CommandName !ss Y N 0.5 ")))

ssget (with pickfirst available)

(defun c:Test (/ ss)
 (and (setq ss (ssget "_:L"))
      (sssetfirst nil ss)
      (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "CommandName Y N 0.5 ")))

entsel

(defun c:Test (/ e)
 (if (setq e (car (entsel)))
   (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object))
     "CommandName !e Y N 0.5 ")))

 

Oh yeah, and if in a situation where a space " " will not force the command to continue (ie: (getstring T "\nEnter String: ") ), you can replace the " " with "\n", which will act the same as if the user pressed the Enter key.

Link to comment
Share on other sites

I need to write a little explanation on using vla-sendcommand. I swear I mention/explain it and load/autoload all the time. LOL

Link to comment
Share on other sites

Thanks for the tips, I ended up copying the command into the same lsp, and editing it to work as a function.

 

'copying the command into the same lsp'

 

? :huh:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...