Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

What is wrong with this vl-cmdf

5 REPLIES 5
Reply
Message 1 of 6
schumi
976 Views, 5 Replies

What is wrong with this vl-cmdf

Hi All,

Can you please tell me what is wrong in my LISP code?

(defun c:test ()

(setq p1 '(10 10 0))
(setq p2 '(200 10 0))
(vl-cmdf "line" p1 p2 "")
(vl-cmdf "rotate" (entlast) "" p1 30)

)

AutoCAD returns:-

Application ERROR: Invalid type sent as command input
Application ERROR: Invalid type sent as command input
nil

But same code executes with command

(defun c:turn ()

(setq p1 '(10 10 0))
(setq p2 '(200 10 0))
(command "line" p1 p2 "")
(command "rotate" (entlast) "" p1 30)

)

Why is such behaviour? I think I am making some mistake can you please help me?

Schumi
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: schumi

This command works good with
correct types of arguments only
You can pass in VL-CMDF list of doubles
instead of integers, the same with
rotation angle:

[code]
(setq p1 '(10. 10. 0.))
(setq p2 '(200. 10. 0.))
(vl-cmdf "._line" p1 p2 "")
(vl-cmdf "._rotate" (entlast) "" p1 30.0)
[/code]

~'J'~
Message 3 of 6
Anonymous
in reply to: schumi

Forget to say about better yet
to pass all arguments explicitly:

(setq p1 '(10. 10. 0.))
(setq p2 '(200. 10. 0.))
(vl-cmdf "._line" p1 p2 "")
(setq ln (entlast))
(vl-cmdf "._rotate" ln "" p1 30.0)

~'J'~
Message 4 of 6
schumi
in reply to: schumi

Hi Fatty,

Thank you very much for reply. But why does data type matters so much in vl-cmdf? Is this a feature of vl-cmdf?
Is vl-cmdf only works with real data types?

I am still confused. Please guide me.

Schumi
Message 5 of 6
Anonymous
in reply to: schumi

Sorry for my poor explanation
The main difference of function 'vl-cmdf' from function 'command' is in that,
that internal tool AutoCAD checks all arguments
till time of performance of this function, also sends in command
line already all these checked up arguments, whereas function
'command' sends all arguments in command
line separately one behind another without check on a correctness in runtime
and check occurs during performance of function
'command'
Thus, you need to define all variables before
you'll pass these arguments in the vl-cmdf function
Of course, as the correct type only, say double, string,
entity name, etc.
IOW, you can't to change double on integer as
in this particular case you showed

Hope this make a sence

~'J'~
Message 6 of 6
Anonymous
in reply to: schumi

Hi schumi,
Look at this code, different test1 and test2 is number with integer and
real.
[code]
(defun c:test1 (/ p1 p2 el) ; it's would get error
(setq p1 '(0 0 0))
(setq p2 '(10 10 0))
(vl-cmdf "_line" p1 p2 "")
(setq el (entlast))
(vl-cmdf "_rotate" el "" p1 30)
(princ)
)

(defun c:test2 (/ p1 p2 el) ; it's OK
(setq p1 '(0.0 0.0 0.0))
(setq p2 '(10.0 10.0 0.0))
(vl-cmdf "_line" p1 p2 "")
(setq el (entlast))
(vl-cmdf "_rotate" el "" p1 30)
(princ)
)
[/code]

wrote in message news:5701225@discussion.autodesk.com...
Hi Fatty,

Thank you very much for reply. But why does data type matters so much in
vl-cmdf? Is this a feature of vl-cmdf?
Is vl-cmdf only works with real data types?

I am still confused. Please guide me.

Schumi

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost