thanhdattdk Posted April 5, 2017 Posted April 5, 2017 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 day ;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)) Quote
Aftertouch Posted April 5, 2017 Posted April 5, 2017 Maybe this will help. (command "Chamfer" "D" c c "") (command "Chamfer" "P" (entlast)) Quote
thanhdattdk Posted April 5, 2017 Author Posted April 5, 2017 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 ** Quote
Aftertouch Posted April 5, 2017 Posted April 5, 2017 (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) ) Quote
thanhdattdk Posted April 5, 2017 Author Posted April 5, 2017 (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 Quote
BIGAL Posted April 5, 2017 Posted April 5, 2017 The other way is draw from 1st principles ie 8 pts, length, width, chamfer. Use polar in lisp. Quote
thanhdattdk Posted April 5, 2017 Author Posted April 5, 2017 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 Quote
Grrr Posted April 5, 2017 Posted April 5, 2017 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 Quote
SLW210 Posted April 5, 2017 Posted April 5, 2017 Please read the Code Posting Guidelines and edit your Code to be included in Code Tags.[NOPARSE] Your Code Here[/NOPARSE] = Your Code Here Quote
BIGAL Posted April 6, 2017 Posted April 6, 2017 (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 April 6, 2017 by BIGAL Quote
Recommended Posts
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.