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
@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)))....
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
@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