how do we read/set the resolution level via script ?

PadonePadone Posts: 3,688

This is to help the diffeomorphic plugin.

I tried to look at the api reference in the documenation center but it seems it's mostly incomplete plus my programming days are far away now. We need to change the resoluition level of the objects in the scene before exporting, so to export the base mesh, then restore the resolution level after exporting. Any help please ?

reso.jpg
397 x 301 - 42K
Post edited by Padone on

Comments

  • There's a sample script that gets you almost all the way there:

    http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/properties/node_properties/start

    Then it's just a case of finding the property in the Mesh Resolution property group that corresponds to the Resolution Level instead of the property the sample is dealing with, and setting the value of the enum as required.

  • PadonePadone Posts: 3,688

    @andya Thank you very much for your reply. I already have the exporter source so I don't need a general example I do know how to export things. It's just the resolution level that I need to find out if anyone can help.

  • The sample script doesn't show anything about exporting.  It shows how to find the Mesh Resolution property group, and the Resolution Level property - which is what you said you wanted to change - is part of that property group.  You can then set the value of that property to "Base" or "High Resolution" as required.

  • PadonePadone Posts: 3,688
    edited April 2020

    @andya Again thank you for your help I do appreciate it. Anyway the script finds out what I already know from the parameter settings dialog. If I understand correctly from this example I have to use the setitems() method in the DzEnumProperty object to set the lodlevel property. Unfortunately the setitems() method is not documented so I have no idea how to use it.

    Is there any other way or can you help with it please ?

    http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/enumproperty_dz

    lodlevel.jpg
    523 x 381 - 56K
    Post edited by Padone on
  • Richard HaseltineRichard Haseltine Posts: 100,888

    setItems is for creating the list of values, I am told - hence its taking an array which will hold the values, in the order in which they are to appear. The next entry, setValueFromString( string ), will do what you want (matching the string to one of the items in  the list of values and setting that item's index as the value). Snce DzEnumProperty inherits from DzIntProperty (see the top of the page in the documentation) you can also just use setValue( number ) to set the value directly, as a number.

  • PraxisPraxis Posts: 254

    These work for me (error-checking code has been omitted for clarity):

    function getResolutionLevel( oNode ) {  if( oNode.className() == 'DzBone' ) {    oNode = oNode.getSkeleton();  }  return oNode.getObject().getCurrentShape().getLODControl().getValue();  // 0 == Base Resolution, 1 == High Resolution};function setResolutionLevel( oNode, nLevel ) {  if( oNode.className() == 'DzBone' ) {    oNode = oNode.getSkeleton();  }  oNode.getObject().getCurrentShape().getLODControl().setValue( nLevel );  // 0 == Base Resolution, 1 == High Resolution};

     

  • PadonePadone Posts: 3,688
    edited April 2020

    Thank you @andya @Richard and @Praxis it seems clear now. I'll pass the information to Thomas for the diffeomorphic plugin. Thank you again very much.

     

    EDIT. Here's the link to the diffeomorphic discussion for anyone interested.

    https://bitbucket.org/Diffeomorphic/import-daz/issues/30/major-subdivision-bug

    Post edited by Padone on
Sign In or Register to comment.