Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Newb want to make as-built program in LISP

4 REPLIES 4
Reply
Message 1 of 5
130900
774 Views, 4 Replies

Newb want to make as-built program in LISP

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

 

 

 

 

4 REPLIES 4
Message 2 of 5
130900
in reply to: 130900

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

Message 3 of 5
martti.halminen
in reply to: 130900


@130900 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/

 

--

 

Message 4 of 5
130900
in reply to: martti.halminen

Hello Martti,

 

Thank you for your answer.

I am taking a look at your link!

 

Have a nice day

Best Regards

Jean-Christophe

Message 5 of 5
stevor
in reply to: 130900

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.

S

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost