Author Topic: Error in use of command  (Read 376 times)

Nima2018

  • Member
  • *
  • Posts: 3
Error in use of command
« 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 ?
« Last Edit: April 18, 2018, 10:49:42 AM by Nima2018 »

Fred Tomke

  • OpenDCL Technician
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2045
  • [ Mr. Bad Guy ]
    • Kommunale Entwicklungsplanung auf digitaler Basis - digital landscape and urban design
Re: Error in use of command
« Reply #1 on: April 18, 2018, 10:57:31 AM »
Hi,
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

  • Member
  • *
  • Posts: 28
Re: Error in use of command
« Reply #2 on: April 18, 2018, 10:06:09 PM »
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

  • Member
  • *
  • Posts: 3
Re: Error in use of command
« Reply #3 on: April 19, 2018, 10:10:52 AM »
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 :

Code: [Select]
(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 :

Code: [Select]
(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.
« Last Edit: April 19, 2018, 10:44:16 AM by Nima2018 »

Tharwat

  • Member
  • *
  • Posts: 28
Re: Error in use of command
« Reply #4 on: April 19, 2018, 10:41:02 AM »
Hi,
Try to use the function vla-sendcommand in lieu of command call.

Let me know if that function works for you.

Nima2018

  • Member
  • *
  • Posts: 3
Re: Error in use of command
« Reply #5 on: April 19, 2018, 11:16:05 AM »
Dear Tharwat Thanks for your advice.
 I used the following instructions on the advice of you :

Code: [Select]

(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"
« Last Edit: April 19, 2018, 11:18:15 AM by Nima2018 »

Tharwat

  • Member
  • *
  • Posts: 28
Re: Error in use of command
« Reply #6 on: April 19, 2018, 11:44:31 AM »
Please try it like the following:

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