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

Strange behaviour with LISP and polylines

1 REPLY 1
Reply
Message 1 of 2
Anonymous
196 Views, 1 Reply

Strange behaviour with LISP and polylines

Hi,

For quite a long time that I have been working with this modified LISP from LeeMac:

 

(defun c:eg02 ( / lst-str pl4ext name_lines actual_name nomebase s l)

	(defun lst-str (lst del / st strout)
	 (setq strout (car lst))
	 (foreach st (cdr lst)
	  (setq strout (strcat strout del st))
	 )
	 strout
	)

	(defun pl4ext ( / f i o )
		(if
			(setq f (open actual_name "w"))
			(progn
				(repeat (setq i (sslength s))
					(setq o (vlax-ename->vla-object (ssname s (setq i (1- i)))))
					(princ
						(apply 'strcat
							(vl-list*
								"\n\n+Layer+" (vla-get-layer o)
								"\n+ObjHd+" (vla-get-handle o)
								"\n+Width+" (rtos (vla-get-constantwidth o)) "\n"
								(   (lambda ( a ) (a (vlax-get o 'coordinates)))
									(lambda ( b )
										(if b
											(cons
												(strcat "+"(rtos (car b)) "," (rtos (cadr b)) "\t")
												(a (cddr b))
											)
										)
									)
								)
							)
						)
						f
					)
				)
				(close f)
			)
		)
		(princ)
	)

	(setq nomebase (getstring "\nInsert name:"))
	(setq name_lines (strcat nomebase "_ln.txt"))
	
	(setq l "LINES")
	(setq s (ssget "_X" (list '(0 . "LWPOLYLINE") (cons 8 (strcat l "*")))))
	(princ s)
	(setq actual_name name_lines)
	(pl4ext)
		
  (princ)
)
	
(vl-load-com) (princ)

 

 

Suddenly, on a new drawing, it has just started to give me the error message

 

"; error: Automation Error. Invalid input"

 

This LISP is supposed to extract all the polylines and some related info from them.

 

Anyone?

1 REPLY 1
Message 2 of 2
_Tharwat
in reply to: Anonymous

You should have LWpolyline on layer LINES****** to let the code works as expected . Smiley Wink

 

and to avoid this error to to be prompted when it does not match the above said issues , just add if function like this .

 

  (if (setq s (ssget "_X"
                     (list '(0 . "LWPOLYLINE") (cons 8 (strcat l "*")))
              )
      )
    (progn
      (princ s)
      (setq actual_name name_lines)
      (pl4ext)
    )
  )

 

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

Post to forums  

Autodesk Design & Make Report

”Boost