Error in use of command

Started by Nima2018, April 18, 2018, 10:35:09 AM

Previous topic - Next topic

Nima2018

Hi members
I put a command in an opendcl button event click but in runtime an error
appears in Autocad prompts .
When I put this command outside of click event in top of my program it
works correctly , I want my Command to be inside of event click body
, what must I do ?

Fred Tomke

Hi,
Quote from: Nima2018 on April 18, 2018, 10:35:09 AM
Hi members
I put a command in an opendcl button event click but in runtime an error
appears in Autocad prompts .
When I put this command outside of click event in top of my program it
works correctly , I want my Command to be inside of event click body
, what must I do ?

without knowing your exact code I think this FAQ may help you.
http://opendcl.com/forum/index.php?topic=1080.0
Regards, Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

Tharwat

Hi,

You can not use command calls in events ( action_tile ) but you can replace the command with a function if available.
What's the command name that you are trying to use in the event?

Similar issue here: http://opendcl.com/forum/index.php?topic=2556.msg12677#msg12677

Nima2018

#3
Hi All
First of all, I thanks for your hints and reply , I learned a lot about "OPENDCL" programming in your points and links.
I really want to bring and execute an assembly that I have created in C# by the following commands :


(command "load" (findfile "myAssembly.dll")
(command "HTS")
;; HTS is command method in myAssembly.dll


When I cut (command "load" (findfile "myAssembly.dll") and paste it top of my program, all routines work but when this command is inside event button onclick,
at the prompt line I get and error !?
And in the case of the second command too , I must change it to below one to get rid of the error :


(princ)
(princ "\nType 'HTS' for execution")
(princ)

I think this is not a good method at all, and there must be a better and more effective one that I do not know about it.

Tharwat

Hi,
Try to use the function vla-sendcommand in lieu of command call.

Let me know if that function works for you.

Nima2018

#5
Dear Tharwat Thanks for your advice.
I used the following instructions on the advice of you :



(vla-sendcommand "load" (filefind "myAssembly.dll"))
(vla-sendcommand "HTS")



And this time I saw this error on the command line:  ;error : bad argument type : VLA-OBJECT "load"

Tharwat

Please try it like the following:


(if (setq file (findfile "myAssembly.dll"))
  (vla-SendCommand (vla-get-ActiveDocument (vlax-get-acad-object)) (strcat "LOAD " file))
  )