Jump to content

Recommended Posts

Posted

Hello everbody! i am trying to chamfer a polygon but failed. i hope everbody help me. I am a new member autolisp.Thank you everboy and have a good dayUntitled.jpg

;lisp ve MC ngang cong hop theo cac thong so cho truoc

;su dung toa do tuong doi @ theo diem chon truoc

;p.tkcd - cienco625

(defun c:ch (\ a b c)

(setvar "OSMODE" 0)

;kich thuoc cong hop

(setq a (getreal "\NNhap CHIEU RONG cong hop:")

b (getreal "\NNhap CHIEU CAO cong hop:")

c (getreal "\NNhap be rong vat mep trong:")

)

;diem ve cong

(setq dv (getpoint "\NChon diem ve MC:"))

(setq dv1 (list (+ (car dv) b) (+ (cadr dv) a)))

(command ".RECTANG" dv dv1)

(command ".CHAMFER" "Distance" c "" c)

(command ".CHAMFER" "Polyline" "last" "")

(princ))

Posted

Maybe this will help.

 

(command "Chamfer" "D" c c "")

(command "Chamfer" "P" (entlast))

Posted
Maybe this will help.

 

(command "Chamfer" "D" c c "")

(command "Chamfer" "P" (entlast))

 

thank yoy but i try code agian and have result:** Error: too few arguments **

Posted
(defun c:chtest ( / a b c)
(setvar "OSMODE" 0)
(setq	a (getreal "\NNhap CHIEU RONG cong hop:"))
(setq b (getreal "\NNhap CHIEU CAO cong hop:"))
(setq c (getreal "\NNhap be rong vat mep trong:"))
(setq dv (getpoint "\NChon diem ve MC:"))
(setq dv1 (list (+ (car dv) b) (+ (cadr dv) a)))
(command ".RECTANG" dv dv1)
(command ".CHAMFER" "Distance" c c)
(command ".CHAMFER" "P" (entlast))
(princ)
)

Posted
(defun c:chtest ( / a b c)
(setvar "OSMODE" 0)
(setq	a (getreal "\NNhap CHIEU RONG cong hop:"))
(setq b (getreal "\NNhap CHIEU CAO cong hop:"))
(setq c (getreal "\NNhap be rong vat mep trong:"))
(setq dv (getpoint "\NChon diem ve MC:"))
(setq dv1 (list (+ (car dv) b) (+ (cadr dv) a)))
(command ".RECTANG" dv dv1)
(command ".CHAMFER" "Distance" c c)
(command ".CHAMFER" "P" (entlast))
(princ)
)

 

thankyou very much

Posted

The other way is draw from 1st principles ie 8 pts, length, width, chamfer. Use polar in lisp.

Posted

Untitled.jpg

The other way is draw from 1st principles ie 8 pts, length, width, chamfer. Use polar in lisp.

thank everybody, i am try to draw this object

Posted

Well if anything else, it was interesting to manipulate the elist and entmod the polyline:

(defun C:test ( / SS d i )
 (and (princ "\nSelect polylines to chamfer: ")
   (setq SS (ssget "_:L" '((0 . "LWPOLYLINE"))))
   (setq d (getdist "\nSpecify chamfer distance: "))
   (repeat (setq i (sslength SS))
     (_ChamferPoly (ssname SS (setq i (1- i))) d)
   ); repeat
 ); and
 (princ)
); defun

; NOTE: it Straightens the bulges
(defun _ChamferPoly ( e d / enx pts L nenx )
 (and
   (setq enx (entget e))
   (= "LWPOLYLINE" (cdr (assoc 0 enx)))
   (setq pts (apply 'append (mapcar '(lambda (x) (if (= 10 (car x)) (list (cdr x)))) enx)))
   (setq pts 
     (apply 'append
       (mapcar '(lambda (x) (list (cons 10 x) '(40 . 0.0) '(41 . 0.0) '(42 . 0.0) '(91 . 0)))
         (setq L
           (cond 
             ( (= 1 (cdr (assoc 70 enx)))
               (apply 'append 
                 (mapcar '(lambda (a b) (list (polar a (angle a b) d) (polar b (angle b a) d)))
                   pts (append (cdr pts) (list (car pts)))
                 )
               )
             )
             (T
               (apply 'append 
                 (reverse 
                   (cdr 
                     (reverse
                       (mapcar '(lambda (a b) (list (polar a (angle a b) d) (polar b (angle b a) d)))
                         pts (append (cdr pts) (list (car pts)))
                       )
                     )
                   )
                 )
               )
             )
           ); cond
         )
       )
     )
   )
   (setq nenx (apply 'append (mapcar '(lambda (x) (if (not (member (car x) '(10 40 41 42 91 210))) (list x))) enx)))
   (entmod
     (setq nenx 
       (append
         (subst (cons 90 (length L)) (assoc 90 nenx) nenx)
         pts
         (list (assoc 210 enx))
       )
     )
   )
 ); and
); defun _ChamferPoly

Posted (edited)

The outside object lets call it with steps, ok draw a pline pick top vert side and answer a couple of questions and step is drawn into line.

Repeat as required. Yes you need a lisp.

 

Just as a bit of fun this is a pline with chamfers the code can be reduced by using double polars or using sqrt 2 *chamfer @ angle of 45's. The reason for doing it was to show you can draw any shape by working out the points.

 

(defun c:plcham ( / pt1 pt2 pt3 pt4 pt5 pt6 pt7 pt8 pt9 pt10 pt11 pt12) 
(setq pi2 (/ pi 2.0))
(setq pi15 (* pi 1.5))
(setq pt1 (getpoint "Pick lower left"))
(setq l (getdist pt1 "Enter length"))
(setq w (getdist pt1 "Enter height"))
(setq cham (getdist "Enter champher"))
(setq cham2 (* cham 2.0))
(setq pt2 (polar Pt1 0.0 cham))
(setq pt3 (polar pt2 0.0 (- l cham2)))
(setq pt4 (polar pt3 0.0 cham))
(setq pt5 (polar pt4 pi2 cham))
(setq pt6 (polar pt5 pi2 (- w cham2)))
(setq pt7 (polar pt6 pi2 cham))
(setq pt8 (polar pt7 pi cham))
(setq pt9 (polar pt8 pi (- l cham2)))
(setq pt10 (polar pt9 pi cham))
(setq pt11 (polar pt10 pi15 cham))
(setq pt12 (polar pt11 pi15 (- w cham2)))
(command "pline" Pt2 pt3 pt5 pt6 pt8 pt9 pt11 pt12 "c")
(princ)
)

Edited by BIGAL

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...