Get AEC_WINDOW rotation?

Get AEC_WINDOW rotation?

DC-MWA
Collaborator Collaborator
812 Views
5 Replies
Message 1 of 6

Get AEC_WINDOW rotation?

DC-MWA
Collaborator
Collaborator

I have a little rourtine we I use to label doors and windows. It works well but it would be nice if it would automatically rotate the label to the same rotation as the window/door selected.  If I use the list command in autocad it shows the rotation, but when I try to get the rotation it is always 0.00.

 

Here is what I've been trying to use:

(setq entw (entsel "\nSelect Door or Window: "))
(setq objw (vlax-ename->vla-object (car entw)))
(setq get_rotat (vlax-get objw 'Rotation))

 

Any ideas??

 

0 Likes
Accepted solutions (1)
813 Views
5 Replies
Replies (5)
Message 2 of 6

CodeDing
Advisor
Advisor

@DC-MWA ,

 

Can you post an example drawing with this object?

It sounds like you are using AutoCAD Architectural.. So bear in mind that not all users will be able to help you. I, personally, do not have that toolset and have never used it.

 

Best,

~DD

0 Likes
Message 3 of 6

DC-MWA
Collaborator
Collaborator

Good morning,

Yes I am using Architectural. I have attached a drawing with sample wall, door, window.

I just tested and I can get the roatation of walls, but not doors/windows.

 

Se attached drawing as requested.

Message 4 of 6

CodeDing
Advisor
Advisor

@DC-MWA ,

 

This is the only way I can find to accomplish it. Maybe there are some properties I cannot access without the Architectural toolset, but this should accomplish the same thing.

(defun c:TEST ( / e ang)
  (if (and (setq e (car (entsel "\nSelect AEC Door or Window: ")))
           (setq ang (GetDWAngle e)))
    (alert (strcat "\nAngle is:\n"
                   (angtos ang 3 2) " - radians\n"
                   (angtos ang 0 2) " - degrees"
    ));strcat/alert
  ;else
    (prompt "\nDoor or Window not selected.")
  );if
  (princ)
);defun

(defun GetDWAngle (e / )
  ;Get Door/Window Angle
  ;e - ename, of AEC_DOOR or AEC_WINDOW object
  ;returns - real, angle of door or window in radians, else nil
  (if (member (cdr (assoc 0 (entget e))) '("AEC_DOOR" "AEC_WINDOW"))
    (+
      (angle
        (list (getpropertyvalue e "StartPoint/X") (getpropertyvalue e "StartPoint/Y"))
        (list (getpropertyvalue e "EndPoint/X") (getpropertyvalue e "EndPoint/Y"))
      );angle
      (* 0.5 pi)
    );+
  );if
);defun

Best,

~DD

0 Likes
Message 5 of 6

CodeDing
Advisor
Advisor
Accepted solution

@DC-MWA ,

 

While the previous function SHOULD work in most cases, it can actually potentially return a value greater than 2*pi, which some people might not expect.

 

I updated the function so that it will now only return values between 0 - 2*pi.

 

(defun GetDWAngle (e / pt)
  ;Get Door/Window Angle
  ;e - ename, of AEC_DOOR or AEC_WINDOW object
  ;returns - real, angle of door or window in radians, else nil
  (if (member (cdr (assoc 0 (entget e))) '("AEC_DOOR" "AEC_WINDOW"))
    (angle
      (setq pt (list (getpropertyvalue e "StartPoint/X") (getpropertyvalue e "StartPoint/Y")))
      (polar pt
             (+ (angle pt (list (getpropertyvalue e "EndPoint/X") (getpropertyvalue e "EndPoint/Y")))
                (* 0.5 pi)
             );+
             1
      );polar
    );angle
  );if
);defun

 

Best,

~DD

0 Likes
Message 6 of 6

DC-MWA
Collaborator
Collaborator

I am always amazed by the Talent and knowledge of the folks in these forums.

I was able to take your code and eget it to work in my routine.

 

It works perfect.

thank you very much!

-dc

0 Likes