Member celer Posted July 2, 2023 Member Share Posted July 2, 2023 (edited) So I'm expecting to generate a mold for casting, I'm getting closer to getting what I want which should look like this: But I'm having some challenges, when try to do an extrusion for the seam: def extrude(target=coat.SceneElement,amount=int): coat.Scene.sculptRoot().unselectAll() target.select() print("Extruding "+target.name()+" by "+str(amount)) def setExtrusion(): coat.ui.setSliderValue("$ExtrudeParams::Extrusion",amount) coat.ui.cmd("$DialogButton#1") coat.ui.cmd("$ExtrudeVO",setExtrusion) coat.ui.wait("$ExtrudeVO",30) And then do an intersection (is the coat.ui.wait(...) even needed, I have no idea. def intSeam(target=coat.SceneElement,width=int): bbox=target.Volume().calcWorldSpaceAABB() center=bbox.GetCenter() size=bbox.GetSize() size.x=width # Shift this up by the seam size amount center.z=center.z-15 print("Intersecting seam "+target.name()+" "+str(width)) sbox=coat.box(center,size) sbox.intersect(target.Volume()) like so: mold_seam=pmold.duplicate() mold_seam.rename("mold_seam") extrude(mold_seam,15) # This fails sometimes intSeam(mold_seam,10) It just doesn't do the intersection sometimes, sometimes running the script 10 times, 9/10 times it will fail, and won't perform the intersection, sometimes restarting 3D Coat will cause it to work Sometimes it works and I can't get it to fail, it's very inconsistent. I either don't understand something, or there is a bug. I'm so excited about python scripting 3D Coat but it's a bit buggy. Previously I was getting very weird results with extrusions, which I posted about in another forum thread, but a restart seems to have fixed that. I either think there is a race condition or a cache invalidation problem - it feels like a bit of both, restarting it fixes is, so seems like a cache validation problem, but then also it feels like a bit of a race condition - is the extrusion finishing before the intersection is complete? negative_mold_test.3b head_mold.py Edited July 2, 2023 by celer to clarify how it fails Quote Link to comment Share on other sites More sharing options...
Dmitriy Nos Posted July 2, 2023 Share Posted July 2, 2023 4 hours ago, celer said: 9/10 times it will fail Did you submit a crash report via the feedback form? Quote Link to comment Share on other sites More sharing options...
Advanced Member Elemeno Posted July 2, 2023 Advanced Member Share Posted July 2, 2023 cant you just use a split command?? Quote Link to comment Share on other sites More sharing options...
Member celer Posted July 2, 2023 Author Member Share Posted July 2, 2023 17 hours ago, Oleg_Shapo said: Did you submit a crash report via the feedback form? I can, it doesn't crash it just fails to perform the intersection. Quote Link to comment Share on other sites More sharing options...
Member celer Posted July 2, 2023 Author Member Share Posted July 2, 2023 15 hours ago, Elemeno said: cant you just use a split command?? not for the operation I'm trying to do, I will eventually end up using split or subtract to split the mold in two Quote Link to comment Share on other sites More sharing options...
Andrew Shpagin Posted July 3, 2023 Share Posted July 3, 2023 On my side script runs correctly. But try adding coat.io.step(2) after intersection to ensure that mesh operation finished: sbox=coat.box(center,size) sbox.intersect(target.Volume()) coat.io.step(2) Quote Link to comment Share on other sites More sharing options...
Solution Andrew Shpagin Posted July 3, 2023 Solution Share Posted July 3, 2023 Other workaround is to use mesh instead of primitive: sbox = coat.Mesh.box(center,size) sbox.toVolume(target.Volume(), op=coat.BoolOpType.BOOL_INTERSECT) Quote Link to comment Share on other sites More sharing options...
Andrew Shpagin Posted July 3, 2023 Share Posted July 3, 2023 If I will loose this thread please remind me at andrewshpagin@gmail.com, I want to make python scripting to be really solid. 1 1 1 Quote Link to comment Share on other sites More sharing options...
Member celer Posted October 17, 2023 Author Member Share Posted October 17, 2023 Thanks for your response, I'm back at this now, I took two months off a computer to see if helped me recover my hands after an RSI from software dev. I will send you an email as I'm still having issues. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.