Jump to content

need of autolisp


ChirilaDan

Recommended Posts

Hi, i'm working in autocad 2005 for civil engeneering project, and i'm in need of an lisp routine ,(similar to "dist" command,) in wich to be displayed the horizontal angle (from direction North, clockwise) , vertical angle, slope distance, horizontal distance, delta x, y, z betwen 2 points or 1 control point and multiple points . if possible to be displayed separated just by commas so that i can paste them into excel

 

sorry for my englsh

 

Thank's

Link to comment
Share on other sites

Thanks Lee Mac it's just what i need but the only deference is that i need the angles units to be displayed in "grads" . Can you help me with this one, i don't have any knowledge in lisp routine language.

Link to comment
Share on other sites

I'm not good at LISP, but the changes you need for Grads are not complex. I've taken the liberty of modifying Alans program. You will need to edit the LSP file with a text editor and make the following changes highlighted in RED.

 

(defun c:D (/) (c:DistanceInquiry))
(defun c:DistanceInquiry (/ *error* AT:FlatDist AT:Arrow AT:Midpoint AT:PointSameXY AT:DrawX
                         _GetPoint AT:Entsel #PromptString #OldOsnapz #Luprec #Lunits #Measure
                         #Arch _RToS #Point1 #Point2 #Bear #Rad [color=Red]#Grad[/color] #Angle #Dist #Elev #Slope
                        )

    ;; points picked, calculation time
    (setq #Point1 (trans #Point1 1 0)
          #Point2 (trans #Point2 1 0)
          #Bear   (angtos
                    (angle #Point1 #Point2)
                    4
                    4
                  ) ;_ angtos
          #Angle  (angtos (angle #Point1 #Point2) 1 4)
          #Rad    (angle #Point1 #Point2)
          [color=Red]#Grad   (/ #Rad (/ 3.14159 200))[/color]
          #Dist   (* #Arch (AT:FlatDist #Point1 #Point2))

I Wikipediad the conversion formula for radians to gradians, check it for accuracy. (the code above means: grad = rad / (pi / 200) )

 

    (setq #PromptString
           (strcat #PromptString
                   "\nRad: "
                   (vl-princ-to-string #Rad)
[color=Red]                    ", Grad: "
                   (vl-princ-to-string #Grad)
[/color]                    ", Azimuth: "
                   #Angle
                   ", Bear: "
                   #Bear
                   ", Dist: "
                   (_RToS #Dist)

please check some known angles before you trust this, as I had never used Gradians prior to this.

 

Hope this helps.

 

Glen

Link to comment
Share on other sites

This should be all you need to add:

 

    (setq #PromptString
           (strcat #PromptString
                   "\nRad: "
                   (vl-princ-to-string #Rad)
                   ", Azimuth: "
                   #Angle
                   ", Bear: "
                   #Bear
[color=Red][b]                    ", Grad: "
                   (angtos #Rad 2 4)[/b][/color]
                   ", Dist: "
                   (_RToS #Dist)
           ) ;_ strcat
    ) ;_ setq

Link to comment
Share on other sites

Lee,

 

At first I was like : :(

 

Then I looked up angtos :facepalm :oops:

 

and then I was like: :shock:

 

Thanks for the lesson.

 

So the only update that you need to make to the code would be this:

    (setq #PromptString
           (strcat #PromptString
                   "\nRad: "
                   (vl-princ-to-string #Rad)
[color=Red]                    ", Grad: "
                   (angtos #Rad 2 3)
[/color]                    ", Azimuth: "
                   #Angle
                   ", Bear: "
                   #Bear
                   ", Dist: "
                   (_RToS #Dist)
           ) ;_ strcat

which returns and prints out your angle in Gradians to 3 significant digits. if you need more, increase the 3 to what you want.

 

Glen

 

Which, naturally you beat me to!! :)

Link to comment
Share on other sites

I'd replace that . Thanks

 

i'm almost there, can you tell me what code to write to to tell the program when making a subtraction like this :

 

(- (caddr #Point2)

(caddr #Point1) )

if the resulting number is negative then make a subtraction like this

(- (caddr #Point1)

(caddr #Point2) ) so the number is always positive

so that later on i can calculate the angle of a slope using formula

(atan slope 100)

Link to comment
Share on other sites

i'm almost there, can you tell me what code to write to to tell the program when making a subtraction like this :

 

(- (caddr #Point2)

(caddr #Point1) )

if the resulting number is negative then make a subtraction like this

(- (caddr #Point1)

(caddr #Point2) ) so the number is always positive

so that later on i can calculate the angle of a slope

 

Why not use:

 

(abs (- (caddr #Point1) (caddr #Point2)))

 

:)

Link to comment
Share on other sites

  • 4 years later...

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