Jump to content

startpt endpt - rotation angle??


Recommended Posts

Posted

if i have a start point and a end point of a line stored how do i get the rotation angle of that line within lisp??

Posted

I've not done any lisp for a long while but here is some VBA code that will record the angle of a line. Open or create a drawing with a line in it then

open your VBA editor (Alt F11) and create a new module and add the following sub LineTest to the module and run it.

 

Public Sub LineTest()
Dim oAcEntity As AcadEntity
Dim oAcLine As AcadLine

 'search all entities for a line object
 For Each oAcEntity In ThisDrawing.ModelSpace
   'find the 1st line object in the current drawing
   If oAcEntity.ObjectName = "AcDbLine" Then
     'record the line
     Set oAcLine = oAcEntity
     Exit For
   End If
 Next
 
 'declare a variable to hole the line angle
 Dim ThisLineAngle As Double
 'convert radians to degrees
 ThisLineAngle = oAcLine.Angle * 180# / 3.14159265
 'print the value
 Debug.Print ThisLineAngle
End Sub

Hope this works for you. I'm sure someone will send you a lisp reply...

Posted
if i have a start point and a end point of a line stored how do i get the rotation angle of that line within lisp??

(angle pt1 pt2)

where pt1 and pt2 are star and end points in (x y z) list form. This will give you the angle in radians relative to the current UCS.

Posted

yes thanks kindly - i dont have the help guide here at home..cheers for that

 

i ended up using

 

(setq a (list (car startpt)(cadr startpt)))
(setq b (list (car endpt)(cadr endpt)))
(setq ANG (angle a b))

 

Cheers mate

Posted
yes thanks kindly - i dont have the help guide here at home..cheers for that

 

i ended up using

 

(setq a (list (car startpt)(cadr startpt)))
(setq b (list (car endpt)(cadr endpt)))
(setq ANG (angle a b))

 

Cheers mate

 

If a and b are nothing more than place holders then do this instead:

 

(setq ANG 
 (list (car startpt)(cadr startpt))
 (list (car endpt)(cadr endpt))
)

 

If you are using them later then the way you have it is fine.

 

$.02

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