turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Close

Visual LISP, AutoLISP and General Customization

- Autodesk Community
- >
- AutoCAD Customization
- >
- Visual LISP, AutoLISP and General Customization
- >
- Angle from XY plane

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page

Distinguished Contributor

533 Posts

2 Kudos

Registered:
04-14-2004

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

669 Views, 16 Replies

06-01-2012 07:38 AM

So I've done a lot of searching this morning on "angles", and I couldn't find anything for getting the "out-of-plane" angle.

I'd like the user to pick two points, and return somehow the angle out of plane.

Thanks

KP

Distinguished Mentor

653 Posts

63 Kudos

Registered:
07-02-2010

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-01-2012 07:51 AM in reply to:
kpennell

This ... ?

(if (and (setq p (getpoint "\n First point :")) (setq p1 (getpoint "\n Second point :" p)) ) (print (angle p p1)) )

____________________________________________________

Get learn and learn and practice , to become experienced guy .

Get learn and learn and practice , to become experienced guy .

Distinguished Contributor

533 Posts

2 Kudos

Registered:
04-14-2004

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-01-2012 07:55 AM in reply to:
kpennell

This gives the angle "IN" the XY plane. I need the angle "FROM" the XY plane.

Distinguished Mentor

653 Posts

63 Kudos

Registered:
07-02-2010

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-01-2012 08:05 AM in reply to:
kpennell

Maybe this .... ?

(if (and (setq a (getpoint "\n First point :")) (setq b (getpoint "\n Second point :" a)) ) (progn (setq ang (- (angle a b) (angle a (polar a 0.0 (distance a b))))) (print (* 180.0 (/ ang pi)) ) ) )

____________________________________________________

Get learn and learn and practice , to become experienced guy .

Get learn and learn and practice , to become experienced guy .

Distinguished Contributor

533 Posts

2 Kudos

Registered:
04-14-2004

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-01-2012 08:16 AM in reply to:
_Tharwat

This returns the same value, which is the value IN plane, not OUT OF plane or FROM plane

Appreciate the efforts though

Distinguished Mentor

653 Posts

63 Kudos

Registered:
07-02-2010

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-01-2012 08:19 AM in reply to:
kpennell

Would you upload an image or a drawing showing your desire of the XY plane 's angle?

____________________________________________________

Get learn and learn and practice , to become experienced guy .

Get learn and learn and practice , to become experienced guy .

Distinguished Contributor

533 Posts

2 Kudos

Registered:
04-14-2004

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-01-2012 08:25 AM in reply to:
_Tharwat

It's the same principle as useing the distance command. When a user picks two points using the distance command there are some values retuned to the command prompt. I've copied an example based on two random points:

Distance = 1'-3 7/16", Angle in XY Plane = 314.97223515, Angle from XY Plane = 1.20000000

Delta X = 0'-10 233/256", Delta Y = -0'-10 235/256", Delta Z = 0'-0 83/256"

I'd like to have the exact value that represents "Angle from XY Plane" returned to a variable somehow.

Does this clean up what I'm asking?

Thanks

KP

*Expert Elite*

6,025 Posts

669 Kudos

Registered:
09-13-2004

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-01-2012 09:17 AM in reply to:
kpennell

kpennell wrote:So I've done a lot of searching this morning on "angles", and I couldn't find anything for getting the "out-of-plane" angle.

I'd like the user to pick two points, and return somehow the angle out of plane.

....

Something like this, perhaps:

(setq

p1 (getpoint "\nPick first point: ")

p2 (getpoint "\nPick second point: ")

distinXY (distance (list (car p1) (cadr p1) 0) (list (car p2) (cadr p2) 0))

deltaZ (- (caddr p2) (caddr p1))

angfromXYplane (angtos (atan (/ deltaZ distinXY)))

)

or, with fewer variables:

(setq

p1 (getpoint "\nPick first point: ")

p2 (getpoint "\nPick second point: ")

); setq

(angtos

(atan

(/

(- (caddr p2) (caddr p1)); = change in Z

(distance (list (car p1) (cadr p1) 0) (list (car p2) (cadr p2) 0)); = distance projected in XY plane

); /

); atan

); angtos

I do find that it always returns positive values -- e.g. from 0,0,0 to 1,0,-1 returns 315 degrees. If you'd rather have that say -45 degrees, you'd need to do some conversion somewhere.

Kent Cooper

*Expert Elite*

6,025 Posts

669 Kudos

Registered:
09-13-2004

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-01-2012 11:00 AM in reply to:
Kent1Cooper

Kent1Cooper wrote:....I do find that it always returns positive values -- e.g. from 0,0,0 to 1,0,-1 returns 315 degrees. If you'd rather have that say -45 degrees, you'd need to do some conversion somewhere.

Like this, for instance:

(setq

p1 (getpoint "\nPick first point: ")

p2 (getpoint "\nPick second point: ")

); setq

(strcat

(if (< (caddr p2) (caddr p1)) "-" "")

(angtos

(atan

(/

(abs (- (caddr p2) (caddr p1)))

(distance (list (car p1) (cadr p1) 0) (list (car p2) (cadr p2) 0))

); /

); atan

); angtos

); strcat

Kent Cooper

Mentor

153 Posts

33 Kudos

Registered:
02-06-2007

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-01-2012 12:10 PM in reply to:
kpennell

For some reasons, I wrote this code to replace native **Distance** command. It will give you the angle from XY plane among other infos.

(defun C:DI16 (/ *error* lst msg p1 p2 oldzin) (defun *error* (msg) (and msg (not (eq msg "Function cancelled")) (princ msg) ) (setvar 'dimzin oldzin) (princ) ) (setq oldzin (getvar 'dimzin)) (setvar 'dimzin 1) (and (setq p1 (getpoint "\nFirst Point: ")) (setq p2 (getpoint p1 "\nSecond Point: ")) (setq lst (mapcar '- p2 p1) lst1 (mapcar '(lambda (x) (rtos x 2 16)) lst) ) (setq lst1 (cons (angtos (atan (caddr lst) (sqrt (+ (expt (car lst) 2) (expt (cadr lst) 2)))) (getvar 'aunits) 16) lst1)) (setq lst1 (cons (angtos (atan (cadr lst) (car lst)) (getvar 'aunits) 16) lst1)) (setq lst1 (cons (rtos (distance p1 p2) 2 16) lst1)) (mapcar '(lambda (x msg) (princ (strcat msg x)) ) lst1 (list "\nDistance = " "\nAngle in XY Plane = " "\nAngle from XY Plane = " "\nDelta X = " "\nDelta Y = " "\nDelta Z = " ) ) ) (*error* nil) (textscr) (princ) )

Search This Board

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Post to the Community

Have questions about Autodesk products? Ask the community.

The Knowledge Network

Access a broad range of knowledge to help get the most out of your products and services.

Download & Installation

Getting your Software

Downloads & Upgrades

Serial Numbers & Product Keys

Installation & Licensing

Activation & Registration

Network License Administration

Subscription Management

Sign In / Create Account

Maintenance Subscription Help

Desktop Subscription Help

Cloud Service Subscription FAQ

Announcements

Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!

- Privacy | Legal Notices & Trademarks | Report Noncompliance | Site map | © Copyright 2014 Autodesk Inc. All rights reserved

Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. Please see the Autodesk Creative Commons FAQ for more information.