Hello
I don't know about LISP yet, but I am reading: http://docs.autodesk.com/ACDMAC/2013/ENU/PDFs/acdmac_2013_autolisp_developers_guide.pdf.
I want to make a little program where I can show with an arrow and an annotation, the distance (in mm.) and the perpendicular direction for a point to meet the design (defined by 2 points). To start with, the program will be in 2D (X,Y).
Do you know some reading or exemples, who could help me to do so?
As I know from programming in another language I have to:
1 launch/start the program
2 click/choose the 2 points I need to relate my measurement to
3 click/choose the point(s) the measured points
Best Regards
Jean-Christophe
So far so good, I am coming to this point:
I use an example: http://www.jefferypsanders.com/autolisp_examp.html#DLD.lsp
I wrote this:
;JCP-As_built.lsp - Draw a perpendicular line with arrow from a point to a line (defun C:JCP-As_built() ;turn system echo off (setvar "cmdecho" 0) ;get the start point of the leader line (setq pt1(getpoint "\n Start Point: ")) ;get the end point of the leader line (setq pt2(getpoint "\n End Point: ")) ;setup some variables to be used later ;[temp] is a temporary point ;[cntr] is a counter ;[tht] holds the current text size (setq tpt temp cntr 0 tht (getvar "textsize")) ;unremark ... ;(command "layer" "set" "YOUR_LAYER_NAME" "") ;loop until the user quits selecting points (while (/= nil(setq tpt(getpoint tpt "\n Next Point: "))) ;if it is the first point the user has selected (if(= cntr 0) ;start ... ; That's her, that I want to make a perpendicular line/arrow from my point to the main line. (command "dim1" "lea" pt1 tpt (command))
Can you please tell me, how I have to formulate the drawing of a perpendicular arrow from temp to pt1/pt2?
Best Regards
Jean-Christophe
@Anonymous wrote:
Can you please tell me, how I have to formulate the drawing of a perpendicular arrow from temp to pt1/pt2?
You could try your luck in getting perpendicular OSNAP to work.
I seldom get predictable results with that programmatically so I usually calculate the point myself.
A web search will find plenty of different approaches for that, I often use something from here:
http://paulbourke.net/geometry/pointlineplane/
--
Hello Martti,
Thank you for your answer.
I am taking a look at your link!
Have a nice day
Best Regards
Jean-Christophe
As I could not comprehend the descriptions of your objective;
I guess these tools may help start you:
a perpendicular is 90 degrees from something,
and in Autolisp: (/ pi 2)
For two points, stored in variables P1 and P2, their angle
would be equal to (angle P1 P2) or (angle P2 P1)
and the perpendicular would be calculated by
(+ (angle P1 P2) (/ pi 2))
You can use the other functions in Autolisp
to build your program.
You can find similar examples by searching
here or on Google.