j_spawn_h Posted November 27, 2011 Posted November 27, 2011 I want to pick two points(distance), divide them points by what ever number I chose, then draw a line from them divided points, to the perpendicular of a third point that I pick. I thought it would be easy but it seems it is not what I thought. I have this for a start. (defun C:st (/ pd1 pd2 d2d sp m pd) (setq pd1 (getpoint "\nSelect first btend: ")) (setq pd2 (getpoint "\nSelect second btend: ")) (setq d2d (distance (cdr (reverse pd1)) (cdr (reverse pd2)))) (setq sp(getreal "\nNumber of spaces between stends? ")) (setq m (/ (cvunit d2d "INCHES" "FEET") (cvunit sp "INCHES" "FEET"))) (setq pd (getpoint "\nSelect line to extend to: ")) (command "_.layer" "s" "s-frm-stend" "" "") (command "line" m pd "")) Quote
BlackBox Posted November 27, 2011 Posted November 27, 2011 For the first two points it sounds like the OP wants a similar result to automagically applying the DIVIDE command to the (entlast) line that is created by the two point specifications and the input even number. I'm lost as for the third point. More information is needed. Quote
GP_ Posted November 27, 2011 Posted November 27, 2011 If I understand correctly...try... (defun C:st (/ pd1 pd2 d2d sp step pd) (vl-load-com) (setq pd1 (trans (getpoint "\nSelect first btend: ") 1 0)) (setq pd2 (trans (getpoint "\nSelect second btend: ") 1 0)) (setq d2d (distance pd1 pd2)) (setq sp (getint "\nNumber of spaces between stends? ")) (setq pd (vlax-ename->vla-object (car (entsel "\nSelect line to extend to: ")))) (setq step (/ (distance pd1 pd2) sp)) (repeat (1- sp) (setq pd1 (polar pd1 (angle pd1 pd2) step)) (entmake (list (cons 0 "LINE") (cons 8 "s-frm-stend") (cons 10 pd1) (cons 11 (vlax-curve-getClosestPointTo pd pd1 T)) ) ) ) ) Quote
Tharwat Posted November 27, 2011 Posted November 27, 2011 @GP You can use all functions that start with vlax-curve-***** without converting the entity to vla object . Quote
GP_ Posted November 27, 2011 Posted November 27, 2011 Thank you, Tharwat :oops: Often I forget to put it in more complex lisp, then insert immediately... Quote
j_spawn_h Posted November 27, 2011 Author Posted November 27, 2011 Gp that is what i needed. I knew i needed to have a repeat or loop of some sort but did not know how to write. All you guys or girls are awesome. I am trying to learn this programing on my own but I get stumped. I am just trying to be at least a 1/4 of how good y'all are. Thank you all for helping. I am hoping in the future I can help some one to pay back all y'alls help. Quote
GP_ Posted November 27, 2011 Posted November 27, 2011 ...Thank you all for helping. I am hoping in the future I can help some one to pay back all y'alls help. You're welcome. Okay well a cake or ice cream...now... Code cleaned up of unnecessary things. (defun C:st (/ pd1 pd2 sp step pd) (setq pd1 (trans (getpoint "\nSelect first btend: ") 1 0)) (setq pd2 (trans (getpoint "\nSelect second btend: ") 1 0)) (setq sp (getint "\nNumber of spaces between stends? ")) (setq pd (car (entsel "\nSelect line to extend to: "))) (setq step (/ (distance pd1 pd2) sp)) (repeat (1- sp) (setq pd1 (polar pd1 (angle pd1 pd2) step)) (entmake (list (cons 0 "LINE") (cons 8 "s-frm-stend") (cons 10 pd1) (cons 11 (vlax-curve-getClosestPointTo pd pd1 T)) ) ) ) ) Quote
BlackBox Posted November 27, 2011 Posted November 27, 2011 Be sure to look out for things like: (distance nil nil) ... Perhaps the use of an IF statement would help mitigate potential errors. :wink: 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.