See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Need Help: LISP Changing Routine Angle

  1. #1
    Member
    Join Date
    2016-10
    Posts
    9
    Login to Give a bone
    0

    Default Need Help: LISP Changing Routine Angle

    I have this attached code, it is working fine I just want to change the angles, instead of 120,60, i want it to be 90 degrees. I tried changing the values but doesn't work. Anybody please help me. Thank you in Advance.
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,508
    Login to Give a bone
    0

    Default Re: Need Help: LISP Changing Routine Angle

    Quote Originally Posted by myrwen.juntereal736858 View Post
    I have this attached code, it is working fine I just want to change the angles, instead of 120,60, i want it to be 90 degrees. I tried changing the values but doesn't work. Anybody please help me. Thank you in Advance.
    You were close by changing the angles, you also needed to set the vertical leader distance to "1.0" (vs 1.1547)
    Code:
    (setq l_ang 270)
    (setq l_ang1 90)
    (defun c:q (/ sty nm p1 p2 ateblk p3)
      (command "cmdecho" "0")
      (setq osm (getvar "osmode"))
      (setq ort (getvar "orthomode"))
    				;(command "osmode" "2")
      (setq p1 (getpoint "\nPick origin point:)"))
      (command "osmode" "0")
      (command "orthomode" "0")
      (setq p2 (getpoint "\nPick target" p1))
      (princ)
      (if (< (car p1) (car p2))
        (progn
          (if (< (cadr p1) (cadr p2))
    	(setq p3d (- (cadr p1) (cadr p2)))
          )
          (if (< (cadr p2) (cadr p1))
    	(setq p3d (- (cadr p2) (cadr p1)))
          )
          (if (< (cadr p2) (cadr p1))
    	(progn
    	  (setq p3 (polar p2 (+ 0.0 (dtr (- l_ang))) (* p3d 1.0)))
    	  (command "LEADER" p2 p3 p1 "" "" "n")
    	)
          )
          (if (< (cadr p1) (cadr p2))
    	(progn
    	  (setq p3 (polar p2 (+ 0.0 (dtr l_ang)) (* p3d 1.0)))
    	  (command "LEADER" p2 p3 p1 "" "" "n")
    	)
          )
        )
      )
      (if (< (car p2) (car p1))
        (progn
          (if (< (cadr p1) (cadr p2))
    	(setq p3d (- (cadr p1) (cadr p2)))
          )
          (if (< (cadr p2) (cadr p1))
    	(setq p3d (- (cadr p2) (cadr p1)))
          )
          (if (< (cadr p2) (cadr p1))
    	(progn
    	  (setq p3 (polar p2 (+ 0.0 (dtr (- l_ang1))) (* p3d 1.0)))
    	  (command "LEADER" p2 p3 p1 "" "" "n")
    	)
          )
          (if (< (cadr p1) (cadr p2))
    	(progn
    	  (setq p3 (polar p2 (+ 0.0 (dtr l_ang1)) (* p3d 1.0)))
    	  (command "leader" p2 p3 p1 "" "" "n")
    	)
          )
        )
      )
      (command "osmode" osm)
      (command "orthomode" ort)
    )
    					;
    (defun dtr (a)
      (* pi (/ a 180.0))
    )
    					;
    (I also noticed this works correctly in one direction: leader going from right to left to match your image. I you go left to right it does't work)
    Last edited by tedg; 2016-10-13 at 12:02 PM. Reason: updated note

  3. #3
    Member
    Join Date
    2016-10
    Posts
    9
    Login to Give a bone
    0

    Default Re: Need Help: LISP Changing Routine Angle

    Thanks a lot ted, this works good. I hope we can find a way to work it in opposite direction

  4. #4
    Member
    Join Date
    2016-10
    Posts
    9
    Login to Give a bone
    0

    Default Re: Need Help: LISP Changing Routine Angle

    Got it instead of "270" it needs to be "-270", Cheers!

  5. #5
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,508
    Login to Give a bone
    1

    Default Re: Need Help: LISP Changing Routine Angle

    Quote Originally Posted by myrwen.juntereal736858 View Post
    Thanks a lot ted, this works good. I hope we can find a way to work it in opposite direction
    I figured out how to make this work in both directions... you only need one angle variable (setq l_ang 90)
    And adjusted the code accordingly:
    Code:
    (setq l_ang 90)
    (defun c:q (/ sty nm p1 p2 ateblk p3)
      (command "cmdecho" "0")
      (setq osm (getvar "osmode"))
      (setq ort (getvar "orthomode"))
    				;(command "osmode" "2")
      (setq p1 (getpoint "\nPick origin point:)"))
      (command "osmode" "0")
      (command "orthomode" "0")
      (setq p2 (getpoint "\nPick target" p1))
      (princ)
      (if (< (car p1) (car p2))
        (progn
          (if (< (cadr p1) (cadr p2))
    	(setq p3d (- (cadr p1) (cadr p2)))
          )
          (if (< (cadr p2) (cadr p1))
    	(setq p3d (- (cadr p2) (cadr p1)))
          )
          (if (< (cadr p2) (cadr p1))
    	(progn
    	  (setq p3 (polar p2 (+ 0.0 (dtr (- l_ang))) (* p3d 1.0)))
    	  (command "LEADER" p2 p3 p1 "" "" "n")
    	)
          )
          (if (< (cadr p1) (cadr p2))
    	(progn
    	  (setq p3 (polar p2 (+ 0.0 (dtr l_ang)) (* p3d 1.0)))
    	  (command "LEADER" p2 p3 p1 "" "" "n")
    	)
          )
        )
      )
      (if (< (car p2) (car p1))
        (progn
          (if (< (cadr p1) (cadr p2))
    	(setq p3d (- (cadr p1) (cadr p2)))
          )
          (if (< (cadr p2) (cadr p1))
    	(setq p3d (- (cadr p2) (cadr p1)))
          )
          (if (< (cadr p2) (cadr p1))
    	(progn
    	  (setq p3 (polar p2 (+ 0.0 (dtr (- l_ang))) (* p3d 1.0)))
    	  (command "LEADER" p2 p3 p1 "" "" "n")
    	)
          )
          (if (< (cadr p1) (cadr p2))
    	(progn
    	  (setq p3 (polar p2 (+ 0.0 (dtr l_ang)) (* p3d 1.0)))
    	  (command "leader" p2 p3 p1 "" "" "n")
    	)
          )
        )
      )
      (command "osmode" osm)
      (command "orthomode" ort)
    )
    					;
    (defun dtr (a)
      (* pi (/ a 180.0))
    )
    					;
    Just saw your latest reply, that's good you figured it out another way, see my code above seems to work too, cheers.
    BTW "-270" = "90"

  6. #6
    Member
    Join Date
    2016-10
    Posts
    9
    Login to Give a bone
    0

    Default Re: Need Help: LISP Changing Routine Angle

    oh yeah that's right now im trying it with MLEADER but still not working, might need some assistance again.

  7. #7
    Member
    Join Date
    2016-10
    Posts
    9
    Login to Give a bone
    0

    Default Re: Need Help: LISP Changing Routine Angle

    hi tedg this is now the working routine using mleader, in previous post im asking to make it 90 degrees but now my colleagues want a different angle so im wondering how i could compute (or change it like for example 45 degrees). The last time we change is "setq l_ang90" and "(* p3d 1.0)))" which i dont have any idea how that works :l


    Quote Originally Posted by tedg View Post
    I figured out how to make this work in both directions... you only need one angle variable (setq l_ang 90)
    And adjusted the code accordingly:
    Code:
    (setq l_ang 90)
    (defun c:q (/ sty nm p1 p2 ateblk p3)
      (command "cmdecho" "0")
      (setq osm (getvar "osmode"))
      (setq ort (getvar "orthomode"))
    				;(command "osmode" "2")
      (setq p1 (getpoint "\nPick origin point:)"))
      (command "osmode" "0")
      (command "orthomode" "0")
      (setq p2 (getpoint "\nPick target" p1))
      (princ)
      (if (< (car p1) (car p2))
        (progn
          (if (< (cadr p1) (cadr p2))
    	(setq p3d (- (cadr p1) (cadr p2)))
          )
          (if (< (cadr p2) (cadr p1))
    	(setq p3d (- (cadr p2) (cadr p1)))
          )
          (if (< (cadr p2) (cadr p1))
    	(progn
    	  (setq p3 (polar p2 (+ 0.0 (dtr (- l_ang))) (* p3d 1.0)))
    	  (command "LEADER" p2 p3 p1 "" "" "n")
    	)
          )
          (if (< (cadr p1) (cadr p2))
    	(progn
    	  (setq p3 (polar p2 (+ 0.0 (dtr l_ang)) (* p3d 1.0)))
    	  (command "LEADER" p2 p3 p1 "" "" "n")
    	)
          )
        )
      )
      (if (< (car p2) (car p1))
        (progn
          (if (< (cadr p1) (cadr p2))
    	(setq p3d (- (cadr p1) (cadr p2)))
          )
          (if (< (cadr p2) (cadr p1))
    	(setq p3d (- (cadr p2) (cadr p1)))
          )
          (if (< (cadr p2) (cadr p1))
    	(progn
    	  (setq p3 (polar p2 (+ 0.0 (dtr (- l_ang))) (* p3d 1.0)))
    	  (command "LEADER" p2 p3 p1 "" "" "n")
    	)
          )
          (if (< (cadr p1) (cadr p2))
    	(progn
    	  (setq p3 (polar p2 (+ 0.0 (dtr l_ang)) (* p3d 1.0)))
    	  (command "leader" p2 p3 p1 "" "" "n")
    	)
          )
        )
      )
      (command "osmode" osm)
      (command "orthomode" ort)
    )
    					;
    (defun dtr (a)
      (* pi (/ a 180.0))
    )
    					;
    Just saw your latest reply, that's good you figured it out another way, see my code above seems to work too, cheers.
    BTW "-270" = "90"
    (defun c:mm (/ sty nm p1 p2 ateblk p3)
    (setq l_ang 90)
    (command "cmdecho" "0")
    (setq osm (getvar "osmode"))
    (setq ort (getvar "orthomode"));
    (command "osmode" "15359")
    (setq p1 (getpoint "\nPick origin point"))
    (command "osmode" "0")
    (command "orthomode" "0")
    (setq p2 (getpoint "\nPick target" p1))
    (princ)
    (if (< (car p1) (car p2))
    (progn
    (if (< (cadr p1) (cadr p2))
    (setq p3d (- (cadr p1) (cadr p2)))
    )
    (if (< (cadr p2) (cadr p1))
    (setq p3d (- (cadr p2) (cadr p1)))
    )
    (if (< (cadr p2) (cadr p1))
    (progn
    (setq p3 (polar p2 (+ 0.0 (dtr (- l_ang))) (* p3d 1.0)))
    )
    )
    (if (< (cadr p1) (cadr p2))
    (progn
    (setq p3 (polar p2 (+ 0.0 (dtr l_ang)) (* p3d 1.0)))
    )
    )
    )
    )
    (if (< (car p2) (car p1))
    (progn
    (if (< (cadr p1) (cadr p2))
    (setq p3d (- (cadr p1) (cadr p2)))
    )
    (if (< (cadr p2) (cadr p1))
    (setq p3d (- (cadr p2) (cadr p1)))
    )
    (if (< (cadr p2) (cadr p1))
    (progn
    (setq p3 (polar p2 (+ 0.0 (dtr (- l_ang))) (* p3d 1.0)))
    )
    )
    (if (< (cadr p1) (cadr p2))
    (progn
    (setq p3 (polar p2 (+ 0.0 (dtr l_ang)) (* p3d 1.0)))
    )
    )
    )
    )
    (command "_mleader" "L" "H" "o" "m" "3" "x" p2 p3 p1 "XX-XX")
    (command "osmode" osm)
    (COMMAND "DDEDIT" "L")
    (command "orthomode" ort)
    )
    ;
    (defun dtr (a)
    (* pi (/ a 180.0))
    );

  8. #8
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,508
    Login to Give a bone
    0

    Default Re: Need Help: LISP Changing Routine Angle

    Good job on the Mleader attempt.
    The code is a bit over my head too, but through trail and error, and using the variables from the original code (the 2 angles) I came up with this:
    It seems to work, I can't get it exact, but the (* p3d 1.414245) is what is driving the vertical distance from end of the horizontal landing to the bend.
    I'm sure that number has a relationship to the mleader, and the points picked, but I don't know what that is.
    Code:
    (setq l_ang 45)
    (setq l_ang1 135)
    (defun c:ttt (/ sty nm p1 p2 ateblk p3)
      (command "cmdecho" "0")
      (setq osm (getvar "osmode"))
      (setq ort (getvar "orthomode"));
      (command "osmode" "15359")
      (setq p1 (getpoint "\nPick origin point:)"))
      (command "osmode" "0")
      (command "orthomode" "0")
      (setq p2 (getpoint "\nPick target" p1))
      (princ)
      (if (< (car p1) (car p2))
        (progn
          (if (< (cadr p1) (cadr p2))
    	(setq p3d (- (cadr p1) (cadr p2)))
          )
          (if (< (cadr p2) (cadr p1))
    	(setq p3d (- (cadr p2) (cadr p1)))
          )
          (if (< (cadr p2) (cadr p1))
    	(progn
    	  (setq p3 (polar p2 (+ 0.0 (dtr (- l_ang))) (* p3d 1.414245)))
    	)
          )
          (if (< (cadr p1) (cadr p2))
    	(progn
    	  (setq p3 (polar p2 (+ 0.0 (dtr l_ang)) (* p3d 1.414245)))
    	)
          )
        )
      )
      (if (< (car p2) (car p1))
        (progn
          (if (< (cadr p1) (cadr p2))
    	(setq p3d (- (cadr p1) (cadr p2)))
          )
          (if (< (cadr p2) (cadr p1))
    	(setq p3d (- (cadr p2) (cadr p1)))
          )
          (if (< (cadr p2) (cadr p1))
    	(progn
    	  (setq p3 (polar p2 (+ 0.0 (dtr (- l_ang1))) (* p3d 1.414245)))
    	)
          )
          (if (< (cadr p1) (cadr p2))
    	(progn
    	  (setq p3 (polar p2 (+ 0.0 (dtr l_ang1)) (* p3d 1.414245)))
    	)
          )
        )
      )
      (command "_mleader" "L" "H" "o" "m" "3" "x" p2 p3 p1 "XX-XX")
      (command "osmode" osm)
      (COMMAND "DDEDIT" "L")
      (command "orthomode" ort)
    )
    ;
    (defun dtr (a)
      (* pi (/ a 180.0))
    );

  9. #9
    Member
    Join Date
    2016-10
    Posts
    9
    Login to Give a bone
    0

    Default Re: Need Help: LISP Changing Routine Angle

    Thank you very much Ted, now it's working great. uhmm just one more question, How did you get "1.414245" I've been trying so hard to understand but i cant still figure out :/

  10. #10
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,508
    Login to Give a bone
    0

    Default Re: Need Help: LISP Changing Routine Angle

    Quote Originally Posted by loudy000 View Post
    Thank you very much Ted, now it's working great. uhmm just one more question, How did you get "1.414245" I've been trying so hard to understand but i cant still figure out :/
    Yea, that's what I was trying to say... I just kept adjusting that number until it was as close to level with the Mleader shoulder as possible.
    In other words, its trail and error, I don't know the math behind it.

    Where that value was "1.0" for the 90 degree Leader routine, that number changes when the leader is at an angle (see your first routine for the "60 and 120 degrees", that was different as well).

    Glad to help, wish I could explain it better, I'm not sure where you got the original routine but whoever wrote it could probably tell you.


Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 8
    Last Post: 2016-04-14, 11:18 AM
  2. Changing rotation angle of blocks using lsp
    By ReachAndre in forum AutoLISP
    Replies: 1
    Last Post: 2014-08-06, 07:45 PM
  3. Help with a lisp routine to add a 12" line to this routine
    By Orbytal.edge341183 in forum AutoLISP
    Replies: 3
    Last Post: 2012-11-14, 10:33 PM
  4. Changing text oblique angle using lisp
    By samir.joshi in forum AutoLISP
    Replies: 3
    Last Post: 2009-07-09, 07:09 AM
  5. Gobally changing oblique angle
    By Anthony Rhodes in forum AutoCAD General
    Replies: 17
    Last Post: 2009-05-21, 06:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •