Author Topic: Draw line by entmake  (Read 1981 times)

0 Members and 1 Guest are viewing this topic.

Christina

  • Newt
  • Posts: 27
Draw line by entmake
« on: April 20, 2021, 05:45:02 AM »
Hello,
I am trying to use entmake instead of the command line to draw a line.

This is the code:

Code: [Select]
(defun c:test()
     ....
     ....
     (setq y (- (length lst1) 1))
(command "line" pt1 (nth y lst2) "")
     (setq y 0)
)

And work fine but i want this  :

Code: [Select]
(defun c:test()
     ....
     ....
     (setq y (- (length lst1) 1))
(mapcar 'line_  pt1  list(nth y lst2))
     (setq y 0)
)
(defun line_ (str_ end_)
(entmakex
(list
'(0 . "LINE")
(cons 10 (trans str_ 1 0))
(cons 11 (trans end_ 1 0))
(cons 62 8)
)
)
)

But don't want to work, nothing append...

Thank you to read this,

Christina







Christina

  • Newt
  • Posts: 27
Re: Draw line by entmake
« Reply #1 on: April 20, 2021, 06:28:23 AM »
OK, got it!

Code: [Select]
(mapcar 'line_  (list pt1) (list(nth y lst2)))

Stefan

  • Bull Frog
  • Posts: 319
  • The most I miss IRL is the Undo button
Re: Draw line by entmake
« Reply #2 on: April 20, 2021, 07:23:59 AM »
If (command ... works, no need to mapcar
Code - Auto/Visual Lisp: [Select]
  1. (line_  pt1 (nth y lst2))


Christina

  • Newt
  • Posts: 27
Re: Draw line by entmake
« Reply #3 on: April 20, 2021, 07:44:48 AM »
OK, thank you Stefan!

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: Draw line by entmake
« Reply #4 on: May 12, 2021, 11:30:49 AM »
Very minor but, it may help!
Code: [Select]
(setq p1 (getpoint "\nSpecify first point:"))
(setq p2 (getpoint p1 "\nSpecify next point:"))

(entmake
  (list
    '(0 . "LINE")
    (cons 10 p1)
    (cons 11 p2)
  )
)
TheSwamp.org  (serving the CAD community since 2003)

d2010

  • Bull Frog
  • Posts: 326
Re: Draw line by entmake
« Reply #5 on: May 17, 2021, 04:10:39 PM »
I used , all times the function "dfn_enamk_line"
Code: [Select]

(Defun dfn_enamk_line(p1 p2 la color lt / $rr nfl)
  (if (=  color nil) (setq;|a37864|;
color 256)) (setq;|a37892|;
la (if (>  la "") la (getvar "CLAYER"))
p1 (append (list 10) p1)
p2 (append (list 11) p2)
nfl (list (cons 0 "LINE") (cons 100 "AcDbEntity") (cons 8 la) (cons 100 "AcDbLine") p1 p2 (cons 62 color))) (if (>  lt "") (setq;|a38184|;
nfl (append nfl (list (cons 6 lt))))) (setq;|a38240|;
$rr (entmakex nfl)) (princ)
$rr);;Lsp=(dfn_enamk_line (getpoint) (getpoint) nil 34 "")
:nerdystraight:
Hello,
I am trying to use entmake instead of the command line to draw a line.
Thank you to read this,
Christina