# plot the DRep print "plotting myDRep..." gem.plotDRep(myDRep); # destroy the DRep print "destroying myDRep" gem.destroyDRep(myDRep) # create a static model and add myBrep into it twice newModel = gem.staticModel(myContext) ;print "newModel ->", newModel print "adding myBRep to newModel twice" gem.add2Model(newModel, myBRep) gem.add2Model(newModel, myBRep, (0.5, 0, 0, 2, 0, 0.5, 0, 0, 0, 0, 0.5, 0)) foo = gem.getModel(newModel) server = foo[0] ;print "server ->", server filename = foo[1] ;print "filename ->", filename modeler = foo[2] ;print "modeler ->", modeler uptodate = foo[3] ;print "uptodate ->", uptodate myBReps = foo[4] ;print "myBReps ->", myBReps nparam = foo[5] ;print "nparam ->", nparam nbranch = foo[6] ;print "nbranch ->", nbranch nattr = foo[7] for iattr in range(1, nattr+1): dum = 0 ;print "iattr ->", iattr foo = gem.getAttribute(newModel, "MODEL", 0, iattr) aname = foo[0] ;print ". aname ->", aname values = foo[1] ;print ". values ->", values
# "optimization" loop to vary "ymax" to drive the "volume" to a specified value volume_target = 15 dvoldymax = 8 for iter in range(100): print "---------------------" print "iter =", iter # get current design variable foo = gem.getParam(myModel, 4) ymax = foo[3][0] print "ymax =", ymax # get the objective function foo = gem.getModel(myModel) myBRep = foo[4][0] foo = gem.getMassProps(myBRep, "BREP", 0) volume = foo[0] print "volume=", volume # if we have converged, stop the iterations if (abs(volume-volume_target) < 0.001): break # change the box height and regenerate the model ymax = ymax + (volume_target - volume) / dvoldymax print "ymax =", ymax gem.setParam(myModel, 4, (ymax,)) gem.regenModel(myModel)