Roy_043 Posted December 15, 2019 Posted December 15, 2019 (edited) Not sure what your point is. I have no problem with using command calls. But I must correct you here: 1 hour ago, BIGAL said: Yes probably worth adding a osmode 0 to code. It is absolutely essential to handle the OSMODE setting when using command calls. Edited December 15, 2019 by Roy_043 Quote
Abdulellah Posted December 15, 2019 Author Posted December 15, 2019 (edited) 15 hours ago, BIGAL said: This is latest has offset radius and angle pick pline anywhere. (defun c:plhook ( / plent pt1 pt2 pt3 pt4 ang3 pt5 add ang1 ang2 ang3) (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (if (= but nil)(setq but 1)) (if (not AH:getvalsm)(load "Multi Getvals.lsp")) (while (setq plent (entsel "Pick pline Enter to exit")) (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent))))) (setq pt1 (nth 0 co-ord)) ; 1st point (setq pt2 (nth 1 co-ord)) ; second point (setq x (- (length co-ord) 1)) ; how many points- 1 as 1st point is 0 (setq pt3 (nth (- x 1) co-ord)) ; second last point (setq pt4 (nth x co-ord)) ; last point (setq ang1 (angle pt2 pt1)) ; angle ofthe pline (setq ang2 (angle pt3 pt4)) (setq ans (AH:getvalsm (list "Enter length" "Hook length " 5 4 "30" "Radius" 5 4 "25" "angle " 5 4 "45"))) (setq add (atof (nth 0 ans))) (setq rad (atof (nth 1 ans))) (setq ang3 (* pi (/ (atof (nth 2 ans)) 180.0))) (setq pt5 (polar pt1 (+ ang3 ang1) add)) ; 135 degrees (command "line" pt1 pt5 "") ; new line (setq ans (ah:butts but "V" '("Flip " "Yes" "No"))) (if (= "No" ans) (princ "ok") (command "mirror" "Last" "" pt1 pt2 "Y") ) (command "pedit" (car plent) "join" (entlast) "" "") (setq pt5 (polar pt4 (+ ang3 ang2) add)) ; other end (command "line" pt4 pt5 "") (setq ans (ah:butts but "V" '("Flip " "Yes" "No"))) (if (= "No" ans) (princ "ok") (command "mirror" "Last" "" pt4 pt3 "Y") ) (command "pedit" (car plent) "join" (entlast) "" "") (command "fillet" "Polyline" "r" rad (car plent)) ) (princ) ) (c:plhook) dear begal i am sorry to say that < - forget dcl window realy it make slow work . return for frist code it its good , discard dcl window make me stay on command prompt - at general my work in meter ( 1 autocad unit = 1 meter ) work with digits assume hook length = 0.03 m - lisp must remember last entries and entries must be as subcommand when lisp ask me to pick polyline like any autocad command -Y or N question ? right click on screen mean "No" hit enter or space button mean "Yes" . - lisp must remember last entries when start it agine You are the only one who has courage. You are left with the finishing touches Edited December 15, 2019 by Abdulellah Quote
BIGAL Posted December 15, 2019 Posted December 15, 2019 Just remove the dcl bits and replace with the code from the 1st code I posted about y n. Same with ang3, add rad, (setq rad (getreal "\nEnter radius")) Quote
BIGAL Posted December 15, 2019 Posted December 15, 2019 Roy_043 It is absolutely essential to handle the OSMODE setting when using command calls. It is not. Depends on the situation as I say I have been programming for over 40 years and know when I need to use osmode. Know about a few other Gotcha that Autocad does to code as well. 1 Quote
asos2000 Posted December 17, 2019 Posted December 17, 2019 (edited) Hi Abdulellah, Which version you want to update to apply these changes? Hassan Edited December 17, 2019 by asos2000 1 Quote
asos2000 Posted December 17, 2019 Posted December 17, 2019 Give This a try (defun c:plhook ( / plent pt1 pt2 pt3 x pt5 add ang1 ang2) (while (setq plent (entsel "Pick pline Enter to exit")) (if plent (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent)))))) (setq pt1 (nth 0 co-ord)) ; 1st point (setq pt2 (nth 1 co-ord)) ; second point (setq x (- (length co-ord) 1)) ; how many points- 1 as 1st point is 0 (setq pt3 (nth (- x 1) co-ord)) ; second last point (setq pt4 (nth x co-ord)) ; last point (setq ang1 (angle pt2 pt1)) ; angle ofthe pline (setq ang2 (angle pt3 pt4)) (setq add 0.03) ;; (setq add (getreal "Enter distance to add on")) (setq pt5 (polar pt1 (+ (* 0.25 pi) ang1) add)) ; 135 degrees (command "line" pt1 pt5 "") ; new line (if (null *mr1) (setq *mr1 "No")) (initget 0 "Yes No") (if (setq tmp (getkword (strcat "\nIs Hook direction OK? [Yes/No] <" *mr1 ">: "))) (setq *mr1 tmp)) ; (setq ans (getstring "is line ok Y or N")) ; is it in correct direction (if (= "Yes" *mr1) ; y or Y (princ "ok") (command "mirror" "Last" "" pt1 pt2 "Y") ; flip line ) (command "pedit" (car plent) "join" (entlast) "" "") (setq pt5 (polar pt4 (+ (* 0.25 pi) ang2) add)) ; other end (command "line" pt4 pt5 "") (if (null *mr2) (setq *mr2 "No")) (initget 0 "Yes No") (if (setq tmp (getkword (strcat "\nIs Hook direction OK? [Yes/No] <" *mr2 ">: "))) (setq *mr2 tmp)) ;(setq ans (getstring "is line ok Y or N")) (if (= "Yes" *mr2) (princ "ok") (command "mirror" "Last" "" pt4 pt3 "Y") ) (command "pedit" (car plent) "join" (entlast) "" "") ) ) 1 Quote
Abdulellah Posted December 17, 2019 Author Posted December 17, 2019 3 hours ago, asos2000 said: Give This a try (defun c:plhook ( / plent pt1 pt2 pt3 x pt5 add ang1 ang2) (while (setq plent (entsel "Pick pline Enter to exit")) (if plent (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent)))))) (setq pt1 (nth 0 co-ord)) ; 1st point (setq pt2 (nth 1 co-ord)) ; second point (setq x (- (length co-ord) 1)) ; how many points- 1 as 1st point is 0 (setq pt3 (nth (- x 1) co-ord)) ; second last point (setq pt4 (nth x co-ord)) ; last point (setq ang1 (angle pt2 pt1)) ; angle ofthe pline (setq ang2 (angle pt3 pt4)) (setq add 0.03) ;; (setq add (getreal "Enter distance to add on")) (setq pt5 (polar pt1 (+ (* 0.25 pi) ang1) add)) ; 135 degrees (command "line" pt1 pt5 "") ; new line (if (null *mr1) (setq *mr1 "No")) (initget 0 "Yes No") (if (setq tmp (getkword (strcat "\nIs Hook direction OK? [Yes/No] <" *mr1 ">: "))) (setq *mr1 tmp)) ; (setq ans (getstring "is line ok Y or N")) ; is it in correct direction (if (= "Yes" *mr1) ; y or Y (princ "ok") (command "mirror" "Last" "" pt1 pt2 "Y") ; flip line ) (command "pedit" (car plent) "join" (entlast) "" "") (setq pt5 (polar pt4 (+ (* 0.25 pi) ang2) add)) ; other end (command "line" pt4 pt5 "") (if (null *mr2) (setq *mr2 "No")) (initget 0 "Yes No") (if (setq tmp (getkword (strcat "\nIs Hook direction OK? [Yes/No] <" *mr2 ">: "))) (setq *mr2 tmp)) ;(setq ans (getstring "is line ok Y or N")) (if (= "Yes" *mr2) (princ "ok") (command "mirror" "Last" "" pt4 pt3 "Y") ) (command "pedit" (car plent) "join" (entlast) "" "") ) ) glad to see your post , ..............what about hook length value option ? Quote
BIGAL Posted December 17, 2019 Posted December 17, 2019 asos2000 just change the dcl version for the yes no part I have tried to get Aubdlellah to have a go himself. Quote
asos2000 Posted December 18, 2019 Posted December 18, 2019 6 hours ago, BIGAL said: asos2000 just change the dcl version for the yes no part I have tried to get Aubdlellah to have a go himself. Yes BIGAL me too wan that to change by himself but step by step Fist applying his requirements Then ask him to do a step Then gide him to www.afralisp.net Then he will be a member of the programming community. 1 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.