Frame selected object/Geometry not working

On 09/04/2014 at 14:20, xxxxxxxx wrote:

Hi,

For my script purpose i need to frame the first object  that i have merged in my scene before rendering.

this 2 commands c4d.CallCommand(12148) # Frame Geometry c4d.CallCommand(13038) # Frame Selected Elements  do not frame the object in the viewport. It seem over-zoomed on the object...

If i paste one of these command in the console , there it frame wellthe object...

Any idea how to make it works?

for infile in glob.glob(scenesPath+"\*.c4d") :
            fname, ext = os.path.splitext(infile)
            c4d.documents.LoadFile(refPath+'\param.c4d')
            doc = c4d.documents.GetActiveDocument()
            docview=doc.GetActiveBaseDraw()
            
            c4d.documents.MergeDocument(doc,infile,c4d.SCENEFILTER_OBJECTS|c4d.SCENEFILTER_MATERIALS|c4d.SCENEFILTER_DIALOGSALLOWED|c4d.SCENEFILTER_MERGESCENE) 
            mycam=docview.GetSceneCamera(doc)
            mycam.SetFocus(35)
            obj=doc.GetFirstObject()
            doc.SetActiveObject(obj)
            
            obj.Message(c4d.MSG_UPDATE)

c4d.CallCommand(12148) # Frame Geometry
            c4d.CallCommand(13038) # Frame Selected Elements
            macam.SetFocus(25)
            c4d.EventAdd()
            return

...

On 17/04/2014 at 12:33, xxxxxxxx wrote:

It is not clear to me what your problem is. Could you narrow your problem down and provide
a script that can be pasted into the script manager that will demonstrate the problem?

Best,
-Niklas

On 18/04/2014 at 13:06, xxxxxxxx wrote:

i think i've found why it does not works properly. In fact when i load scene and merge with my python script, the viewport is "empty" untill my function finish. So the command "Frame selected object" apply to nothing. I should find a way to force the viewport to refresh and then call this command. I'm searching to make this not a dirty way... i will let you know if i find the solution, excetp if you tell me it before :D

On 21/04/2014 at 09:04, xxxxxxxx wrote:

Simple refresh is c4d.EventAdd()