Author Topic: Error in Command  (Read 1500 times)

0 Members and 1 Guest are viewing this topic.

Nima2018

  • Newt
  • Posts: 30
Error in Command
« on: April 26, 2018, 11:45:46 AM »
Hi guys
I have a command on the road of button click in a opendcl form but I get an error message on the command line .
Here is my Command :
Code: [Select]
(command "_chprop" ssget "" "lt" (getvar "celtype") "")
I chose my linetype from listbox and I get this error message :

Select objects: 1 found
Select objects:
; error: invalid AutoCAD command: nil

What should I do to fix this error?

kpblc

  • Bull Frog
  • Posts: 396
Re: Error in Command
« Reply #1 on: April 26, 2018, 11:51:30 AM »
I think you missed some symbols:
Code - Auto/Visual Lisp: [Select]
  1. (command "_chprop" (ssget) "" "lt" (getvar "celtype") "")
Sorry for my English.

Nima2018

  • Newt
  • Posts: 30
Re: Error in Command
« Reply #2 on: April 26, 2018, 02:08:20 PM »
Thanks kpblc for your replay .

I changed the command code about "chprop" with the following code and got rid of the error !

Code: [Select]


(if (!= (setq A (ssget)
      nil
)
    )
  (repeat (setq i (sslength A))
    (setq sn (ssname A (setq i (1- i))))
    (setq obj (vlax-ename->vla-object sn))
    (setq check (vlax-property-available-p obj "LineType" T))
    (if check
      (progn
(vlax-put-property obj 'linetype (getvar "celtype"))
(princ "\n")
(vla-regen
  (vla-get-activedocument
    (vlax-get-acad-object)
  )
  acactiveviewport
)
      )
    )
  )
)


If someone has a better way, please advise me .

kpblc

  • Bull Frog
  • Posts: 396
Re: Error in Command
« Reply #3 on: April 26, 2018, 02:15:52 PM »
I think you mixed C++ / C# and LISP. != in C# is /= in lisp :)
Code - Auto/Visual Lisp: [Select]
  1. (if (= (type (setq selset (vl-catch-all-apply (function (lambda () (ssget "_:L")))))) 'pickset)
  2.   (progn (foreach ent (mapcar (function vlax-ename->vla-object)
  3.                               ((lambda (/ item tab)
  4.                                  (repeat (setq tab  nil
  5.                                                item (sslength selset)
  6.                                                ) ;_ end setq
  7.                                    (setq tab (cons (ssname selset (setq item (1- item))) tab))
  8.                                    ) ;_ end of repeat
  9.                                  ) ;_ end of LAMBDA
  10.                                )
  11.                               ) ;_ end of mapcar
  12.            (if (vlax-property-available-p ent 'linetype)
  13.              (vla-put-linetype ent (getvar "celtype"))
  14.              ) ;_ end of if
  15.            ) ;_ end of foreach
  16.          (vla-regen (vla-get-activedocument (vlax-get-acad-object)) acactiveviewport)
  17.          ) ;_ end of progn
  18.   ) ;_ end of if
Sorry for my English.

Nima2018

  • Newt
  • Posts: 30
Re: Error in Command
« Reply #4 on: April 26, 2018, 02:21:58 PM »
Dear kpbc

Because of my habit I've written code for it in autolisp, Anyway, thanks you for telling me  about my mistakes .

kpblc

  • Bull Frog
  • Posts: 396
Re: Error in Command
« Reply #5 on: April 26, 2018, 02:23:40 PM »
Not at all :) Last 3 years I'm trying to start write code in C# - and I can't do it :)
Sorry for my English.