LM:OrthoPoint

LM:OrthoPoint

Moshe-A
Mentor Mentor
913 Views
11 Replies
Message 1 of 12

LM:OrthoPoint

Moshe-A
Mentor
Mentor

Guys,

 

Hope Lee Mac can see this but if not? can some body else take a look at (LM:OrthoPoint) function . it work splendid when ucs is rotate about Z axis and origin at 0,0,0 but when using UCS Object is fails to align with the new ucs.

 

maybe some one already fixed it?

 

i did try to replace this => (setq a (angle '(0. 0. 0.) n))

with this =>  (setq a (angle (getvar 'ucsorg) n)  -  but still doesn't work

 

thanks in advance

Moshe

 

(defun LM:OrthoPoint ( base point )
    (if (zerop (getvar 'ORTHOMODE))
        point
        (apply 'polar
            (cons base
                (
                    (lambda ( n / a x z )
                        (setq x (- (car   (trans point 0 n)) (car   (trans base 0 n)))
                              z (- (caddr (trans point 0 n)) (caddr (trans base 0 n)))
                              a (angle '(0. 0. 0.) n)
                        )
                        (if (< (abs z) (abs x))
                            (list (+ a (/ pi 2.)) x)
                            (list a z)
                        )
                    )
                    (trans (getvar 'UCSXDIR) 0 1)
                )
            )
        )
    )
)

 

0 Likes
Accepted solutions (1)
914 Views
11 Replies
Replies (11)
Message 2 of 12

ВeekeeCZ
Consultant
Consultant

@Moshe-A,

afaik he's not around here so ofter to catch your issue unless you tag him @Lee_Mac to notify.

Also, recommend using his website form HERE  to reach him.

Good luck.

0 Likes
Message 3 of 12

Moshe-A
Mentor
Mentor

afaik he's not around here so ofter to catch your issue unless you tag him @Lee_Mac to notify.

 

I did not tag him (i assume he is most busy coding) so your are most welcome.

 

Moshe

 

 

0 Likes
Message 4 of 12

CodeDing
Advisor
Advisor

@Moshe-A ,

 

This is definitely not the final solution, but I have found that in some instances removing the (trans ...) function around the UCSXDIR corrects the issue you describe.. However, in some instances (such as a simple UCS change, not to an object) it ruins the existing functionality. I'm not sure what would indicate when one would be used over the other...

(defun LM:OrthoPoint ( base point )
    (if (zerop (getvar 'ORTHOMODE))
        point
        (apply 'polar
            (cons base
                (
                    (lambda ( n / a x z )
                        (setq x (- (car   (trans point 0 n)) (car   (trans base 0 n)))
                              z (- (caddr (trans point 0 n)) (caddr (trans base 0 n)))
                              a (angle '(0. 0. 0.) n)
                        )
                        (if (< (abs z) (abs x))
                            (list (+ a (/ pi 2.)) x)
                            (list a z)
                        )
                    )
                    (trans (getvar 'UCSXDIR) 0 1)
                )
            )
        )
    )
)

 

Best,

~DD

0 Likes
Message 5 of 12

Moshe-A
Mentor
Mentor

@thanks @CodeDing  for the input i'll test this tonight

 

When i investigate it last night, i wanted to see what is the difference (in sysvars) when rotating about z axis and using OBject and did not see any change except for UCSORG. that's why i thought to replace '(0. 0. 0.) with ucsorg.

 

Moshe

 

 

 

 

 

0 Likes
Message 6 of 12

marko_ribar
Advisor
Advisor
Accepted solution

No, it should be like this :

 

 

(defun LM:OrthoPoint ( base point )
    (if (zerop (getvar 'ORTHOMODE))
        point
        (apply 'polar
            (cons base
                (
                    (lambda ( n / a x z )
                        (setq x (- (car   (trans point 0 n)) (car   (trans base 0 n)))
                              z (- (caddr (trans point 0 n)) (caddr (trans base 0 n)))
                              a (angle '(0. 0. 0.) n)
                        )
                        (if (< (abs z) (abs x))
                            (list (+ a (/ pi 2.)) x)
                            (list a z)
                        )
                    )
                    '(1. 0. 0.)
                )
            )
        )
    )
)
Marko Ribar, d.i.a. (graduated engineer of architecture)
Message 7 of 12

CodeDing
Advisor
Advisor

@marko_ribar 's solution seems to work for me 😎👍

0 Likes
Message 8 of 12

Moshe-A
Mentor
Mentor

excellent @marko_ribar  it works - thank you very much 😀

to complete this, one more switch SNAPANG 

if it is not 0 (under WCS) it does not work and under any UCS .

0 Likes
Message 9 of 12

marko_ribar
Advisor
Advisor

If you want to make ortho follow cursor angle (SNAPANG), then use this instead, otherwise to follow UCS orientation use my previous version...

 

 

(defun LM:OrthoPoint ( base point )
    (if (zerop (getvar 'ORTHOMODE))
        point
        (apply 'polar
            (cons base
                (
                    (lambda ( n / a x z )
                        (setq x (- (car   (trans point 0 n)) (car   (trans base 0 n)))
                              z (- (caddr (trans point 0 n)) (caddr (trans base 0 n)))
                              a (angle '(0. 0. 0.) n)
                        )
                        (if (< (abs z) (abs x))
                            (list (+ a (/ pi 2.)) x)
                            (list a z)
                        )
                    )
                    (polar '(0. 0. 0.) (getvar 'SNAPANG) 1.0)
                )
            )
        )
    )
)
Marko Ribar, d.i.a. (graduated engineer of architecture)
Message 10 of 12

Moshe-A
Mentor
Mentor

OK

 

Accept my apology for one more, does UCS ob and snapang enable can be solved?

 

 

 

 

 

 

 

0 Likes
Message 11 of 12

marko_ribar
Advisor
Advisor

Look every problem is solvable, you just have to know what do you want to achieve... I must admit that I don't fully understand what you want with UCS ob and SNAPANG together, but if I may guess I believe you are asking what is the best for usage between those 2 variants... IMHO the second one is more general and covers situations that may occur by using SNAPANG with or without changing UCS... It's just unclear what user wants every time : to always follow UCS XY axises or cursor angle in every situation... If SNAPANG=0 then second variant will fullfill both UCS and cursor, and if SNAPANG/=0 then also second variant will obay cursor orientation, but then UCS XY will be neglected... It's simply what user wants, you can't wish both things at the same time, you have to decide and then act according to needs...

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 12 of 12

Moshe-A
Mentor
Mentor

@marko_ribar ,

 

I just want to make my custom command to react much like any other AutoCAD command even the odds a user may enter UCS + SNAPANG is close to zero.

 

again, thank you very much

Moshe

 

0 Likes