Lisp that runs external .vlx and gives required inputs

Lisp that runs external .vlx and gives required inputs

pablo.odriozola
Contributor Contributor
860 Views
8 Replies
Message 1 of 9

Lisp that runs external .vlx and gives required inputs

pablo.odriozola
Contributor
Contributor

Hi there,

I'm trying to speed up the use of a .vlx I found online by creating a lisp that runs it and gives the values the program is asking for.

If I write (c:xoffset) in the lisp file, the program runs normally and asks the user to specify some values.

What I tried afterwards was to write (c:xoffset "1") for example, so that the first value is automatically given, but I get the error that there are "too many arguments".

What would be the right way to do this?

Thanks

0 Likes
Accepted solutions (1)
861 Views
8 Replies
Replies (8)
Message 2 of 9

ВeekeeCZ
Consultant
Consultant
Accepted solution

That way it never works. Try something like this

 

(vl-load-com)
(defun c:xo1 ( / s)
  (if (setq s (ssget))
    (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) (strcat "xoffset _p  1 ")))
  (princ)
  )

 

The thing is, that there is no simple way to call LISP command with arguments from another LISP routine. If the routine is appropriately designed so that routine has some sub that you can all, it could look something like (xoffset ss 1 ...) but you need to know what arguments it requires...

 

If you want a simple way, you can use a MACRO. 

0 Likes
Message 3 of 9

john.uhden
Mentor
Mentor

@pablo.odriozola 

What does XOFFSET do and where did you find it?

John F. Uhden

0 Likes
Message 4 of 9

pablo.odriozola
Contributor
Contributor

It's similar to LeeMac's Dynamic Offset routine (less advanced though), but I decided to use this "xoffset" instead because I thought it would be easier to customize to my needs. It lets you offset multiple lines/polylines inwards or outwards. Additionally you can specify the number of offsets it generates at once and the destination layer, or other things like deleting the original lines.

0 Likes
Message 5 of 9

Sea-Haven
Mentor
Mentor

Like John do you need a vlx version ? There is more than likely an open coded version of what the program is doing, I know have written a few multi offset.

 

So again explain clearly what it is doing.

0 Likes
Message 6 of 9

reb0265
Contributor
Contributor

@pablo.odriozola 
Hey Just checking in on this. I am currently working on what I believe is a similar issue. I have a .VLX program that requires inputs typed into the command line. Curious how exactly you ended up doing this for your issue. I am new to the CAD automations game and still learning!

I have been trying to write a lisp to do this and have not had success. Trying to get a lisp to work so i can run it through script pro on a batch of dwg files.

0 Likes
Message 7 of 9

Sea-Haven
Mentor
Mentor

If some one went to the trouble of making a vlx they dont want their code to be exposed, so did you ask who wrote the vlx if it could be modified to allow for input with defined variables.

0 Likes
Message 8 of 9

reb0265
Contributor
Contributor

Looks like you found my other post!

I have a note out to the owner of the vlx program as well. There are other variables in the program so shouldn't be too bad to add.

I wrote a very clunky code that worked, but not pretty.

0 Likes
Message 9 of 9

john.uhden
Mentor
Mentor

@reb0265 ,

I am pretty sure that you can use the (vlax-add-cmd) function to make an AutoCAD type command from a defined function.  That way you could use it in a script to feed it the required inputs in the proper order.

BUT if the function requires DCL input, you're stuck.

Not sure, but I think you will have to add the vlax-add-cmd after every time you load the function (probably in your acaddoc.lsp file).

John F. Uhden

0 Likes