Jump to content
3DCoat Forums

Resampling a Surface object to a specific polycount? Can't calculate ratio


kritskiy
 Share

Recommended Posts

  • Member

I think my issue comes from the fact that the value in the tree (that's also output by .getPolycount() is not the same as the initial value in the Resample dialog:

image.thumb.png.4b3e77aabdacc19679e59e1309978b85.png

 

So when I run this I'm getting a wrong result.

active_element = coat.Scene.current()
vol = active_element.Volume()
active_polycount = vol.getPolycount()
   
target_polycount = 50000

resample_scale = math.sqrt(target_polycount / active_polycount)

# prints out current polycount: 176; resample_scale: 16.85499656158105, the resulting polycount is at 12k
print(f"current polycount: {active_polycount}; resample_scale: {resample_scale}")

def ui_command():
    coat.ui.setSliderValue("$ResampleParams::ResamplingScale", resample_scale)
    coat.ui.setEditBoxValue("$ResampleParams::RequiredPolycount", target_polycount) # this seems to be completely ignored
    coat.ui.cmd("$DialogButton#1")

coat.ui.cmd("$Resample", ui_command)

 

If I manually put 41 as active_polycount, the resampling is correct. So my question is, how do I get this "initial polycount" value, 41 ?

Or maybe how can I use $ResampleParams::RequiredPolycount instead of ResamplingScale ? Putting any value in it doesn't seem to change anything

CC @Andrew Shpagin

Edited by kritskiy
Link to comment
Share on other sites

  • Member

Oh, this works. But this seems... weird and wrong?

def ui_command():
    initial_polygon = int(coat.ui.getEditBoxValue('$ResampleParams::RequiredPolycount'))        
    resample_scale = math.sqrt(target_polycount / initial_polygon)
      
    coat.ui.setSliderValue("$ResampleParams::ResamplingScale", resample_scale)
    coat.ui.cmd("$DialogButton#1")

coat.ui.cmd("$Resample", ui_command)

 

Link to comment
Share on other sites

As I remember that issue was solved on version 27

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...