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

entmake lwpolyline with arc

7 REPLIES 7
Reply
Message 1 of 8
smaher12
1559 Views, 7 Replies

entmake lwpolyline with arc

I have run into a little trouble in trying to figure out how to create a arc polyline with entmake. I've put together the following and it works great with command "pline". I just want to know how to do it with entmake.

 

 (defun C:22 ()
    (setq P1 (getpoint "\nSpecify first point: ")
             P2 (getpoint P1 "\nSpecify next point: "))

    (setq A (angle P1 P2)
             D (distance P1 P2))

    (setq P3 (polar P1 A (/ D 2))           ;midpoint
             P4 (polar P1 A (/ D 4))
             P5 (polar P3 A (/ D 4))
             P6 (polar P4 (+ A (/ PI 2)) (/ D 6))
             P7 (polar P5 (- A (/ PI 2)) (/ D 6)))
    (entmake
      (list
        '(0 . "LWPOLYLINE")
        '(100 . "AcDbEntity")
        '(100 . "AcDbPolyline")
        (cons 6 "Continuous")
        (cons 8 "S-LINEWORK")
        (cons 43 0)               ; constant width
        (cons 62 7)               ; color
        (cons 90 4)               ; number of vertices
        (cons 10 P1)
        (cons 10 P6)
        (cons 10 P3)
        (cons 10 P7)
        (cons 10 P2)
      )
    )
;(command "pline" P2 "width" "0" "0" "arc" "S" P7 P3 "S" P6 P1 "")
)

7 REPLIES 7
Message 2 of 8
Moshe-A
in reply to: smaher12

Hi,

 

dxf code 42 (called bulge)

 

The bulge is the tangent of 1/4 of the included angle for the arc between the selected vertex and the next vertex in the polyline's vertex list. A negative bulge value indicates that the arc goes clockwise from the selected vertex to the next vertex. A bulge of 0 indicates a straight segment, and a bulge of 1 is a semicircle.

 

Cheers

Moshe

 

Message 3 of 8
smaher12
in reply to: Moshe-A


@Moshe-A wrote:

dxf code 42 (called bulge)


Perfect - I kept reading about dxf code 42 (bulge) so I put if before dxf code 43. It just didn't work, so I took it out. Well the light bulb just went off. Put dxf code 42 after dxf code 10, and Houston we have lift off. Thanks Moshe for flipping the switch!!! 

 

 (defun C:22 ()
    (setq P1 (getpoint "\nSpecify first point: ")
             P2 (getpoint P1 "\nSpecify next point: "))

    (setq A (angle P1 P2)
             D (distance P1 P2))

    (setq P3 (polar P1 A (/ D 2))           ;midpoint
             P4 (polar P1 A (/ D 4))
             P5 (polar P3 A (/ D 4)))
;;;          P6 (polar P4 (+ A (/ PI 2)) (/ D 6))
;;;          P7 (polar P5 (- A (/ PI 2)) (/ D 6))

    (entmake
     (list
      '(0 . "LWPOLYLINE")
      '(100 . "AcDbEntity")
      '(100 . "AcDbPolyline")
      (cons 6 "Continuous")
      (cons 8 "S-LINEWORK")
      (cons 43 0)               ; constant width
      (cons 62 7)               ; color
      (cons 90 4)               ; number of vertices
      (cons 10 P1)
      (cons 42 -0.65)
;;;      (cons 10 P6)
      (cons 10 P3)
      (cons 42 0.65)
;;;      (cons 10 P7)
      (cons 10 P2)
     )
   )
;;;(command "pline" P2 "width" "0" "0" "arc" "S" P7 P3 "S" P6 P1 "")
)

 

 

Message 4 of 8
smaher12
in reply to: Moshe-A

What is the difference when you do   '(43 . 0) or (cons 43 0)? What does the apostrophe do? What does the period do?

 

Message 5 of 8
Moshe-A
in reply to: smaher12

 

"and Houston we have lift off"  Smiley Very Happy

 

Happy New Year mate

Message 6 of 8
Moshe-A
in reply to: smaher12


@smaher12 wrote:

What is the difference when you do   '(43 . 0) or (cons 43 0)? What does the apostrophe do? What does the period do?

 


The period construct (what autolisp calls) a dotted pair sublist which is list with only two items

you can get the first item with (car) function and the second with (cdr) function this a special use of (cdr)

function cause the nature of it is to return the whole list except for the first.

also (cdr) always return list but on dotted pair it will return an atom (the second item alone)

 

if the second item of the dotted pair is a number (not a variable) than you can just use

'(43 . 0) but if it is a variable? you only can use (cons)

 

(cons) function construct a list but if it's second argument is an atom it will return a dotted pair.

 

the apostrophe is a shortcut (hope i'm not worng) of creating a list. AutoLISP is

all about list where a correct expression must start with a function name and than arguments

like (foo args1 args2 ... ....)

 

you can express a point in autolisp like this:

 

(setq pt '(5.0 12.0 0.0))

or

(setq pt (list 5.0 12.0 0.0)

 

it's the same

 

Moshe

 

Message 7 of 8
Rtogores
in reply to: Moshe-A


@Moshe-A wrote:

the apostrophe is a shortcut (hope i'm not worng) of creating a list.

 


In fact the apostrophe is an abbreviation of the AutoLISP function QUOTE which returns an expression without evaluating it.

The expressions (quote (43 . 0)) and '(43 . 0) are exactly the same thing.

_$ '(43 . 0)
(43 . 0)
_$ (quote (43 . 0))
(43 . 0)

QUOTE or the apostrophe are used whenever we want to pass an expression without AutoLISP evaluating it:

_$ (setq a "something")
"something"
_$ a
"something"
_$ 'a
A
_$ (quote a)
A

_$ (eval (quote a))
"something"
_$

 

Have a great 2013!

Message 8 of 8
Moshe-A
in reply to: Rtogores

Reinaldo,

 

thanks you very much for clearing this

 

moshe

 

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

Post to forums  

Autodesk Design & Make Report

”Boost