Author Topic: get angle of line and insert at the end  (Read 7188 times)

0 Members and 1 Guest are viewing this topic.

andrew_nao

  • Guest
Re: get angle of line and insert at the end
« Reply #15 on: March 23, 2012, 07:31:36 AM »
I think the problem is that he is not allowed to change those or at least he must
change them back to there company standard.

my angle base is 0

we dont have any company standard really. other then our layer names.. lol which is sad to say the least.


my angbase changed to  270 somehow an now it wont let me change it back
« Last Edit: March 23, 2012, 09:31:56 AM by andrew_nao »

andrew_nao

  • Guest
Re: get angle of line and insert at the end
« Reply #16 on: March 23, 2012, 09:10:03 AM »
Ensure:

ANGBASE = 90.0
ANGDIR  = 1


Then try this:
...


this is exactly what im trying to do. with the exception of putting the text in as a field and turn the decimal into degrees

ill use this as reference, but im still going to try to do it myself.
sense of accomplishment type of thing.

but the anglebase and angdir vars was a step in the right direction for me
if there was a way to get the XY plane value that is listed from when you list a line, i would be in great shape but im getting some other value.

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: get angle of line and insert at the end
« Reply #17 on: March 23, 2012, 09:38:46 AM »
this is exactly what im trying to do. with the exception of putting the text in as a field and turn the decimal into degrees

You could change the Field formatting quite easily to include a degree symbol if necessary.

if there was a way to get the XY plane value that is listed from when you list a line, i would be in great shape but im getting some other value.

Note that the angle returned by the LIST command is affected by the ANGBASE and ANGDIR System Variables, the angle returned by the angle function on the two endpoints is not and is always measured anti-clockwise from the X-Axis in the current plane.

andrew_nao

  • Guest
Re: get angle of line and insert at the end
« Reply #18 on: March 23, 2012, 10:53:58 AM »
You could change the Field formatting quite easily to include a degree symbol if necessary.

yea i can change the formatting but i was hoping to just use text
but it dont look like i can

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: get angle of line and insert at the end
« Reply #19 on: March 23, 2012, 11:07:00 AM »
but it dont look like i can

Of course you can. But you will need to adjust the angle value to account for the settings of ANGBASE / ANGDIR

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: get angle of line and insert at the end
« Reply #20 on: March 23, 2012, 02:39:22 PM »
Judging from your earlier response, it sounds like you've given up on this, so here's my earlier post modified to not use a Field:

Code - Auto/Visual Lisp: [Select]
  1. ;; Line Angle  -  Lee Mac
  2. ;; Displays the Angle of a Line at its endpoint
  3.  
  4. (defun c:LineAng ( / acdoc acsel acspc mtx pnt )
  5.          acspc ((if (= 1 (getvar 'CVPORT)) vla-get-paperspace vla-get-modelspace) acdoc)
  6.    )
  7.    (if (ssget '((0 . "LINE")))
  8.        (progn
  9.            (while (= 8 (logand 8 (getvar 'UNDOCTL)))
  10.                (vla-endundomark acdoc)
  11.            )
  12.            (vla-startundomark acdoc)
  13.            (vlax-for obj (setq acsel (vla-get-activeselectionset acdoc))
  14.                (setq pnt
  15.                    (vlax-3D-point
  16.                        (polar
  17.                            (vlax-get obj 'endpoint)
  18.                            (vlax-get obj 'angle)
  19.                            (getvar 'TEXTSIZE)
  20.                        )
  21.                    )
  22.                )
  23.                (setq mtx (vla-addmtext acspc pnt 0.0 (angtos (vlax-get obj 'angle) 0 3)))
  24.                (vla-put-attachmentpoint mtx acattachmentpointmiddlecenter)
  25.                (vla-put-insertionpoint  mtx pnt)
  26.            )
  27.            (vla-delete acsel)
  28.            (vla-endundomark acdoc)
  29.        )
  30.    )
  31.    (princ)
  32. )

Again, ensure:

ANGBASE = 90
ANGDIR  = 1




For those interested, here is one possible version of an angle function that respects the settings of ANGBASE and ANGDIR:

Code - Auto/Visual Lisp: [Select]
  1. ;; 'angle' function to respect ANGBASE / ANGDIR  -  Lee Mac
  2.  
  3. (defun _angle ( p1 p2 )
  4.     (rem
  5.         (+ pi pi
  6.             (
  7.                 (if (zerop (getvar 'ANGDIR)) + -)
  8.                 (- (angle p1 p2) (getvar 'ANGBASE))
  9.             )
  10.         )
  11.         (+ pi pi)
  12.     )
  13. )

andrew_nao

  • Guest
Re: get angle of line and insert at the end
« Reply #21 on: March 23, 2012, 03:31:07 PM »
Judging from your earlier response, it sounds like you've given up on this...

i have. i got frustrated that i couldnt do it on my own.

i thought with my code, it was something stupid and simple i was missing.

nivuahc

  • Guest
Re: get angle of line and insert at the end
« Reply #22 on: March 27, 2012, 08:53:55 AM »
i have. i got frustrated that i couldnt do it on my own.

i thought with my code, it was something stupid and simple i was missing.

I know that feeling all too well.

When I get in that type of situation, more often than not it's because I've got metaphoric blinders on and I can't see the problem though it's likely right in front of me. What I like to do is step away from the problem for a bit and try to focus on something else.

That usually helps to remove those blinders and allows me to see things more clearly.

And tossing around ideas with others usually helps me to see things with another pair of eyes. It's why I love this place so much.

But don't give up.

At least not permanently.