Little help for a scripting newb please

SerumSerum Posts: 256

i have an idea i want to achieve and i wonder if you can help me.

its relatively simple 

i would like a script that adds a camera to a scene pointing in the same direction as the active view, names it a specific name and sets a specific focal length. from there i would be able to workout everything else i need it to do 

any help is appreciated thanks :) 

Problem now solved thread can be closed

Post edited by Serum on

Comments

  • Richard HaseltineRichard Haseltine Posts: 100,871

    The Create>New Camera already lets you copy the active view - what more are you wishing?

  • SerumSerum Posts: 256

    to have the cameras set up how i want them almost as if they are presets for various camera settings i go to regulary . 
    the existing camera  preset system does not work for how i want to do it as it gets rid of any other cameras in the scene so its a bit of a cross between the 2 so it needs to be a script.

  • Richard HaseltineRichard Haseltine Posts: 100,871

    Well, you can hold down the ctrl/cmd key while double-clickign a preset to choose to keep the current camera(s) and add those from the preset.

    I have a couple of older (DS3) scripts relating to cameras that may help with getting the current camera, after that it's mostly crteating the new camera in the same place and then applying the settings tyou desire. The code for getting the current camera looked like this:

    // Select current view// (c) Richard Haseltine, November 2009// Select camera or light currently being used to view the scenevar viewMgr = MainWindow.getViewportMgr();var activeView = viewMgr.getActiveViewport();if ( activeView ) {	var viewport3d = activeView.get3DViewport();	if ( viewport3d ) {		var curCam = viewport3d.getCamera();		// Now do stuff with the camera	}}

     

  • SerumSerum Posts: 256

    thanks ill give it a try

  • SerumSerum Posts: 256

    i dont know if it was supposed to do something when executed but it says it ran okay but it didnt create a new camera or do anything that i saw. 

    what i need is the script equivilent of create new camera using active view so that new camera shows up in the scene pane, Name that camera what ever name then   set the focal length of that camera to 50mm.

    As soon as it does that when i hit execute and that is working  then i can see the format of the code and modify it for the rest of things i want to set. 

    i can then go through each parameter setting it how i like it and it will be a case of run the script and it adds my camera to the scene

  • SerumSerum Posts: 256

    Cancel that i have found another way around it I appreciate you trying to help. thank you 

  • Richard HaseltineRichard Haseltine Posts: 100,871

    It was showing how to get the current camera/view, so that you have a source for the position to apply to your new camera.

Sign In or Register to comment.