I wrote script to set LOD Value of model .Based on Bounding box calculation, I hope it is useful when you Appling LOD value for box kind of models.
Great... thanks for posting this. Hopefully others will find it useful.
If you like you can also post "code" directly inline here on the forum. You do so by enclosing the code in begin/end code tags. Click the "code" button on the Topic Toolbar to enter begin/end code tags. Then simply enter your code between the begin/end tags. I took the liberty of enclosing your code in this way here: I hope you don't mind.
I also fixed a minor problem in the original script posted. In the file attached, the function LodValue was being called as LodValues (note 's' on name). I suspect you might have changed the function name at some point during debugging. This highlights a nasty gotcha in Python. If the original function was called LodValues and you ran it once, it is forever defined in Python (until you restart the host application). If you subsequently rename it LodValue but continue to call LodValues, the "old" LodValues (still defined) will be called instead of the new function you renamed. You can see how this can cause nasty results if you're not careful.
If you're debugging your Scripts in Creator, a good thing to do is to "restart" Creator and run the "final" version of the script one more time to make sure it is still ok. Restarting Creator, in this scenario, will "clear" the old LodValues function leaving only the new LodValue function defined. If your script still calls the old LodValues function, Python will complain when that function cannot be found (restarting Creator "clears" out Python's memory in this way). I suspect every Python script developer has been bitten by this at one point. I know I have been! Hopefully now that you know this can happen, it will help in the future.
Anyway, here is the "fixed" version of your upload. Thanks again for sharing your script.
db = mgGetCurrentDb()
Mainvalue = 140
ok,Lodbox = mgGetBounds(rec)
LodboxM= mgBoxGetDiagonalSize(Lodbox) % 10
def BeadWalk (db, parent, rec, userData):
if mgGetCode (rec) == fltLod:
if db != None:
mgWalk (db,BeadWalk, None, None, MWALK_NOREADONLY)
Thank you SteveThompson, Thanks for your advice. Sorry you did small mistake in script.you left out Modulus Operator with 10. If add Code directly in post it won't be display .Here I Attached My fixed version Script.
Hmmm... there seems to be a problem with the code begin/end here on the forum. You are correct, anything after the % (percent) symbol in the code is not displayed. That is why the modulo operator with 10 was left off my updated post. It got stripped out by the forum software.
I'll try to figure out a fix for that. Thanks!
I got the "%" to show up in the code (see updated post above). It seems that as long as there are "spaces" around it, it will show up. So if you do want to use % in your code snippets, make sure to put the "space" character before and after the % like this:
LodboxM = mgBoxGetDiagonalSize(Lodbox) % 10
Sorry about that.