+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Forum Newbie
    Using
    AutoCAD 2007
    Join Date
    Nov 2007
    Location
    New York
    Posts
    9

    Default AUTOLISP Insert block, and rotate

    Registered forum members do not see this ad.

    I am trying to find or build a LISP that will insert a block @ +20' Z coord. locate it with the insertion point of the block, and then rotate it from the center of the block.

    If that dosn;t make scence what I am trying to do is insert an elevation marker on a pipe then rotate it to allign with it.


    THANKS


    I found this but I am not good at editing LISP

    Quote Originally Posted by Alan Cullen View Post
    Here's an AutoDesk lisp for copy rotate.

    Code:
    ;;;   Mcr.Lsp
    ;;;   Copyright (C) 1990 by Autodesk Australia Pty. Ltd.
    ;;;  
    ;;;   Permission to use, copy, modify, and distribute this software and its
    ;;;   documentation for any purpose and without fee is hereby granted.  
    ;;;
    ;;;   THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. 
    ;;;   ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF 
    ;;;   MERCHANTABILITY ARE HEREBY DISCLAIMED.
    ;;; 
    ;;;-------------------------------------------------------------------------
    ;;; DESCRIPTION:
    ;;;
    ;;;   Mcr.Lsp provides two new commands, MoveRot and CopyRot.
    ;;;   MoveRot, MOVEs and ROTATEs selected entities whilst
    ;;;   CopyRot, COPYies and ROTATEs selected entities.
    ;;;
    ;;;   Written by  Sam Crupi, Autodesk Australia Pty. Ltd.
    ;;;               October 1987
    ;;;   Modified by Jeff De Silva & Sam Crupi, Autodesk Australia Pty. Ltd.
    ;;;               November 1990
    ;;;
    ;;;   Version 1.0
    ;;;   4 December 1990
    ;;;
    ;;;-------------------------------------------------------------------------
    ;;;
    ;;; Error function
    ;;;
    (defun mcr_err (s)                   ; If an error (such as CTRL-C) occurs
                                         ; while this command is active...
      (if (/= s "Function cancelled") 
        (if (= s "quit / exit abort") 
          (princ) 
          (princ (strcat "\nError: " s))
        )
      ) 
      (if mcr_oer                        ; If an old error routine exists
        (setq *error* mcr_oer)           ; then, reset it 
      ) 
      (if mcr_oce                        ; Reset command echoing on error
        (setvar "cmdecho" mcr_oce)
      ) 
      (princ)
    ) 
    ;;;
    ;;; Command MoveRot
    ;;;
    (defun c:MoveRot (/ sset mcr_oce mcr_oer) 
      (setq mcr_oce (getvar "cmdecho"))  ; save cmdecho setting
      (setvar "cmdecho" 0)               ; turn cmdecho off
      (if *error*                        ; Set our new error handler
        (setq mcr_oer *error* 
              *error* mcr_err)
        (setq *error* mcr_err)
      ) 
      (princ (strcat "\nMoveRot, Version " mcr_ver 
                     ", (C) 1990 by Autodesk Australia Pty. Ltd. "
             )
      ) 
      (if (setq sset (ssget))            ; get selection set
        (progn
          (setvar "cmdecho" 1)           ; turn cmdecho on to allow MOVE
                                         ; prompts to appear
          (command "MOVE" sset "" pause pause) ; MOVE them
          ;; now ROTATE the selection set using the LASTPOINT as Base point
          (command "ROTATE" sset "" (getvar "LASTPOINT") pause) 
        )
      )
      (setvar "cmdecho" mcr_oce)         ; reset cmdecho to old setting
      (if mcr_oer                        ; If an old error routine exists
         (setq *error* mcr_oer)          ; then set it back
      ) 
      (princ)
    ) 
    ;;;
    ;;; Command CopyRot
    ;;;
    (defun c:CopyRot (/ mcr_oce mcr_oer sset) 
      (setq mcr_oce (getvar "cmdecho"))  ; save cmdecho setting
      (setvar "cmdecho" 0)               ; turn cmdecho off
      (if *error*                        ; Set our new error handler
        (setq mcr_oer *error* 
              *error* mcr_err)
        (setq *error* mcr_err)
      ) 
      (princ (strcat "\nCopyRot, Version " mcr_ver 
                     ", (C) 1990 by Autodesk Australia Pty. Ltd. "
             )
      ) 
      (if (setq sset (ssget))            ; get selection set
        (progn
          (command "COPY" sset "" "0,0" "0,0") ; COPY selection set over itself
          (setvar "cmdecho" 1)           ; turn cmdecho on to allow MOVE
                                         ; prompts to appear
          (command "MOVE" "p" "" pause pause) 
          (redraw)                       ; Redraw screen
          ;; now ROTATE the selection set using the LASTPOINT as Base point
          (command "ROTATE" "p" "" (getvar "LASTPOINT") pause)
        )
      )
      (setvar "cmdecho" mcr_oce)         ; reset cmdecho to old setting
      (if mcr_oer                        ; If an old error routine exists
         (setq *error* mcr_oer)          ; then set it back
      ) 
      (princ)
    ) 
    ;;;
    ;;; Define the c: functions.
    ;;;
    (defun c:MR () 
      (c:MoveRot)
    ) 
    (defun c:CR () 
      (c:CopyRot)
    ) 
    (setq mcr_ver "1.0")                 ; set version number string
    ;;(princ (strcat "\nC:MCR (v" mcr_ver ") loaded.")) 
    ;;(princ "\nMR or MoveRot to Move and Rotate, CR or CopyRot to Copy and Rotate.") 
    (princ)

  2. #2
    Forum Newbie
    Using
    Architectural DT 2007
    Join Date
    Dec 2007
    Posts
    6

    Default

    Quote Originally Posted by 420325 View Post
    I am trying to find or build a LISP that will insert a block @ +20' Z coord. locate it with the insertion point of the block, and then rotate it from the center of the block.

    If that dosn;t make scence what I am trying to do is insert an elevation marker on a pipe then rotate it to allign with it.


    THANKS


    I found this but I am not good at editing LISP
    Why dont you try sothing like this.

    Code:
    (defun c:spinblk (/ doc ss ll ur midpt)
      (vl-load-com)
      (if (and (ssget '((0 . "INSERT")))
        (setq doc (vla-get-activedocument
             (vlax-get-acad-object)
           )
        )
        (setq ss (vla-get-activeselectionset doc))
          )
        (progn
          (vlax-for ent ss
     (vla-getboundingbox ent 'll 'ur)
     (setq ll    (vlax-safearray->list ll)
           ur    (vlax-safearray->list ur)
           midpt (mapcar '/
           (mapcar '+
            ll
            ur
           )
           '(2.0 2.0 2.0)
          )
     )
     (vlax-invoke ent 'rotate midpt pi)
          )
        )
      )
      (princ)
    )
    or you can make a lisp that allows you to insert a block and then using macros tell the block to do a task.

  3. #3
    Junior Member
    Using
    AutoCAD 2007
    Join Date
    Feb 2009
    Posts
    12

    Default Looking For Lisp Or Help With Another Lisp (move, Rotate Along Axis)

    Registered forum members do not see this ad.

    I have a lisp that move an object 2D and 3D. I want to add on to it or file another file where it will move and rotate alone the same axis. Let's say I have a pipe with tee pointing up and I need to connect to it. That line might be say in the horizontal. The fittings I am adding are a unknown distance and unknown angle. I am looking for a lisp file that will move and rotate the elbow are tee and keep it inline just by selecting the tee that need to connect to. This has to a 3D lisp.

    This is the file that I found and would like to modify (if possible):
    Attached Files

Similar Threads

  1. how to delete a block from the Insert block list
    By Brantis in forum AutoCAD Drawing Management & Output
    Replies: 6
    Last Post: 26th Jul 2012, 09:16 am
  2. Rotate attibutes without affecting associated block
    By hyposmurf in forum AutoCAD General
    Replies: 2
    Last Post: 6th Nov 2007, 09:34 pm
  3. Block rotate
    By johnengineer in forum AutoCAD General
    Replies: 2
    Last Post: 25th Apr 2007, 09:07 pm
  4. Rotate Attributes of Block to Zero Globally
    By ORgrown in forum AutoCAD General
    Replies: 4
    Last Post: 14th Dec 2006, 10:36 am
  5. Rotate a Block and Have Base Point Dynamically change
    By Jedidia in forum AutoCAD General
    Replies: 3
    Last Post: 7th Mar 2005, 10:08 pm

Bookmarks

Posting Permissions

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