I have a very strange problem in autolisp ...

I have a very strange problem in autolisp ...

michael
Explorer Explorer
702 Views
6 Replies
Message 1 of 7

I have a very strange problem in autolisp ...

michael
Explorer
Explorer
The (cons 10 x) is exactly (10 0.0 0.0 0.0), but this value in the entmake call causes an error. If i put the value direct, not from x, it works! Why?????????? (defun c:apl () (setq x (list 0.0 0.0 0.0)) (entmake '((0 . "POLYLINE") ; Object type (70 . 8) ; 3d polyline ) ) (entmake '((0 . "VERTEX") ; Object type (70 . 32) ; 3d polyline vertex (cons 10 x) ; Start point -----------------------------------got error here!!!!!!!!!!!!!!! ) ) (entmake '((0 . "VERTEX") ; Object type (70 . 32) ; 3d polyline vertex (10 4.0 6.0 1.0) ; Second point ) ) (entmake '((0 . "VERTEX") ; Object type (70 . 32) ; 3d polyline vertex (10 3.0 2.0 0.0) ; Third point ) ) (entmake '((0 . "SEQEND"))))
0 Likes
Accepted solutions (1)
703 Views
6 Replies
Replies (6)
Message 2 of 7

ВeekeeCZ
Consultant
Consultant

You cannot use '((cons x y)).

Apostrophe can be used only when there is nothing to evaluate! And there is CONS!

Use (list ... (cons x y))

0 Likes
Message 3 of 7

Shneuph
Collaborator
Collaborator

If you make a list like:

'((70 . 32))

 

You are literally typing in what the list is.  If you want to use (cons 10 var) like (cons 10 x) you need to use the list command like

(list '(70 . 31) (cons 10 x))

 

or

 

(list (cons 70 32) (cons 10 x))

 

(Defun c:apl ()
   (setq x (list 0.0 0.0 0.0))
   (entmake '((0 . "POLYLINE") ; Object type
	      (70 . 8) ; 3d polyline
	      )
	    )
   (entmake (list '(0 . "VERTEX") ; Object type
	      '(70 . 32) ; 3d polyline vertex
	      (cons 10 x) ; Start point -----------------------------------got error here!!!!!!!!!!!!!!!
	      );list
	    );entmake
   (entmake '((0 . "VERTEX") ; Object type
	      (70 . 32) ; 3d polyline vertex
	      (10 4.0 6.0 1.0) ; Second point
	      )
	    )
   (entmake '((0 . "VERTEX") ; Object type
	      (70 . 32) ; 3d polyline vertex
	      (10 3.0 2.0 0.0) ; Third point
	      )
	    )
   (entmake '((0 . "SEQEND"))))
---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
0 Likes
Message 4 of 7

marko_ribar
Advisor
Advisor

You need to let lisp evaluate list that is supplied in entmake call... Only literal lists without variables can be processed through ' apostrophe symbol inside expression...

So you need to replace this line :

(entmake '((0 . "VERTEX") ; Object type (70 . 32) ; 3d polyline vertex (cons 10 x) ; Start point -----------------------------------got error here!!!!!!!!!!!!!!! ) )

With this :

(entmake (list '(0 . "VERTEX") ; Object type '(70 . 32) ; 3d polyline vertex (cons 10 x) ; Start point) )

 

HTH

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 5 of 7

michael
Explorer
Explorer
Hi! Thanx to all, but is still not working. Now without error messages, only ignoring the first vertex: (Defun c:apl () (entmake '((0 . "POLYLINE") (62 . 5) (66 . 1) (70 . 8) ) ) (setq x (list 0.0 0.0 0.0) (entmake (list '(0 . "VERTEX") '(70 . 32) (cons 10 x) ) (entmake '((0 . "VERTEX") (70 . 32) (10 1.0 1.0 0.0) ) ) (entmake '((0 . "VERTEX") (70 . 32) (10 4.0 6.0 0.0) ) ) (entmake '((0 . "VERTEX") (70 . 32) (10 3.0 2.0 0.0) ) ) (entmake '((0 . "SEQEND"))) )
0 Likes
Message 6 of 7

ВeekeeCZ
Consultant
Consultant
Accepted solution

Wrong parenthesis.

 

Spoiler
(Defun c:apl ()
  (entmake '((0 . "POLYLINE")
	     (62 . 5)
	     (66 . 1)
	     (70 . 8)))
  
  (setq x (list 0.0 0.0 0.0))

  (entmake (list '(0 . "VERTEX")
		 '(70 . 32)
		 (cons 10 x)))
  (entmake '((0 . "VERTEX")
	     (70 . 32)
	     (10 1.0 1.0 0.0) ) )
  (entmake '((0 . "VERTEX")
	     (70 . 32)
	     (10 4.0 6.0 0.0) ) )
  (entmake '((0 . "VERTEX")
	     (70 . 32)
	     (10 3.0 2.0 0.0) ) )
  (entmake '((0 . "SEQEND")))
  )
0 Likes
Message 7 of 7

michael
Explorer
Explorer
Thnaks a lot, best regards!
0 Likes