Jump to content

Entmake rect.


DuanJinHui

Recommended Posts

You will need to calculate the positions of each of the 8 vertices, calculate the appropriate bulge values for the rounded corners [noparse][tan(pi/8)][/noparse] and then entmake(x) an LWPOLYLINE entity with such vertex & bulge data.

Link to comment
Share on other sites

Thank you,Lee,if "f"=0,so only 4 vertices ?

 

It looks very difficult, my mathematics and geometry is very poor .

Link to comment
Share on other sites

Here is an example for you to study:

;; Rounded Rectangle Example  -  Lee Mac 2016

(defun c:myrect ( / blg lst ocs pt1 pt2 rad tmp )
   
   (setq rad 10.0) ;; Fillet Radius
   
   (if (and (setq pt1 (getpoint "\nSpecify 1st point: "))
            (setq pt2 ((if (zerop (getvar 'worlducs)) getpoint getcorner) pt1 "\nSpecify 2nd point: "))
       )
       (progn
           (setq ocs (trans '(0 0 1) 1 0 t)
                 tmp (mapcar 'max pt1 pt2)
                 pt1 (mapcar 'min pt1 pt2)
                 pt2 tmp
                 lst (list pt1 (list (car pt2) (cadr pt1)) pt2 (list (car pt1) (cadr pt2)))
                 blg (1- (sqrt 2))
           )
           (if (equal rad 0.0 1e-
               (entmake
                   (append
                      '(   (000 . "LWPOLYLINE")
                           (100 . "AcDbEntity")
                           (100 . "AcDbPolyline")
                           (090 . 4)
                           (070 . 1)
                       )
                       (list (cons 038 (caddr (trans pt1 1 ocs))))
                       (mapcar '(lambda ( x ) (cons 10 (trans x 1 ocs))) lst)
                       (list (cons 210 ocs))
                   )
               )
               (entmake
                   (append
                      '(   (000 . "LWPOLYLINE")
                           (100 . "AcDbEntity")
                           (100 . "AcDbPolyline")
                           (090 . 
                           (070 . 1)
                       )
                       (list (cons 038 (caddr (trans pt1 1 ocs))))
                       (apply 'append
                           (mapcar
                               (function
                                   (lambda ( a b )
                                       (apply 'append 
                                           (mapcar 
                                               (function
                                                   (lambda ( c d ) 
                                                       (list 
                                                           (cons 10 (trans (mapcar '+ a c) 1 ocs)) 
                                                           (cons 42 d)
                                                       )
                                                   )
                                               )
                                               b (list blg 0.0)
                                           )
                                       )
                                   )
                               )
                               lst
                               (list
                                   (list (list 0 rad)     (list rad 0))
                                   (list (list (- rad) 0) (list 0 rad))
                                   (list (list 0 (- rad)) (list (- rad) 0))
                                   (list (list rad 0)     (list 0 (- rad)))
                               )
                           )
                       )
                       (list (cons 210 ocs))
                   )
               )
           )
       )
   )
   (princ)
)

The above should also be compatible in all UCS & Views.

Link to comment
Share on other sites

Here is an example for you to study:

 

The above should also be compatible in all UCS & Views.

 

Thank you very much! Lee. I will study it !

Link to comment
Share on other sites

You're welcome - feel free to ask any questions about the code.

 

Thank you ,I did a little change.

 

1.use parameter

(defun myrect (rad pt1 pt2 lay col / blg lst ocs tmp )
(if (and pt1 pt2 rad lay col)
       (progn
   ...
       ...

 

2.

(list (cons 038 (caddr (trans pt1 1 ocs))))

Change to-->

(list (cons 8 lay)(cons 62 col)(cons 038 (caddr (trans pt1 1 ocs))))

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...