Need to add delay before running ce.generateModels?

1149
5
Jump to solution
04-10-2017 04:30 PM
RobertYu
New Contributor III

Hello,

I am doing the following all in python:

  1. Associate a rule file with a shape
  2. Generate the model
  3. Create an new rule file
  4. Associate the new rule file with the shape

But when I try to regenerate the model using the new rule file, it seems to fail unless I put a delay in front, as in:

    time.sleep(10)

    shapes = ce.getObjectsFrom(ce.scene, ce.isShape)

    ce.generateModels(shapes)

 

Is there a reason why the delay is needed?  I might be doing something wrong here.

Thanks,

Robert

0 Kudos
1 Solution

Accepted Solutions
RobertYu
New Contributor III

From trial and error, it looks like whenever you associate a .cga with a shape,

one should add a bit of delay to it, as in (function "framewait" defined in earlier post)

ruleFile = "rules/foo.cga"

ce.setAttribute(zone, "/ce/rule/ruleFile", ruleFile)

framewait(2)

View solution in original post

0 Kudos
5 Replies
LR
by
Occasional Contributor III

That's probably because CE is still busy with the first model generation. Try ce.waitForUIIdle().

0 Kudos
RobertYu
New Contributor III

Thanks for the suggestion.  I gave it a try it works a bit better.  I ended up doing a hack, where

I estimate the wait delay based on how many buildings (collada) I need to redraw.

def framewait(delay=0😞

    print "Waiting", delay, "seconds ..."

    time.sleep(delay)

    views = ce.getObjectsFrom(ce.get3DViews())

    views[0].frame()

    ce.waitForUIIdle()

    print "frame finished"

0 Kudos
LR
by
Occasional Contributor III

Have you looked into  @noUIupdate and ce.generateModels ( --> asynchronous)? Those might help as well.

0 Kudos
RobertYu
New Contributor III

I upload the results to arcGIS online, so I do need the model to be complete.  With @noUIUpdate and asynchronous, how can I tell when the models are ready for upload?

0 Kudos
RobertYu
New Contributor III

From trial and error, it looks like whenever you associate a .cga with a shape,

one should add a bit of delay to it, as in (function "framewait" defined in earlier post)

ruleFile = "rules/foo.cga"

ce.setAttribute(zone, "/ce/rule/ruleFile", ruleFile)

framewait(2)

0 Kudos