Jump to content

REQ : lisp to draw polyline rebar end hook side indecator


Abdulellah

Recommended Posts

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 by Roy_043
Link to comment
Share on other sites

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 by Abdulellah
Link to comment
Share on other sites

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.

  • Thanks 1
Link to comment
Share on other sites

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) "" "")
    )
  )

 

  • Like 1
Link to comment
Share on other sites

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 ?

Link to comment
Share on other sites

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.

 

  • Thanks 1
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...