gem.setAttribute(myBReps[0], "BREP", 0, "s_attr", "brep attribute") gem.setAttribute(myBReps[0], "BREP", 0, "i_attrs", (0, 1, 2, 3, 4, 5)) gem.setAttribute(myBReps[0], "BREP", 0, "r_attrs", (0., 0.1, 0.2, 0.3, 0.4, 0.5)) # get information about each of the Attributes for iattr in range(1, nattr+1): dum = 0 ;print "iattr ->", iattr foo = gem.getAttribute(myModel, "MODEL", 0, iattr) aname = foo[0] ;print ". aname ->", aname values = foo[1] ;print ". values ->", values # get information about each of the Parameters for iparam in range(1, nparam+1): dum = 0 ;print "iparam ->", iparam foo = gem.getParam(myModel, iparam) pname = foo[0] ;print ". pname ->", pname bflag = foo[1] ;print ". bflag ->", bflag order = foo[2] ;print ". order ->", order values = foo[3] ;print ". values ->", values nattr = foo[4] for iattr in range(1, nattr+1): dum = 0 ;print ". iattr ->", iattr foo = gem.getAttribute(myModel, "PARAM", iparam, iattr) aname = foo[0] ;print ". . aname ->", aname values = foo[1] ;print ". . values ->", values # get information about each of the Branches for ibranch in range(1, nbranch+1): dum = 0 ;print "ibranch ->", ibranch
print "plotting initial configuration..." myDRep = gem.newDRep(myModel) gem.tesselDRep(myDRep, 0, 0, 0, 0) gem.plotDRep(myDRep); gem.destroyDRep(myDRep) # "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