for iattr in range(1, nattr+1): dum = 0 ;print ". iattr ->", iattr foo = gem.getAttribute(myModel, "BRANCH", ibranch, iattr) aname = foo[0] ;print ". . aname ->", aname values = foo[1] ;print ". . values ->", values # get information about each of the BReps for myBRep in myBReps: dum = 0 ;print "myBRep ->", myBRep foo = gem.getBRepOwner(myBRep) model = foo[0] ;print ". model ->", model instance = foo[1] ;print ". instance ->", instance branch = foo[2] ;print ". branch ->", branch foo = gem.getMassProps(myBRep, "BREP", 0) volume = foo[ 0] ;print ". volume ->", volume area = foo[ 1] ;print ". area ->", area xcg = foo[ 2] ;print ". xcg ->", xcg ycg = foo[ 3] ;print ". ycg ->", ycg zcg = foo[ 4] ;print ". zcg ->", zcg Ixx = foo[ 5] ;print ". Ixx ->", Ixx Ixy = foo[ 6] ;print ". Ixy ->", Ixy Ixz = foo[ 7] ;print ". Ixz ->", Ixz Iyx = foo[ 8] ;print ". Iyx ->", Iyx Iyy = foo[ 9] ;print ". Iyy ->", Iyy Iyz = foo[10] ;print ". Iyz ->", Iyz Izx = foo[11] ;print ". Izx ->", Izx Izy = foo[12] ;print ". Izy ->", Izy Izz = foo[13] ;print ". Izz ->", Izz
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) # print and plot "final" configuration print "*******************************"