Jump to content

Recommended Posts

Posted

I have hundreds of items to move. They will all be at different angles and distances. Without a macro, I will get lost as all these items look the same and will probably move the right distance but the wrong object. I will also move the right object but the wrong distance:(:?

 

I started a macro. It explains it better of what I am after

 

Please help

 

;
;   prompt for input
;
(setq dist(getdist"\nEnter the distance to move: "))
(setq angl(getreal"\nEnter the angle: "))
(setq obj(getreal"\npick the object you want moved: "))
;
;
;



(setq xvalue(     (cos angl)*dist    )
(setq yvalue(     (sin angl)*dist    )

;


(COMMAND "move"  obj 0,0 @xvalue,yvalue "")

MOVE MACRO.dwg

Posted

rookie37,

Based on your idea, here's one with a little "color"

 

; mvm.lsp - move selected objects to a specified distance at an angle
;           and color them green

(defun dtr (a) ;Degrees to radians conversion
(* pi (/ a 180.0))
)

(defun c:mvm (/ dis angl objset n en el bse vec)
(setq dis (getdist"\n Enter the distance to move: "))
(setq angl (getreal"\n Enter the angle: "))
(princ "\n Pick the object(s) you want moved: ")
(setq objset (ssget))
(setq n (- (sslength objset) 1))
(while (> n -1) ; make the moved objects green
(setq en (ssname objset n))
(setq el (entget en))
(setq el (subst (cons 62 3) (assoc 62 el) el))
(entmod el)
(setq n (- n 1)) 
)
(setq angl (dtr angl))
(setq bse (list 0 0 0)) ; set the base 0,0,0
(setq vec (polar bse angl dis)) ; obtain vector
(command "_.move" objset "" bse vec)
(princ)
)

Posted

Another approach :)

 

(defun c:mvm ( / _toColour ) (vl-load-com)

 (defun _toColour ( entity colour )
   (entmod
     (if (assoc 62 (entget entity))
       (subst (cons 62 colour) (assoc 62 (entget entity)))
       (append (entget entity) (list (cons 62 colour)))
     )
   )
 )

 (mapcar
   (function
     (lambda ( fun string symbol default )
       (set symbol
         (cond
           (
             (
               (eval fun)
               (strcat string " <"
                 (rtos
                   (set symbol
                     (cond ( (eval symbol) ) ( default ))
                   )
                 )
                 "> : "
               )
             )
           )
           ( (eval symbol) )
         )
       )
     )
   )
   '(getdist getangle)
   '("\nEnter Distance " "\nEnter Angle ") '(*dis* *ang*) '(1.0 0.0)
 )

 (
   (lambda ( SelSet i / base disp )      
     (setq base (vlax-3D-point '(0. 0. 0.))
           disp (vlax-3D-point (polar '(0. 0. 0.) *ang* *dis*)))
     
     (if SelSet
       (while (setq entity (ssname SelSet (setq i (1+ i))))
         (_toColour entity 30)

         (vla-move (vlax-ename->vla-object entity) base disp)
       )
     )
   )
   (ssget) -1
 )

 (princ)
)

 

Posted

That saves me so much work that it was almost undo-able without it. Thank you!

 

I thought of a modification for it. To explain it I will tell you what I'm using it for.

 

I'm making an animated movie with autocad. For 1 second of movie I make 24 drawings. There is a much easier way to do this than the way I'm doing it.(Inventor, 3DsMax, and perhaps autocad can already do this but I don't know how) I'm still investigating the other ways but meanwhile, I'm doing it this way.

 

If I want an object to move 30 mm in one second of movie, I input the distance for frame 1 as 1.25mm. I then input the distance as 2.5mm on frame 2. I keep doing this until frame 24

 

I would like a second macro that will prompt me for total distance and then for number of frames required to reach this distance. The reason for the separate macro is so that it doesn't run all the time. However if you can combine it with this one without it running unless I ask for it, so much the better

 

setq totledist  ;; 30 in this case
setq framesrequird ;;24 in this case


Then on your macro above, instead of

 

(setq dis (getdist"\n Enter the distance to move: "))

 

put instead

 

(setq frameno (getdist1"\n what frame number is this? ")) 
(setq dis = frameno*(totaldist/framesrequird)

Unfortunately the angle will still be different on every frame

 

Whether or you make the changes above or not, I am still very grateful for your help. The macro as it is is still a big time saver. (and perhaps sanity saver):?:lol:

Posted

You may be better with other software for a movie I remember years ago playing with Autodesk something and it had morphing built in just pick your object move it to some where else change its shape and the software would add all the in between steps automatically. Change a square to a circle etc

Posted

Fun twist on Lee's submission...cheesy.gifcheesy.gif

 

(defun c:MVM (/)
 (vl-load-com)
 ((lambda (i ss bp pt _toColor / e)
    (if ss
      (while (setq e (ssname ss (setq i (1+ i))))
        (_toColor (entget e) 3)
        (vla-move (vlax-ename->vla-object e) bp pt)
      )
    )
  )
   -1
   (ssget "_:L")
   (vlax-3d-point '(0. 0. 0.))
   (vlax-3d-point
     (apply (function polar)
            (cons '(0. 0. 0.)
                  (reverse (mapcar
                             (function
                               (lambda (fun string symbol default)
                                 (set symbol
                                      (cond
                                        (((eval fun)
                                           (strcat string
                                                   "<"
                                                   (rtos
                                                     ((lambda (val)
                                                        (if (eq fun 'getangle)
                                                          (* 180. (/ val pi))
                                                          val
                                                        )
                                                      )
                                                       (set symbol
                                                            (cond ((eval symbol))
                                                                  (default)
                                                            )
                                                       )
                                                     )
                                                   )
                                                   "> : "
                                           )
                                         )
                                        )
                                        ((eval symbol))
                                      )
                                 )
                               )
                             )
                             '(getdist getangle)
                             '("\nEnter Distance " "\nEnter Angle ")
                             '(*dis* *ang*)
                             '(1.0 0.0)
                           )
                  )
            )
     )
   )
   (lambda (eLst clr)
     (entmod (if (assoc 62 eLst)
               (subst (cons 62 clr) (assoc 62 eLst) eLst)
               (append eLst (list (cons 62 clr)))
             )
     )
   )
 )
 (princ)
)

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