Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: Rotate multiple blocks about the insertion point to global fixed point.

  1. #1
    100 Club
    Join Date
    2015-09
    Posts
    154
    Login to Give a bone
    0

    Default Rotate multiple blocks about the insertion point to global fixed point.

    Hi,

    Could anyone assist me in modifying the following code that I found to enable the following:

    step 1:Select blocks
    step 2: Select a single point that all blocks should point towards (blocks are arrows and all have to point towards mecca)

    step 3: then using the rotate command on each block

    base point = insertion point
    use a reference angle of 90
    for the new angle it should use a point (that being the point selected in step 2)


    #
    ;RotBlock.lsp by Maurizio
    ;Start code
    (defun C:RotBlock ()
    (princ “nSelect blocks: “)
    (setq grp (ssget))
    (setq rotAngle (getangle “nRotation angle: “)) ;
    (setq rotAngle (atof (angtos rotAngle 0)))
    (setq j 0)
    (repeat (sslength grp)
    (setq eName (ssname grp j))
    (setq pt (cdr (assoc 10 (entget eName))))
    (command “_rotate” eName “” pt rotAngle)
    (setq j (1+ j))
    )
    )
    ;End code
    #

    for me I need to change this to
    (setq rotAngle (getangle “nRotation angle: “)) ;
    (setq rotAngle (atof (angtos rotAngle 0)))

    to (setq Rotangle (getpoint "nRotate block to point: "))

    and this line
    (command “_rotate” eName “” pt rotAngle)

    to (command "_rotate" ename "" pt "_r" "90" "_p" rotangle)

    but that does not do it.

    any ideas? I thought it strange that I was not able to find a similar lisp online.

    Any help much appreciated.
    thanks

  2. #2
    100 Club
    Join Date
    2000-11
    Location
    Ontario, Canada
    Posts
    116
    Login to Give a bone
    0

    Default Re: Rotate multiple blocks about the insertion point to global fixed point.

    This is necessarily basic, as I am unfortunately pressed for time, but it should do what you seem to be requesting...

    Code:
    (defun c:pointat ( / ARRW-N ARRWS N N-PT NUM PTA)
      (vl-load-com)
      (if (setq arrws (ssget '((0 . "INSERT")))
    	    ); setq
        (progn
          (setq num (sslength arrws)
    	    pta (getpoint "\nPick the Target... ")
    	    n 0
    	    ); setq
          (while (< n num)
    	(setq arrw-n (vlax-ename->vla-object (ssname arrws n))
    	      n-pt (vlax-get arrw-n 'insertionpoint)
    	      n (1+ n)
    	      ); setq
    	(vla-put-rotation arrw-n (angle n-pt pta))
    	); while
          ); progn
        (prompt "\nNo blocks selected. ")
        ); if
      (princ)
      ); defun

  3. #3
    All AUGI, all the time Tharwat's Avatar
    Join Date
    2010-06
    Posts
    914
    Login to Give a bone
    0

    Default Re: Rotate multiple blocks about the insertion point to global fixed point.

    This may not give you the right direction if your blocks are not on zero angle , anyway try it and i can modify it if you in need of any .

    Code:
    (defun c:Test (/ ss i sn gr)
      ;; Tharwat 02. Oct. 2012 ;;;
      (if (setq ss (ssget "_:L" '((0 . "INSERT"))))
        (repeat (setq i (sslength ss))
          (setq sn (cons (ssname ss (setq i (1- i))) sn))
        )
      )
      (while (eq (car (setq gr (grread t 15 0))) 5)
        (redraw)
        (foreach b sn
          (entmod
            (subst
              (cons
                50
                (- (angle (cdr (assoc 10 (entget b))) (cadr gr)) (/ pi 2.))
              )
              (assoc 50 (entget b))
              (entget b)
            )
          )
        )
      )
      (princ)
    )

  4. #4
    All AUGI, all the time pbejse's Avatar
    Join Date
    2010-10
    Posts
    535
    Login to Give a bone
    0

    Default Re: Rotate multiple blocks about the insertion point to global fixed point.

    Code:
    (defun c:Test (/ ss i sn gr rp)
      ;; Tharwat 02. Oct. 2012 ;;;
      (if (setq ss (ssget "_:L" '((0 . "INSERT"))))
        (repeat (setq i (sslength ss))
          (setq sn (cons (ssname ss (setq i (1- i))) sn))
        )
      )
      (while (eq (car (setq gr (grread t 15 0))) 5)
        (redraw)
        (foreach b sn
          (entmod
            (subst
              (cons
                50
                (- (angle (setq rp  (cdr (assoc 10 (entget b)))) (cadr gr)) (/ pi 2.))
              )
              (assoc 50 (entget b))
              (entget b)
            )
          )
          (grdraw rp (cadr gr) 1 1)
        )
      )(redraw)
      (princ)
    )

  5. #5
    All AUGI, all the time Tharwat's Avatar
    Join Date
    2010-06
    Posts
    914
    Login to Give a bone
    0

    Default Re: Rotate multiple blocks about the insertion point to global fixed point.

    I completely forgot about grdraw function .

    Thanks pBejse .

  6. #6
    100 Club
    Join Date
    2015-09
    Posts
    154
    Login to Give a bone
    0

    Default Re: Rotate multiple blocks about the insertion point to global fixed point.

    Hi GHarvey,

    Thanks for your help. This works in principle although there appears to be a little problem in that each block rotates what appears to be an extra 90 degrees.....any ideas?

  7. #7
    100 Club
    Join Date
    2015-09
    Posts
    154
    Login to Give a bone
    0

    Default Re: Rotate multiple blocks about the insertion point to global fixed point.

    Hi Tharwat,

    Thanks for your help. I have problem with selecting the target point. I cannot snap to anything or insert coordinates at the command line. It works if I just select a random point on the screen. Any ideas on what I might be doing wrong.

    Thanks for the help guys

  8. #8
    All AUGI, all the time Tharwat's Avatar
    Join Date
    2010-06
    Posts
    914
    Login to Give a bone
    0

    Default Re: Rotate multiple blocks about the insertion point to global fixed point.

    You did not do anything wrong , but I used the grread function for graphic action ,
    but anyway here is another one according to have mentioned in your last post .

    Code:
    (defun c:Test (/ ss p i sn)
      ;; Tharwat 03. Oct. 2012 ;;;
      (if (and (setq ss (ssget "_:L" '((0 . "INSERT")))) (setq p (getpoint "\n Specify target point :")))
        (repeat (setq i (sslength ss))
          (setq sn (ssname ss (setq i (1- i))))
          (entmod (subst (cons 50 (- (angle (cdr (assoc 10 (entget sn))) p) (/ pi 2.)))
                         (assoc 50 (entget sn))
                         (entget sn)
                         )
                  )
          )
        )
      (princ)
      )

  9. #9
    100 Club
    Join Date
    2015-09
    Posts
    154
    Login to Give a bone
    0

    Default Re: Rotate multiple blocks about the insertion point to global fixed point.

    hi,

    that's does exactly what I need, thanks for your help. Much appreciated.

    This thread is now "Solved"!

    thanks Tharwat

  10. #10
    All AUGI, all the time Tharwat's Avatar
    Join Date
    2010-06
    Posts
    914
    Login to Give a bone
    0

    Default Re: Rotate multiple blocks about the insertion point to global fixed point.

    Quote Originally Posted by feargt View Post
    hi,

    that's does exactly what I need, thanks for your help. Much appreciated.

    This thread is now "Solved"!

    thanks Tharwat
    You're welcome anytime .

Page 1 of 3 123 LastLast

Similar Threads

  1. Rotate objects by insertion point
    By spattn in forum VBA/COM Interop
    Replies: 6
    Last Post: 2011-11-05, 05:24 AM
  2. Display cooridinates of a blocks insertion point
    By JH75 in forum Dynamic Blocks - Technical
    Replies: 1
    Last Post: 2009-01-06, 05:06 AM
  3. Pick to Rotate at Insertion point
    By BCrouse in forum AutoLISP
    Replies: 5
    Last Post: 2007-07-13, 09:22 PM
  4. Select blocks by name and insertion point?
    By keelay711 in forum AutoLISP
    Replies: 17
    Last Post: 2006-10-17, 12:03 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
  •