Sorry for my English
Maybe some of you remember "Adjust to Bitmap": free plug-in distributed from the same site of the old Tuile-Gen (now not available)
I needed it and I wrote something with Python!
Ok, but what does it do?
Quickly set the size of a plane with the size of the assigned texture
And what is it?
For example it is useful to quickly resize the plans with the blueprint texture.
How it works:
- creates plans and assigns the texture
- selection plan and execute the script (using the button on a palette or using keyboard shortcut)
Installation:
- unzip the zip file in C:\...C4D_DIRECTORY...\library\scripts
- now you can decide whether to add the button in a palette and / or assign a keyboard shortcut
To who wanted to look at the code:
Codice: Seleziona tutto
import c4d
from c4d import gui, bitmaps
def main():
# controlla se hai selezionato qualcosa
if not op:
print "Selezionare un oggetto Piano"
gui.MessageDialog("Selezionare un oggetto Piano")
return
# controlla se hai selezionato un oggetto Piano
elif op.GetType()!=5168:
print "Selezionare un oggetto Piano"
gui.MessageDialog("Selezionare un oggetto Piano")
return
# controlla se l'oggetto selezionatoha una texture
elif not op.GetTag(c4d.Ttexture):
print "All'oggetto Piano non è assegnato alcun materiale"
gui.MessageDialog("All'oggetto Piano non è assegnato alcun materiale")
else:
# leggi path texture
path = op.GetTag(c4d.Ttexture)[c4d.TEXTURETAG_MATERIAL][c4d.MATERIAL_COLOR_SHADER][c4d.BITMAPSHADER_FILENAME]
print "path: "+path
# assegna la texture ad una nuova bitmap
bmp = bitmaps.BaseBitmap(path)
bmp.InitWith(path)
# leggi i valori x y della texture
x, y = bmp.GetSize()
print x
print y
# assegna al Piano i valori letti
op[c4d.PRIM_PLANE_WIDTH] = x
op[c4d.PRIM_PLANE_HEIGHT] = y
op[c4d.PRIM_PLANE_SUBW] = 1
op[c4d.PRIM_PLANE_SUBH] = 1
c4d.EventAdd()
return
if __name__=='__main__':
main()
I hope my experiment is helpful critiques and suggestions are always welcome!
FOLLOW US