TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: curmudgeon on September 15, 2022, 01:52:57 PM

Title: list processing
Post by: curmudgeon on September 15, 2022, 01:52:57 PM
it's beta. I create a list of points to draw a "section" of a house gable. I entmake the left side, perfect. I add a "special" line, different colour.
it all works.

I process the list to mirror it for the right side:

Code - Auto/Visual Lisp: [Select]
  1. (setq them (mapcar '(lambda (x) (setq x (polar x 0 (* 2 (- (car mpt) (car x))))))
  2.                  (list RF raft fas_l fas_r lastp))

and it draws the right polyline correctly.

but using the same variables, the line is drawn again on the left side.
???


somebody, tell me where I went wrong, please.
the variable that fails is raft. I have changed the variable name (to raft), and I have "patched" the code by setq before attempting to draw the line. no joy.
Title: Re: list processing
Post by: VovKa on September 15, 2022, 03:45:34 PM
the last expression should be
Code: [Select]
(entmake (mapcar '(lambda (x y) (cons x y))
'(0 100 8 62 100 10 11)
(list "LINE" "AcDbEntity" "WALLS" 4 "AcDbPLine" (cadr them) pk_2)
)
)
Title: Re: list processing
Post by: Tharwat on September 15, 2022, 03:46:20 PM
This part fails when using distof function with fractions:
Code - Auto/Visual Lisp: [Select]
  1. (+ (distof "9'-1 1/8") (distof "5.5") (distof "1.5")) ;;; rim height
  2.  

The cyan line repeated because there are two functions in the program ( repeated one ).

The way you are coding entmake with polyline and line is really very odd to me at least, so why don't you create a defun to create each entity instead of repeating the entmake as many as you are using them into your programs ?
Title: Re: list processing
Post by: curmudgeon on September 16, 2022, 10:55:51 PM
"why don't you create a defun to create each entity"
because I am a complete amature, and I haven't written any lisp at all for a few years.
thank you. I will go define a function now. :whistling: