Jump to content

Perhaps a monumental task...Animating from AutoLISP using Render.


Recommended Posts

Posted

After posting this thread and investigating in a few other forums, it seems like learning to animate in 3DS Max could take an eternity, so here's my new plan of attack...

 

I've captured every single command sent from the external program I use and figured out how to use it in the command line. I can easily write an AutoLISP script that contains all the commands to move the piece of machinery through every motion. All I really need to do is insert a command between each movement to render an image, preferably from a camera I have specified.

 

So, that's my next step; learning to use the Render command in every way possible, preferably from an existing camera. Is it reasonable to try and use the render command via AutoLISP to render and save images?

 

I know this whole process will be insanely processor intensive, but I have that under control.

  • Replies 31
  • Created
  • Last Reply

Top Posters In This Topic

  • jjatho

    15

  • David Bethel

    6

  • tzframpton

    2

  • MSasu

    2

Posted
....it seems like learning to animate in 3DS Max could take an eternity....
Why would you think that? Lots of people animate things with 3DSMax all day long with no troubles. There's a big community out there. I would imagine as much effort as you've put into this AutoLISP script would be the same amount to learn and execute how to animate using 3DSMax (or another program that's probably simpler).
Posted

Yes, you can automate the render processing using AutoLISP; here you have an example:

(command "_VIEW" "_R" "view1st"
        "_REGEN"
        "_RENDER" "_M" "_R" 640 480 "_Y" "C:\\test1st.bmp")
(command "_VIEW" "_R" "view2nd"
        "_REGEN"
        "_RENDER" "_M" "_R" 640 480 "_Y" "C:\\test2nd.bmp")
(command "_VIEW" "_R" "view3rd"
        "_REGEN"
        "_RENDER" "_M" "_R" 640 480 "_Y" "C:\\test3rd.bmp")

 

The script alternative would also work:

_VIEW _R view1st
_REGEN
_RENDER _M _R 640 480 _Y C:\\test1st.bmp
_VIEW _R view2nd
_REGEN
_RENDER _M _R 640 480 _Y C:\\test2nd.bmp
_VIEW _R view3rd
_REGEN
_RENDER _M _R 640 480 _Y C:\\test3rd.bmp
;end of file

The script approach had the advantage that you can use Excel (or other worksheet tool) to generate it if you have a big amount of scenes.

 

But, as @StykFacE mentioned above, there are better tools for rendering than AutoCAD, so on long term may be rewarding to go with one of those. For sure this depends of your (or your employer) resources and what kind of images you need to create.

Posted
But, as @StykFacE mentioned above, there are better tools for rendering than AutoCAD, so on long term may be rewarding to go with one of those.
I was meaning animation only. AutoCAD does rendering just fine (at least for me). :)
Posted

Msasu, that is exactly what I need! Follow up question; would you mind explaining what each component of the command does? Obviously I can figure out the resolution and file location, but I'm not sure what the other portions do. If there's an online reference you could point me to that would be great as well. Thanks!

Posted

Just call the prompt only version of the command, like -RENDER to see the options you can use. Not sure if you will have access this way to all settings.

Posted

It appears the (C:SAVEIMG ....) command has either been abandoned or replaced. With it the process of animating AutroCAD was very simple. You could using any shademode that you desired on a walkthur or on movement scenes and then save the image as it was displayed on your screen. I will have to do some research as I use this extensively in AutoLISP animations. -David

 

Some samples:

 

http://www.youtube.com/user/DDBethel?feature=mhee

Posted

David, those samples are pretty much exactly what I'm trying to do, except with a fixed camera and a piece of machinery in the scene moving. The external program I use to control heavy machinery does so via AutoLISP commands, so it would be trivial to write my own LISP script for all the movements and interject commands to save the images between each.

Posted

Here is the code:

 

(defun c:revo (/ u2 u3 ss cp an)
 (setq	oecho (getvar "cmdecho")
osn   (getvar "osmode")
ohl   (getvar "highlight")
 )
 (setvar "cmdecho" 0)
 (setq ss (ssget "_X" '((0 . "insert")(2 . "body"))))
 (setvar "highlight" 0)
 (setq cp (list 7.577 7.239 2.105)
u2 (getint "\n Adjust speed <1-10>: "))
 (if (= u2 nil)(setq u2 2))

 
   (setq u3 u2
  an (getreal "\n Number of revolutions?: ")
   )
 (if (= an nil)(setq an 720)(setq an (* an 360)))
   (while (<= u2 (+ (/ u3 2) an))
     (command "rotate" ss "" cp u3)
     (setq u2 (+ u2 u3))
   )
 (setvar "cmdecho" oecho)
 (setvar "highlight" ohl)
 (princ)
)

Posted

MSasu, I played around with the -RENDER command and found the following. I'm documenting everything here for anyone who may come across this thread in the future.

 

Selecting "Presentation" for the render preset, then Viewport for the render destination gives no further options and then renders the image right there in the viewport. There doesn't seem to be anything to do after that, and the viewport reverts back to its previous settings once you pan, zoom, or otherwise move around the scene. Being able to save the image there in the viewport via LISP would actually be pretty ideal.

 

Selecting, render preset "Presentation", render destination "Render Window", output width "1280" output height "720", save rendering "Yes", and filename and path as "C:\Test.png" Opens the rendering window like normal, renders the file, and then saves it to the disk. I've noticed two things about this. First of all, MSasu you included an extra \ which causes saving the file to fail. The file will actually show up, but it will be a zero filesize and have nothing in it. Secondly, .bmp renders a black background while .png renders white.

 

All other rendering settings like shadows and sunlight settings seem to just be whatever you already had AutoCAD setup for.

 

The last hurdle I'm facing is dealing with the render window. Once the -RENDER command has run its course and saved the file, the render window is still open and the previous file is still listed. What I really need now is a way to clear the file list and close the render so that the LISP script can run the next step.

Posted

Maybe look into configuring and plotting to a .png plotter.

 

Try using :

(setvar "FILEDIA" 0)
(setvar "CMDDIA" 0)
(command "-PLOT"   ....)

 

 

It will be a lot of trail and error...... -David

Posted

Tertiary question: does rendering in AutoCAD use the graphics card at all or is it strictly processor?

Posted

It looks as if the -render command uses the card whereas the -plot command does not. -David

Posted

Ok, using the "-PLOT" command with a .png plotter doesn't seem to be working out the way I'd like, and I've gone through A LOT of trial and error with it.

 

Using -RENDER seems to be perfect, but I need to find a way to suppress the render window. Can this be done?

Posted

Using -RENDER seems to be perfect, but I need to find a way to suppress the render window. Can this be done?

 

Not sure if the Command's window can be suppressed though:

 

(command "._-render" "medium" "render" "640" "480" "yes" "[b][color=red]<YourFilePath>[/color][/b]\\[color=blue][b]<YourFileName>[/b][/color].png")

Posted

using the ._-RENDER doesn't seem to keep the render window from appearing.

Posted

Ok, after some more experimentation last night, it seems that it isn't necessary at all to suppress the render window. I wrote a simple test script that just contains:

 

(command "-render" "p" "r" "1280" "720" "yes" "C:\\LISPtest01.png")

(command "-render" "p" "r" "1280" "720" "yes" "C:\\LISPtest02.png")

(command "-render" "p" "r" "1280" "720" "yes" "C:\\LISPtest03.png")

 

And so on up to LISPtest99.png. I ran it before going to bed and woke up to a computer with 99 png images on it. Seems to work just fine that way.

 

My current question is something that is probably stupidly simple. If I run this in a loop, can I change the name of the destination file using a variable? Something like this:

 

(setq counter 1)   

(While (< counter 360)

;rotate machinery 1 degree

(command "-render" "p" "r" "1280" "720" "yes" "C:\\RotateMachine(counter).png")

(setq counter(+ counter 1))

)

 

What's the correct syntax for inserting the current counter number into the filename?

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