Jump to content

Recommended Posts

Posted

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

 

Here's an AutoDesk lisp for copy rotate.

 

;;;   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) 

  • 4 weeks later...
Posted
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.

 

(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.

  • 1 year later...
Posted

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):

MPF.lsp

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...