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

What is the problem with this.

3 REPLIES 3
Reply
Message 1 of 4
ozitag
249 Views, 3 Replies

What is the problem with this.

Hi guys,

I'm just learning a little Lisp and thought I's do a program that replaces circles with a point at the center. I have this, which works to a certain extent, but it always comes up with unknown command "PNTS" for each loop through the while, then it crashes out in the princ function with ;error: bad argument type: FILE.  Then it prints cntr.

Any help would be great.

Here is what I have.

 

(defun c:pnts()
  (if (setq circleset(ssget (list (Cons 0 "CIRCLE")))) ;get set of circles
    (progn
      (setq cntr 0) ;set counter to first item in set
      (while (< cntr (sslength circleset)) ;while counter is less than the length of the set
    (setq item(ssname circleset cntr)) ;get entity name of the item indexed
    (setq itemcodes(entget item)) ;get items group codes
    (entdel item) ;delete circle
    (setq cpnt (cdr (assoc 10 itemcodes))) ;get center point of item
    (command "point" cpnt "") ;place point at point
    (setq cntr (+ cntr 1)) ;increment counter
    ) ;close while
      (princ "\nCircles changed: " cntr) ;print the number of circles after new line
      ) ;close progn
    (alert "No circles selected")
    ) ;close if
  (princ)
  ) ;close defun

IV 2010
3 REPLIES 3
Message 2 of 4
pbejse
in reply to: ozitag


@ozitag wrote:

Hi guys,

I'm just learning a little Lisp and thought I's do a program that replaces circles with a point at the center. I have this, which works to a certain extent, but it always comes up with unknown command "PNTS" for each loop through the while, then it crashes out in the princ function with ;error: bad argument type: FILE.  Then it prints cntr.

Any help would be great.

Here is what I have.

 

 


 

(command "point" cpnt )....

...

(princ (strcat "\nCircles changed: " (itoa cntr)))....

Message 3 of 4
ozitag
in reply to: pbejse

Thanks heaps for that. Now it works perfectly.

I was wondering what the inverted commas were in (command "point" cpnt "") Obviously they are not required for what I want. What are they for?

Thanks again

IV 2010
Message 4 of 4
pbejse
in reply to: ozitag


@ozitag wrote:

Thanks heaps for that. Now it works perfectly.

I was wondering what the inverted commas were in (command "point" cpnt "") Obviously they are not required for what I want. What are they for?

Thanks again


 

 

Those are double quotations, it's like pressing "Enter" on the keyboard. In this case, an extra return that causes the error,  some functions require them and some not. , that is why most of the time i shy away from the use command function and take the entmake/vla route when creating new entities.

 

Glad i could help

 

Cheers

 

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

Post to forums  

Autodesk Design & Make Report

”Boost