Jump to content

need help with moving objects- animation


mcclarion

Recommended Posts

there is around 60 layers( if u opened a file ) and i need them to slowly shoving up and turning off so they look like animation ..

 

i ask if someone could do begging of script - i could do the rest ..

 

this is what i came up so far .. but that don't work ..,

 

-LAYER ?

LAYER1

on

LAYER1

 

DELAY 1000

-LAYER ?

LAYER1

off

LAYER1

y

 

DELAY 1000

-LAYER ?

LAYER3

on

LAYER3

 

DELAY 1000

-LAYER ?

LAYER3

off

LAYER3

 

DELAY 1000

-LAYER ?

LAYER5

on

LAYER5

 

DELAY 1000

-LAYER ?

LAYER5

off

LAYER5

 

DELAY 1000

-LAYER ?

LAYER7

on

LAYER7

 

DELAY 1000

-LAYER ?

LAYER7

off

LAYER7

 

RSCRIPT

Edited by mcclarion
  • Thanks 1
Link to comment
Share on other sites

Here, I made this quick example what should be used... Make LWPOLYLINE, LINE, or SPLINE and check it what it does...

 

Hope this helps...

 

(defun c:roll ( / OVAR VAR LOOP A BALL CI D GR GROUND GRSTPT LI P PATH PP PPD PT PTSTDI PTSTPT RAD SSBALL) (vl-load-com)
 (setq ovar (mapcar 'getvar (setq var (list 'cmdecho 'osmode))))
 (mapcar 'setvar var '(0 0))
 (prompt "\nPick ground")
 (while (vl-catch-all-error-p (setq ground (vl-catch-all-apply 'ssname (list (ssget "_+.:E:S:L" (list '(-4 . "<or") '(0 . "LWPOLYLINE") '(0 . "LINE") '(0 . "SPLINE") '(-4 . "or>"))) 0)))))
 (setq grstpt (vlax-curve-getstartpoint ground))
 (setq rad (distance grstpt (setq pt (getpoint grstpt "\nPick radius of rolling ball : "))))
 (vl-cmdf "_.OFFSET" rad ground pt "")
 (setq path (entlast))
 (entupd (cdr (assoc -1 (entmod (subst (cons 67 1) (assoc 67 (entget path)) (entget path))))))
 (setq ptstpt (vlax-curve-getstartpoint path))
 (setq ptstdi (vlax-curve-getdistatpoint path ptstpt))
 (setq ci (entmakex (list '(0 . "CIRCLE") (cons 10 ptstpt) (cons 40 rad))))
 (setq li (entmakex (list '(0 . "LINE") (cons 10 ptstpt) (cons 11 (polar ptstpt (- (angle grstpt ptstpt) (/ pi 2.0)) rad)))))
 (setq ssball (ssadd))
 (ssadd ci ssball)
 (ssadd li ssball)
 (vl-cmdf "-BLOCK" "ball" ptstpt ssball "" "")
 (vl-cmdf "-INSERT" "ball" ptstpt "" "" "")
 (setq ball (entlast))
 (setq loop T)
 (while loop
   (setq gr (grread T))
   (if (= (car gr) 5)
     (progn
     (setq p (cadr gr))
     (setq pp (vlax-curve-getclosestpointto path p))
     (setq ppd (vlax-curve-getdistatpoint path pp))
     (setq d (- ppd ptstdi))
     (setq a (/ d rad))
     (entupd (cdr (assoc -1 (entmod (subst (cons 10 pp) (assoc 10 (entget ball)) (entget ball))))))
     (entupd (cdr (assoc -1 (entmod (subst (cons 50 a) (assoc 50 (entget ball)) (entget ball))))))
     )
   )
   (if (or (= (car gr) 2) (= (car gr) 3)) (progn (setq loop nil) (entdel ball) (entdel path) (vl-cmdf "-PURGE" "B" "ball" "N")))
 )
 (mapcar 'setvar var ovar)
 (princ)
)

 

M.R.

Link to comment
Share on other sites

Here is your layer idea. It is a bit shaky but it moves.

It works only in this new "move.dwg" file (attached).

 

(defun c:bf (/ ln la)
 (command "_.undo" "begin")
 (setq	ln 1
la (itoa (+ 1 ln))
 )
 (while (tblsearch "layer" la)
   (command "delay" 100)
   (command "layer" "Off" la "")
   (setq ln (+ ln 1)
  la (itoa ln)
   )
   (command "layer" "On" la "")
 )
 (command "layer" "on" "31" "")
 (command "_.undo" "end")
 (princ)
)

move.dwg

Link to comment
Share on other sites

I think that you will get better results over an AutoLISP routine to control visibility of layers, if you will create slides (command MSLIDE) for each frame from your animation and create a script using commands VSLIDE to show them and DELAY to control the timing.

Link to comment
Share on other sites

or

(defun c:Roll ( / hide Rolling Delay n )
[b][color=blue](initget 7)[/color][/b]
[b][color=blue](setq delay (getint "\nEnter Delay factor: "))[/color][/b]      
(defun hide (ln mode)
     (setq ss (ssget "_X" (list (cons 8 ln))))
       (repeat (setq i (sslength ss))
                     (redraw (ssname ss (setq i (1- i))) mode)))
(defun Rolling (prcnt)
(repeat prcnt 
 (setq prcnt_1 (1+ prcnt))
 (prompt "\r|")(prompt "\r/")
 (prompt "\r|")(prompt "\r\\")
 (princ)
  )
     )      
(setq n 0)
(hide "ROLL-*" 2)
 (repeat 29
     (setq lnm (strcat "Roll-" (itoa (setq n (1+ n)))))
 (hide lnm 1)
 (rolling [color=blue][b]delay[/b][/color])
 (hide lnm 2)
       )
)

 

See attached drawign file.

(rolling delay) will dictate the delay. the higher the number the slower the animation

 

Have fun

 

EDIT: Add prompt for DELAY Value. Test run for delay approximation

animate.dwg

Edited by pBe
Add prompt
Link to comment
Share on other sites

If you want to explore the slide approach too, in order to don’t have to deal with too much slides you can also join those into a slide library; AutoCAD provide you a small utility named SLIDELIB.EXE for that.

To display a slide from library use:

_VSLIDE C:\MyPresentation\MySlideLib(MySlide1st)

Link to comment
Share on other sites

@pBe: It's been a while since I last saw that temporization / waiting icon solution...

 

Yup, i opted to use that as the "delay" command doesn't work well in this case. I'll leave it to the OP to work out the rest.

 

Cheers MSasu :)

Link to comment
Share on other sites

It will be interesting to check if using REDRAW function to control visibility of items will work better over layer state solution.

Link to comment
Share on other sites

It will be interesting to check if using REDRAW function to control visibility of items will work better over layer state solution.

 

Indeed, One more possibility is using the Visibility parameter of a Dynamic Block. That would be interesting to code :).

Link to comment
Share on other sites

Yup, i opted to use that as the "delay" command doesn't work well in this case. I'll leave it to the OP to work out the rest.

There is a potential issue that the display speed may be affected by other processes that run in parallel – but since this seems to be for a presentation (probably a school project) that should not be the case.

A suggestion that I'd make to OP is to don’t rely for timing setup on the test that he/she will make on his/her workstation and test it on the workstation were the presentation will be made due to differences in performance.

Link to comment
Share on other sites

There is a potential issue that the display speed may be affected by other processes .....test that he/she will make on his/her workstation and test it on the workstation were the presentation will be made due to differences in performance.

 

Exactly! Very well put MSasu. :thumbsup:

Link to comment
Share on other sites

Here, I made this quick example what should be used... Make LWPOLYLINE, LINE, or SPLINE and check it what it does...

 

Hope this helps...

 

(defun c:roll ( ....
(while loop (setq gr (grread T))
(if (= (car gr) 5)
(progn (setq p (cadr gr))
(setq pp (vlax-curve-getclosestpointto path p))
(setq ppd (vlax-curve-getdistatpoint path pp))
......)

 

M.R.

 

Nice Idea MArko :)

Link to comment
Share on other sites

Layer Freeze/Thaw Version [Object as a block]

(defun c:Roll2 ( / _FTLayer Rolling cur n )
(defun Rolling (prcnt)
(repeat prcnt 
 (setq prcnt_1 (1+ prcnt))
 (prompt "\r|")(prompt "\r/")
 (prompt "\r|")(prompt "\r\\")
 (princ)
  )
     )      
(defun _FTLayer (en / dx )
     (setq en (entget en)
             dx (assoc 70 en)
             en (entmod (subst (cons 70 (boole 6 1 (cdr dx))) dx en))) en)
(initget 7)
(setq delay (getint "\nEnter Delay factor: "))          
(setq n 0)
 (repeat 29
     (setq lnm (strcat "Roll-" (itoa (setq n (1+ n))))
           cur  (tblobjname "LAYER" lnm))
 (_FTLayer cur)
 (rolling delay)
 (_FTLayer cur)
       )
     )

 

Also by using a block, a call to (command "_delay" 100) performs better than i expected

 

(defun c:Roll2 ( / _FTLayer cur n )
(defun _FTLayer (en / dx )
     (setq en (entget en)
             dx (assoc 70 en)
             en (entmod (subst (cons 70 (boole 6 1 (cdr dx))) dx en))) en)
(initget 7)
(setq delay (getint "\nEnter Delay factor: "))          
(setq n 0)
 (repeat 29
     (setq lnm (strcat "Roll-" (itoa (setq n (1+ n))))
           cur  (tblobjname "LAYER" lnm))
 (_FTLayer cur)
[b][color=blue] (command "_delay" delay)[/color][/b]
 (_FTLayer cur)
       )
     )

animate2.dwg

Edited by pBe
Link to comment
Share on other sites

This is all grate .. ill mast test it on my machine .. thx for effort :))

bat this is all done in lisp

 

is it possible please for someone to do it in script by turning on / off layers ?

Link to comment
Share on other sites

The required script will look like this (version for 3 frames):

_LAYER _S 0

_LAYER _OFF Layer1 _OFF Layer3 _OFF Layer5

_LAYER _ON Layer1

_DELAY 300
_LAYER _OFF Layer1 _ON Layer3

_DELAY 300
_LAYER _OFF Layer3 _ON Layer5

_DELAY 300
;end of script

May use Excel to create script's lines, due to the big number of frames. Please don't ignore the empty lines - those are required to end the LAYER command.

 

You may also want to consider my previous suggestion to use slides instead of layers.

Link to comment
Share on other sites

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