Jump to content

Draw a line from points divided to a point that i pick.


Recommended Posts

Posted

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

Posted

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.

Posted

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

Posted

@GP

 

You can use all functions that start with vlax-curve-***** without converting the entity to vla object .

Posted

Thank you, Tharwat :oops::oops:

 

 

Often I forget to put it in more complex lisp, then insert immediately... :)

Posted

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.

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

Posted

Be sure to look out for things like:

 

(distance nil nil) 

 

... Perhaps the use of an IF statement would help mitigate potential errors. :wink:

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